|
|
|
@ -334,24 +334,23 @@ void template_load_cfg(char* cmd, dictionary* load_cfg) {
|
|
|
|
|
void init_cfg_array(int index) {
|
|
|
|
|
//main_config.disk = yon_char_parsed_append(main_config.disk, &index, "-");
|
|
|
|
|
//index--;
|
|
|
|
|
set_pow_size_memory("-", &main_config.type_quota_size, index);
|
|
|
|
|
set_size_memory_integer_char("-", &main_config.type_quota, index);
|
|
|
|
|
philos_set_pow_size_memory("-", &main_config.type_quota_size, index, array_size_pow);
|
|
|
|
|
philos_set_size_memory_integer_char("-", &main_config.type_quota, index);
|
|
|
|
|
|
|
|
|
|
set_pow_size_memory("-", &main_config.quota_volume_size, index);
|
|
|
|
|
set_size_memory_integer_char("-", &main_config.quota_volume, index);
|
|
|
|
|
philos_set_pow_size_memory("-", &main_config.quota_volume_size, index, array_size_pow);
|
|
|
|
|
philos_set_size_memory_integer_char("-", &main_config.quota_volume, index);
|
|
|
|
|
|
|
|
|
|
set_pow_size_memory("-", &main_config.cpu_limit_size, index);
|
|
|
|
|
philos_set_pow_size_memory("-", &main_config.cpu_limit_size, index, array_size_pow);
|
|
|
|
|
set_size_memory_integer("-", &main_config.cpu_limit, index);
|
|
|
|
|
|
|
|
|
|
set_pow_size_memory("-", &main_config.soft_raw_limit_size, index);
|
|
|
|
|
philos_set_pow_size_memory("-", &main_config.soft_raw_limit_size, index, array_size_pow);
|
|
|
|
|
set_size_memory_integer("-", &main_config.soft_raw_limit, index);
|
|
|
|
|
|
|
|
|
|
set_pow_size_memory("-", &main_config.hard_raw_limit_size, index);
|
|
|
|
|
philos_set_pow_size_memory("-", &main_config.hard_raw_limit_size, index, array_size_pow);
|
|
|
|
|
set_size_memory_integer("-", &main_config.hard_raw_limit, index);
|
|
|
|
|
|
|
|
|
|
set_pow_size_memory("-", &main_config.swap_size, index);
|
|
|
|
|
philos_set_pow_size_memory("-", &main_config.swap_size, index, array_size_pow);
|
|
|
|
|
set_size_memory_integer("-",&main_config.swap , index);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void str_split_key(char* source_value, int index) {
|
|
|
|
@ -431,19 +430,19 @@ void str_split_value(char* values, int index) {
|
|
|
|
|
get_param_io_limit(arr_values, index_1, size,index, "IOWriteBandwidthMax");
|
|
|
|
|
}
|
|
|
|
|
if (yon_char_find_count(key, "MemoryHigh") != 0) {
|
|
|
|
|
set_pow_size_memory(yon_char_new(value), &main_config.soft_raw_limit_size, index);
|
|
|
|
|
philos_set_pow_size_memory(yon_char_new(value), &main_config.soft_raw_limit_size, index, array_size_pow);
|
|
|
|
|
set_size_memory_integer(yon_char_new(value), &main_config.soft_raw_limit, index);
|
|
|
|
|
}
|
|
|
|
|
if (yon_char_find_count(key, "MemoryMax") != 0) {
|
|
|
|
|
set_pow_size_memory(yon_char_new(value), &main_config.hard_raw_limit_size, index);
|
|
|
|
|
philos_set_pow_size_memory(yon_char_new(value), &main_config.hard_raw_limit_size, index, array_size_pow);
|
|
|
|
|
set_size_memory_integer(yon_char_new(value), &main_config.hard_raw_limit, index);
|
|
|
|
|
}
|
|
|
|
|
if (yon_char_find_count(key, "MemorySwapMax") != 0) {
|
|
|
|
|
set_pow_size_memory(yon_char_new(value), &main_config.swap_size, index);
|
|
|
|
|
philos_set_pow_size_memory(yon_char_new(value), &main_config.swap_size, index, array_size_pow);
|
|
|
|
|
set_size_memory_integer(yon_char_new(value), &main_config.swap, index);
|
|
|
|
|
}
|
|
|
|
|
if (yon_char_find_count(key, "CPUQuota") != 0) {
|
|
|
|
|
set_pow_size_memory(yon_char_new(value), &main_config.cpu_limit_size, index);
|
|
|
|
|
philos_set_pow_size_memory(yon_char_new(value), &main_config.cpu_limit_size, index, array_size_pow);
|
|
|
|
|
set_size_memory_integer(yon_char_new(value), &main_config.cpu_limit, index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -466,7 +465,7 @@ void get_param_io_limit(char** arr_values, int index_start, int size, int index_
|
|
|
|
|
char* disk = yon_char_divide_search(yon_char_new(value), " ", -1);
|
|
|
|
|
array_disk = yon_char_parsed_append(array_disk, &index_n2, disk);
|
|
|
|
|
index_n2--;
|
|
|
|
|
set_pow_size_memory(yon_char_new(value), &array_limit_size, index_n2);
|
|
|
|
|
philos_set_pow_size_memory(yon_char_new(value), &array_limit_size, index_n2, array_size_pow);
|
|
|
|
|
set_size_memory_integer(yon_char_new(value), &array_limit, index_n2);
|
|
|
|
|
flag_parsed = 1;
|
|
|
|
|
index_n2++;
|
|
|
|
@ -483,7 +482,7 @@ void get_param_io_limit(char** arr_values, int index_start, int size, int index_
|
|
|
|
|
char* disk = yon_char_divide_search(yon_char_new(arr_values[i]), " ", -1);
|
|
|
|
|
array_disk = yon_char_parsed_append(array_disk, &index_n2, disk);
|
|
|
|
|
index_n2--;
|
|
|
|
|
set_pow_size_memory(yon_char_new(arr_values[i]), &array_limit_size, index_n2);
|
|
|
|
|
philos_set_pow_size_memory(yon_char_new(arr_values[i]), &array_limit_size, index_n2, array_size_pow);
|
|
|
|
|
set_size_memory_integer(yon_char_new(arr_values[i]), &array_limit, index_n2);
|
|
|
|
|
index_n2++;
|
|
|
|
|
}
|
|
|
|
@ -539,72 +538,6 @@ void set_size_memory_integer(char* str_find, int** array_data, int index) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_size_memory_integer_char(char* str_find, char*** array_data, int index) {
|
|
|
|
|
char* simv_del_array[10] = {"K","M","G","T","k","m","g","t"," ","%"};
|
|
|
|
|
for (size_t i = 0; i < 10; i++) {
|
|
|
|
|
if (strstr(str_find, simv_del_array[i])) {
|
|
|
|
|
str_find = yon_char_divide_search(str_find, simv_del_array[i], -1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (strstr(str_find, " ") != NULL) {
|
|
|
|
|
char* mem_s = yon_char_new(str_find);
|
|
|
|
|
yon_char_divide_search(mem_s, " ", -1);
|
|
|
|
|
*array_data = yon_char_parsed_append(*array_data, &index, mem_s);
|
|
|
|
|
}
|
|
|
|
|
if (strstr(str_find, "-") != NULL) {
|
|
|
|
|
*array_data = yon_char_parsed_append(*array_data, &index, "-");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (str_find[0] == '\"') {
|
|
|
|
|
yon_char_divide(str_find, 0);
|
|
|
|
|
size_t length = strlen(str_find);
|
|
|
|
|
str_find = yon_char_divide(str_find, length-2);
|
|
|
|
|
}
|
|
|
|
|
if (strstr(str_find, " ") == NULL) {
|
|
|
|
|
*array_data = yon_char_parsed_append(*array_data, &index, str_find);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void set_pow_size_memory(char* str_find, int** array_size,int index) {
|
|
|
|
|
size_t length = strlen(str_find);
|
|
|
|
|
if (strstr(str_find,"K") != NULL) {
|
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 0);
|
|
|
|
|
str_find = yon_char_divide(str_find, length-1);
|
|
|
|
|
str_find = yon_char_unite(str_find, " ", STR_KB, NULL);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(str_find,"M") != NULL) {
|
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 1);
|
|
|
|
|
str_find = yon_char_divide(str_find, length-1);
|
|
|
|
|
str_find = yon_char_unite(str_find," ", STR_MB, NULL);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(str_find,"G") != NULL) {
|
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 2);
|
|
|
|
|
str_find = yon_char_divide(str_find, length-1);
|
|
|
|
|
str_find = yon_char_unite(str_find," ", STR_GB, NULL);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(str_find,"T") != NULL) {
|
|
|
|
|
*array_size = philos_int_append(*array_size, &index, 3);
|
|
|
|
|
str_find = yon_char_divide(str_find, length-1);
|
|
|
|
|
|
|
|
|
|
str_find = yon_char_unite(str_find," ", STR_TB, NULL);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(str_find,"%%") != NULL) {
|
|
|
|
|
*array_size = philos_int_append(*array_size, &index, -1);
|
|
|
|
|
str_find = yon_char_divide(str_find, length-1);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(str_find,"-") != NULL) {
|
|
|
|
|
*array_size = philos_int_append(*array_size, &index, -1);
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void main_cbx_2_event() {
|
|
|
|
|
int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtMainInfoLevel2));
|
|
|
|
|
char* cmd_text_param = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->cbtMainInfoLevel2));
|
|
|
|
@ -1033,52 +966,36 @@ char* save_format_value(int index) {
|
|
|
|
|
split_simvol[0] = 0;
|
|
|
|
|
split_simvol[1] = 0;
|
|
|
|
|
if (main_config.soft_raw_limit[index]==0) {
|
|
|
|
|
char* value1 = yon_char_unite(philos_format_cfg_str_size_memory("MemoryHigh=", main_config.soft_raw_limit[index],main_config.soft_raw_limit_size[index]),NULL);
|
|
|
|
|
if (strstr(value1,"-")) {
|
|
|
|
|
free(value1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
value = yon_char_new(value1);
|
|
|
|
|
free(value1);
|
|
|
|
|
char* value_size = philos_format_cfg_str_size_memory("MemoryHigh=", main_config.soft_raw_limit[index],main_config.soft_raw_limit_size[index]);
|
|
|
|
|
if (!strstr(value_size,"-")) {
|
|
|
|
|
value = yon_char_unite(value ,split_simvol, value_size, NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
free(value_size);
|
|
|
|
|
}
|
|
|
|
|
if (main_config.hard_raw_limit[index]==0) {
|
|
|
|
|
char* value1 = yon_char_unite(value ,split_simvol, philos_format_cfg_str_size_memory("MemoryMax=", main_config.hard_raw_limit[index],main_config.hard_raw_limit_size[index]), NULL);
|
|
|
|
|
if (strstr(value1,"-")) {
|
|
|
|
|
free(value1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
value = yon_char_new(value1);
|
|
|
|
|
free(value1);
|
|
|
|
|
char* value_size = philos_format_cfg_str_size_memory("MemoryMax=", main_config.hard_raw_limit[index],main_config.hard_raw_limit_size[index]);
|
|
|
|
|
if (!strstr(value_size,"-")) {
|
|
|
|
|
value = yon_char_unite(value ,split_simvol, value_size, NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
free(value_size);
|
|
|
|
|
}
|
|
|
|
|
if (main_config.swap[index]==0) {
|
|
|
|
|
char* value1 = yon_char_unite(value ,split_simvol, philos_format_cfg_str_size_memory("MemorySwapMax=", main_config.swap[index],main_config.swap_size[index]), NULL);
|
|
|
|
|
if (strstr(value1,"-")) {
|
|
|
|
|
free(value1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
value = yon_char_new(value1);
|
|
|
|
|
free(value1);
|
|
|
|
|
char* value_size = philos_format_cfg_str_size_memory("MemorySwapMax=", main_config.swap[index],main_config.swap_size[index]);
|
|
|
|
|
if (!strstr(value_size,"-")) {
|
|
|
|
|
value = yon_char_unite(value ,split_simvol, value_size, NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
free(value_size);
|
|
|
|
|
}
|
|
|
|
|
if (main_config.cpu_limit[index]==0) {
|
|
|
|
|
char* value1 = yon_char_unite(value ,split_simvol,"CPUQuota=", main_config.cpu_limit[index], NULL);
|
|
|
|
|
if (strstr(value1,"-")) {
|
|
|
|
|
free(value1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
value = yon_char_new(value1);
|
|
|
|
|
free(value1);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
if (main_config.cpu_limit[index]>=0) {
|
|
|
|
|
value = yon_char_unite(value ,split_simvol,"CPUQuota=", yon_char_from_int(main_config.cpu_limit[index]), "%", NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
value = add_io_str_format_ubconfig(value, "IOReadBandwidthMax", main_config.i_o_limit_read, main_config.i_o_limit_read_size, main_config.disk, index);
|
|
|
|
|
value = add_io_str_format_ubconfig(value, "IOWriteBandwidthMax", main_config.i_o_limit_write, main_config.i_o_limit_write_size, main_config.disk, index);
|
|
|
|
@ -1086,33 +1003,36 @@ char* save_format_value(int index) {
|
|
|
|
|
}
|
|
|
|
|
char* add_io_str_format_ubconfig(char* cmd_io, char* key, int** i_o_limit, int** i_o_limit_size, char*** disk, int index) {
|
|
|
|
|
char split_simvol[2] = {0};
|
|
|
|
|
if (i_o_limit) {
|
|
|
|
|
if (i_o_limit[index] != NULL) {
|
|
|
|
|
if (i_o_limit[index] != NULL) {
|
|
|
|
|
for (int i = 0;i_o_limit[index][i] != -2; i++) {
|
|
|
|
|
if (i==0 && strlen(cmd_io) == 0) {
|
|
|
|
|
cmd_io = yon_char_unite(cmd_io, ",", key, "=", NULL);
|
|
|
|
|
}
|
|
|
|
|
if (cmd_io == NULL) {
|
|
|
|
|
cmd_io = yon_char_new("");
|
|
|
|
|
}
|
|
|
|
|
int read_limit = i_o_limit[index][i];
|
|
|
|
|
char* read_disk = disk[index][i];
|
|
|
|
|
int read_limit_size = i_o_limit_size[index][i];
|
|
|
|
|
if (read_limit >= 0 && read_disk && read_limit_size >= 0) {
|
|
|
|
|
char* num_and_pow_size = philos_format_cfg_str_size_memory("",read_limit, read_limit_size);
|
|
|
|
|
cmd_io = yon_char_unite(cmd_io, split_simvol, read_disk, " ",num_and_pow_size, NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (i_o_limit== NULL) {return cmd_io;}
|
|
|
|
|
if (i_o_limit_size[index] == NULL) {return cmd_io;}
|
|
|
|
|
if (i_o_limit[index] == NULL) {return cmd_io;}
|
|
|
|
|
int len_array = 0;
|
|
|
|
|
for (int i = 0;i_o_limit[index][i] != -2; i++) {
|
|
|
|
|
len_array += 1;
|
|
|
|
|
}
|
|
|
|
|
for (int i=0; i<len_array; i++) {
|
|
|
|
|
if (i==0 && strlen(cmd_io) < 3) {
|
|
|
|
|
cmd_io = yon_char_unite(cmd_io, key, "=", NULL);
|
|
|
|
|
}
|
|
|
|
|
else if (i==0 && strlen(cmd_io) > 3) {
|
|
|
|
|
cmd_io = yon_char_unite(cmd_io, ",", key, "=", NULL);
|
|
|
|
|
}
|
|
|
|
|
puts(cmd_io);
|
|
|
|
|
int read_limit = i_o_limit[index][i];
|
|
|
|
|
char* read_disk = disk[index][i];
|
|
|
|
|
int read_limit_size = i_o_limit_size[index][i];
|
|
|
|
|
if (read_limit >= 0 && read_disk && read_limit_size >= 0) {
|
|
|
|
|
char* num_and_pow_size = philos_format_cfg_str_size_memory("",read_limit, read_limit_size);
|
|
|
|
|
cmd_io = yon_char_unite(cmd_io, split_simvol, read_disk, " ",num_and_pow_size, NULL);
|
|
|
|
|
split_simvol[0] = ',';
|
|
|
|
|
split_simvol[1] = '\0';
|
|
|
|
|
free(num_and_pow_size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return cmd_io;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int check_save(dictionary* load_cfg) {
|
|
|
|
|
if (main_config.flag_set_data == 1) {
|
|
|
|
|
return 0;
|
|
|
|
@ -1159,6 +1079,7 @@ char* template_format_str_set_save(dictionary* load_cfg, char* source_set_cmd) {
|
|
|
|
|
value = yon_char_new(save_format_value(index));
|
|
|
|
|
if (key != NULL && value != NULL) {
|
|
|
|
|
cmd = yon_char_unite(cmd, " " , key, "=\"" , value, "\"\n", NULL);
|
|
|
|
|
puts(cmd);
|
|
|
|
|
flag_save = 1;
|
|
|
|
|
}
|
|
|
|
|
if (key != NULL) {
|
|
|
|
@ -1237,6 +1158,11 @@ int main(int argc, char *argv[]){
|
|
|
|
|
local=setlocale(LC_ALL, "");
|
|
|
|
|
textdomain (LocaleName);
|
|
|
|
|
config_init();
|
|
|
|
|
int size_array_size_pow = 0;
|
|
|
|
|
array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_KB);
|
|
|
|
|
array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_MB);
|
|
|
|
|
array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_GB);
|
|
|
|
|
array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_TB);
|
|
|
|
|
int option_index=0;
|
|
|
|
|
int show_help=0;
|
|
|
|
|
{
|
|
|
|
@ -1332,5 +1258,6 @@ int main(int argc, char *argv[]){
|
|
|
|
|
load_global_cfg();
|
|
|
|
|
load_system_cfg();
|
|
|
|
|
gtk_main();
|
|
|
|
|
philos_free_string_array(&array_size_pow, size_array_size_pow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|