mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 18:45:10 +00:00
Make net_avg_samples a lua setting
This commit is contained in:
parent
80f3359634
commit
9d30e34a01
16
src/conky.cc
16
src/conky.cc
@ -354,8 +354,9 @@ static conky::simple_config_setting<bool> fork_to_background("background", false
|
||||
* first forking */
|
||||
static int first_pass = 1;
|
||||
|
||||
static int net_avg_samples, diskio_avg_samples;
|
||||
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> net_avg_samples("net_avg_samples", 1, 14, 2, true);
|
||||
|
||||
/* filenames for output */
|
||||
char *overwrite_file = NULL; FILE *overwrite_fpointer = NULL;
|
||||
@ -2595,7 +2596,6 @@ static void set_default_configurations(void)
|
||||
{
|
||||
update_uname();
|
||||
total_run_times = 0;
|
||||
info.net_avg_samples = 2;
|
||||
info.diskio_avg_samples = 2;
|
||||
info.memmax = 0;
|
||||
top_cpu = 0;
|
||||
@ -2877,18 +2877,6 @@ char load_config_file(const char *f)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CONF("net_avg_samples") {
|
||||
if (value) {
|
||||
net_avg_samples = strtol(value, 0, 0);
|
||||
if (net_avg_samples < 1 || net_avg_samples > 14) {
|
||||
CONF_ERR;
|
||||
} else {
|
||||
info.net_avg_samples = net_avg_samples;
|
||||
}
|
||||
} else {
|
||||
CONF_ERR;
|
||||
}
|
||||
}
|
||||
CONF("diskio_avg_samples") {
|
||||
if (value) {
|
||||
diskio_avg_samples = strtol(value, 0, 0);
|
||||
|
@ -213,8 +213,6 @@ struct information {
|
||||
/* struct cpu_stat cpu_summed; what the hell is this? */
|
||||
int cpu_count;
|
||||
|
||||
int net_avg_samples;
|
||||
|
||||
int diskio_avg_samples;
|
||||
|
||||
float loadavg[3];
|
||||
@ -247,6 +245,7 @@ struct information {
|
||||
};
|
||||
|
||||
extern conky::range_config_setting<int> cpu_avg_samples;
|
||||
extern conky::range_config_setting<int> net_avg_samples;
|
||||
|
||||
/* needed by linux.c and top.c -> outsource somewhere */
|
||||
enum {
|
||||
|
11
src/linux.cc
11
src/linux.cc
@ -479,20 +479,21 @@ int update_net_stats(void)
|
||||
curtmp1 = 0;
|
||||
curtmp2 = 0;
|
||||
// get an average
|
||||
int samples = net_avg_samples.get(*state);
|
||||
#ifdef HAVE_OPENMP
|
||||
#pragma omp parallel for reduction(+:curtmp1, curtmp2) schedule(dynamic,10)
|
||||
#endif /* HAVE_OPENMP */
|
||||
for (i = 0; i < info.net_avg_samples; i++) {
|
||||
for (i = 0; i < samples; i++) {
|
||||
curtmp1 = curtmp1 + ns->net_rec[i];
|
||||
curtmp2 = curtmp2 + ns->net_trans[i];
|
||||
}
|
||||
ns->recv_speed = curtmp1 / (double) info.net_avg_samples;
|
||||
ns->trans_speed = curtmp2 / (double) info.net_avg_samples;
|
||||
if (info.net_avg_samples > 1) {
|
||||
ns->recv_speed = curtmp1 / (double) samples;
|
||||
ns->trans_speed = curtmp2 / (double) samples;
|
||||
if (samples > 1) {
|
||||
#ifdef HAVE_OPENMP
|
||||
#pragma omp parallel for schedule(dynamic,10)
|
||||
#endif /* HAVE_OPENMP */
|
||||
for (i = info.net_avg_samples; i > 1; i--) {
|
||||
for (i = samples; i > 1; i--) {
|
||||
ns->net_rec[i - 1] = ns->net_rec[i - 2];
|
||||
ns->net_trans[i - 1] = ns->net_trans[i - 2];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user