mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-16 01:57:09 +00:00
Make diskio_avg_samples a lua setting
This commit is contained in:
parent
9d30e34a01
commit
228f65bc52
15
src/conky.cc
15
src/conky.cc
@ -354,9 +354,9 @@ static conky::simple_config_setting<bool> fork_to_background("background", false
|
|||||||
* first forking */
|
* first forking */
|
||||||
static int first_pass = 1;
|
static int first_pass = 1;
|
||||||
|
|
||||||
static int diskio_avg_samples;
|
|
||||||
conky::range_config_setting<int> cpu_avg_samples("cpu_avg_samples", 1, 14, 2, true);
|
conky::range_config_setting<int> cpu_avg_samples("cpu_avg_samples", 1, 14, 2, true);
|
||||||
conky::range_config_setting<int> net_avg_samples("net_avg_samples", 1, 14, 2, true);
|
conky::range_config_setting<int> net_avg_samples("net_avg_samples", 1, 14, 2, true);
|
||||||
|
conky::range_config_setting<int> diskio_avg_samples("diskio_avg_samples", 1, 14, 2, true);
|
||||||
|
|
||||||
/* filenames for output */
|
/* filenames for output */
|
||||||
char *overwrite_file = NULL; FILE *overwrite_fpointer = NULL;
|
char *overwrite_file = NULL; FILE *overwrite_fpointer = NULL;
|
||||||
@ -2596,7 +2596,6 @@ static void set_default_configurations(void)
|
|||||||
{
|
{
|
||||||
update_uname();
|
update_uname();
|
||||||
total_run_times = 0;
|
total_run_times = 0;
|
||||||
info.diskio_avg_samples = 2;
|
|
||||||
info.memmax = 0;
|
info.memmax = 0;
|
||||||
top_cpu = 0;
|
top_cpu = 0;
|
||||||
top_mem = 0;
|
top_mem = 0;
|
||||||
@ -2877,18 +2876,6 @@ char load_config_file(const char *f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
CONF("diskio_avg_samples") {
|
|
||||||
if (value) {
|
|
||||||
diskio_avg_samples = strtol(value, 0, 0);
|
|
||||||
if (diskio_avg_samples < 1 || diskio_avg_samples > 14) {
|
|
||||||
CONF_ERR;
|
|
||||||
} else {
|
|
||||||
info.diskio_avg_samples = diskio_avg_samples;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
CONF_ERR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CONF("max_text_width") {
|
CONF("max_text_width") {
|
||||||
max_text_width = atoi(value);
|
max_text_width = atoi(value);
|
||||||
}
|
}
|
||||||
|
@ -213,8 +213,6 @@ struct information {
|
|||||||
/* struct cpu_stat cpu_summed; what the hell is this? */
|
/* struct cpu_stat cpu_summed; what the hell is this? */
|
||||||
int cpu_count;
|
int cpu_count;
|
||||||
|
|
||||||
int diskio_avg_samples;
|
|
||||||
|
|
||||||
float loadavg[3];
|
float loadavg[3];
|
||||||
|
|
||||||
#ifdef BUILD_XMMS2
|
#ifdef BUILD_XMMS2
|
||||||
@ -246,6 +244,7 @@ struct information {
|
|||||||
|
|
||||||
extern conky::range_config_setting<int> cpu_avg_samples;
|
extern conky::range_config_setting<int> cpu_avg_samples;
|
||||||
extern conky::range_config_setting<int> net_avg_samples;
|
extern conky::range_config_setting<int> net_avg_samples;
|
||||||
|
extern conky::range_config_setting<int> diskio_avg_samples;
|
||||||
|
|
||||||
/* needed by linux.c and top.c -> outsource somewhere */
|
/* needed by linux.c and top.c -> outsource somewhere */
|
||||||
enum {
|
enum {
|
||||||
|
@ -194,17 +194,18 @@ void update_diskio_values(struct diskio_stat *ds,
|
|||||||
ds->sample[0] = ds->sample_read[0] + ds->sample_write[0];
|
ds->sample[0] = ds->sample_read[0] + ds->sample_write[0];
|
||||||
|
|
||||||
/* compute averages */
|
/* compute averages */
|
||||||
for (i = 0; i < (signed) info.diskio_avg_samples; i++) {
|
int samples = diskio_avg_samples.get(*state);
|
||||||
|
for (i = 0; i < samples; i++) {
|
||||||
sum += ds->sample[i];
|
sum += ds->sample[i];
|
||||||
sum_r += ds->sample_read[i];
|
sum_r += ds->sample_read[i];
|
||||||
sum_w += ds->sample_write[i];
|
sum_w += ds->sample_write[i];
|
||||||
}
|
}
|
||||||
ds->current = sum / (double) info.diskio_avg_samples;
|
ds->current = sum / (double) samples;
|
||||||
ds->current_read = sum_r / (double) info.diskio_avg_samples;
|
ds->current_read = sum_r / (double) samples;
|
||||||
ds->current_write = sum_w / (double) info.diskio_avg_samples;
|
ds->current_write = sum_w / (double) samples;
|
||||||
|
|
||||||
/* shift sample history */
|
/* shift sample history */
|
||||||
for (i = info.diskio_avg_samples-1; i > 0; i--) {
|
for (i = samples-1; i > 0; i--) {
|
||||||
ds->sample[i] = ds->sample[i-1];
|
ds->sample[i] = ds->sample[i-1];
|
||||||
ds->sample_read[i] = ds->sample_read[i-1];
|
ds->sample_read[i] = ds->sample_read[i-1];
|
||||||
ds->sample_write[i] = ds->sample_write[i-1];
|
ds->sample_write[i] = ds->sample_write[i-1];
|
||||||
|
Loading…
Reference in New Issue
Block a user