1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-02-12 17:08:29 +00:00

Added diskio_avg_samples patch (thanks Yeon-Hyeong)

This commit is contained in:
Yeon-Hyeong Yang 2009-05-01 17:03:59 -06:00 committed by Brenden Matthews
parent 814469b0c9
commit 68ea7a7859
8 changed files with 233 additions and 194 deletions

View File

@ -1,3 +1,6 @@
2009-05-01
* Added diskio_avg_samples patch (thanks Yeon-Hyeong)
2009-05-01 2009-05-01
* Conky 1.7.0 "Hungry Hobo" released! * Conky 1.7.0 "Hungry Hobo" released!

53
README
View File

@ -173,15 +173,15 @@ conky(1) conky(1)
background background
Boolean value, if true, Conky will be forked to background when Boolean value, if true, Conky will be forked to background when
started started.
border_margin border_margin
Border margin in pixels Border margin in pixels.
border_width border_width
Border width in pixels Border width in pixels.
colorN Predefine a color for use inside TEXT segments. Substitute N by colorN Predefine a color for use inside TEXT segments. Substitute N by
@ -190,7 +190,11 @@ conky(1) conky(1)
cpu_avg_samples cpu_avg_samples
The number of samples to average for CPU monitoring The number of samples to average for CPU monitoring.
diskio_avg_samples
The number of samples to average for disk I/O monitoring.
top_cpu_separate top_cpu_separate
@ -202,7 +206,7 @@ conky(1) conky(1)
default_bar_size default_bar_size
Specify a default width and height for bars. Example: 'de Specify a default width and height for bars. Example: 'de
fault_bar_size 0 6'. This is particularly useful for execbar and fault_bar_size 0 6'. This is particularly useful for execbar and
execibar as they do not take size arguments execibar as they do not take size arguments.
default_graph_size default_graph_size
@ -672,14 +676,19 @@ conky(1) conky(1)
a digit between 0 and 9, inclusively. a digit between 0 and 9, inclusively.
combine var1 var2
Places the lines of var2 to the right of the lines of var1
seperated by the chars that are put between var1 and var2. For
example: ${combine ${head /proc/cpuinfo 2} - ${head /proc/memin
fo 1}} gives as output "cpuinfo_line1 - meminfo_line1" on line 1
and "cpuinfo_line2 -" on line 2. $combine vars can also be nest
ed to place more vars next to each other.
conky_version conky_version
Conky version Conky version
combine var1 var2
Places the lines of var2 to the right of the lines of var1 seperated by the chars that are put between var1 and var2. For example: ${combine ${head /proc/cpuinfo 2} - ${head /proc/meminfo 1}} gives as output "cpuinfo_line1 - meminfo_line1" on line 1 and "cpuinfo_line2 -" on line 2. $combine vars can also be nested to place more vars next to each other.
conky_build_date conky_build_date
Date Conky was built Date Conky was built
@ -874,21 +883,6 @@ conky(1) conky(1)
omitted, the parameter defaults to 1. omitted, the parameter defaults to 1.
<<<<<<< HEAD:README
freq_dyn (n)
Returns CPU #n's frequency in MHz (defaults to 1), but is calcu
lated by counting to clock cycles to complete an instruction.
Only available for x86/amd64.
freq_dyn_g (n)
Returns CPU #n's frequency in GHz (defaults to 1), but is calcu
lated by counting to clock cycles to complete an instruction.
Only available for x86/amd64.
=======
>>>>>>> cb4b914... Few misc doc related things.:README
fs_bar (height),(width) fs fs_bar (height),(width) fs
Bar that shows how much space is used on a file system. height Bar that shows how much space is used on a file system. height
is the height in pixels. fs is any file on that file system. is the height in pixels. fs is any file on that file system.
@ -1262,15 +1256,11 @@ conky(1) conky(1)
Bar that shows amount of memory in use Bar that shows amount of memory in use
<<<<<<< HEAD:README
memgauge (height),(width) memgauge (height),(width)
Gauge that shows amount of memory in use (see cpugauge) Gauge that shows amount of memory in use (see cpugauge)
memgraph ("normal"|"log") (height),(width) (gradient colour 1) (gradi memgraph ("normal"|"log") (height),(width) (gradient colour 1) (gradi
=======
memgraph ("normal"|"log") (height),(width) (gradient colour 1) (gradi
>>>>>>> cb4b914... Few misc doc related things.:README
ent colour 2) (scale) ent colour 2) (scale)
Memory usage graph. Uses a logarithmic scale (to see small num Memory usage graph. Uses a logarithmic scale (to see small num
bers) when you use "log" instead of "normal". bers) when you use "log" instead of "normal".
@ -1664,18 +1654,11 @@ conky(1) conky(1)
Move text over by N pixels. See also $voffset. Move text over by N pixels. See also $voffset.
<<<<<<< HEAD:README
rss url delay_in_minutes action (num_par (spaces_in_front)) rss url delay_in_minutes action (num_par (spaces_in_front))
Download and parse RSS feeds. Action may be one of the follow Download and parse RSS feeds. Action may be one of the follow
ing: feed_title, item_title (with num par), item_desc (with num ing: feed_title, item_title (with num par), item_desc (with num
par) and item_titles (when using this action and spaces_in_front par) and item_titles (when using this action and spaces_in_front
is given conky places that many spaces in front of each item). is given conky places that many spaces in front of each item).
=======
rss url delay_in_minutes action item_num
Download and parse RSS feeds. Action may be one of the follow
ing: feed_title, item_title (with num par), item_desc (with num
par) and item_titles.
>>>>>>> cb4b914... Few misc doc related things.:README
tab (width, (start)) tab (width, (start))

View File

@ -16,21 +16,21 @@
<varlistentry> <varlistentry>
<term><command><option>background</option></command></term> <term><command><option>background</option></command></term>
<listitem> <listitem>
Boolean value, if true, Conky will be forked to background when started Boolean value, if true, Conky will be forked to background when started.
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><command><option>border_margin</option></command></term> <term><command><option>border_margin</option></command></term>
<listitem> <listitem>
Border margin in pixels Border margin in pixels.
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><command><option>border_width</option></command></term> <term><command><option>border_width</option></command></term>
<listitem> <listitem>
Border width in pixels Border width in pixels.
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>
@ -44,7 +44,14 @@
<varlistentry> <varlistentry>
<term><command><option>cpu_avg_samples</option></command></term> <term><command><option>cpu_avg_samples</option></command></term>
<listitem> <listitem>
The number of samples to average for CPU monitoring The number of samples to average for CPU monitoring.
<para></para></listitem>
</varlistentry>
<varlistentry>
<term><command><option>diskio_avg_samples</option></command></term>
<listitem>
The number of samples to average for disk I/O monitoring.
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>
@ -58,7 +65,7 @@
<varlistentry> <varlistentry>
<term><command><option>default_bar_size</option></command></term> <term><command><option>default_bar_size</option></command></term>
<listitem> <listitem>
Specify a default width and height for bars. Example: 'default_bar_size 0 6'. This is particularly useful for execbar and execibar as they do not take size arguments Specify a default width and height for bars. Example: 'default_bar_size 0 6'. This is particularly useful for execbar and execibar as they do not take size arguments.
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>

View File

@ -155,15 +155,15 @@ Aligned position on screen, may be top_left, top_right, top_middle, bottom_left,
.TP .TP
\fB\*(T<\fBbackground\fR\*(T>\fR \fB\*(T<\fBbackground\fR\*(T>\fR
Boolean value, if true, Conky will be forked to background when started Boolean value, if true, Conky will be forked to background when started.
.TP .TP
\fB\*(T<\fBborder_margin\fR\*(T>\fR \fB\*(T<\fBborder_margin\fR\*(T>\fR
Border margin in pixels Border margin in pixels.
.TP .TP
\fB\*(T<\fBborder_width\fR\*(T>\fR \fB\*(T<\fBborder_width\fR\*(T>\fR
Border width in pixels Border width in pixels.
.TP .TP
\fB\*(T<\fBcolorN\fR\*(T>\fR \fB\*(T<\fBcolorN\fR\*(T>\fR
@ -171,7 +171,11 @@ Predefine a color for use inside TEXT segments. Substitute N by a digit between
.TP .TP
\fB\*(T<\fBcpu_avg_samples\fR\*(T>\fR \fB\*(T<\fBcpu_avg_samples\fR\*(T>\fR
The number of samples to average for CPU monitoring The number of samples to average for CPU monitoring.
.TP
\fB\*(T<\fBdiskio_avg_samples\fR\*(T>\fR
The number of samples to average for disk I/O monitoring.
.TP .TP
\fB\*(T<\fBtop_cpu_separate\fR\*(T>\fR \fB\*(T<\fBtop_cpu_separate\fR\*(T>\fR
@ -179,7 +183,7 @@ If true, cpu in top will show usage of one processor's power. If false, cpu in t
.TP .TP
\fB\*(T<\fBdefault_bar_size\fR\*(T>\fR \fB\*(T<\fBdefault_bar_size\fR\*(T>\fR
Specify a default width and height for bars. Example: 'default_bar_size 0 6'. This is particularly useful for execbar and execibar as they do not take size arguments Specify a default width and height for bars. Example: 'default_bar_size 0 6'. This is particularly useful for execbar and execibar as they do not take size arguments.
.TP .TP
\fB\*(T<\fBdefault_graph_size\fR\*(T>\fR \fB\*(T<\fBdefault_graph_size\fR\*(T>\fR

View File

@ -262,7 +262,7 @@ static unsigned long total_run_times;
/* fork? */ /* fork? */
static int fork_to_background; static int fork_to_background;
static int cpu_avg_samples, net_avg_samples; static int cpu_avg_samples, net_avg_samples, diskio_avg_samples;
/* filenames for output */ /* filenames for output */
char *overwrite_file = NULL; FILE *overwrite_fpointer = NULL; char *overwrite_file = NULL; FILE *overwrite_fpointer = NULL;
@ -6534,6 +6534,7 @@ static void set_default_configurations(void)
total_run_times = 0; total_run_times = 0;
info.cpu_avg_samples = 2; info.cpu_avg_samples = 2;
info.net_avg_samples = 2; info.net_avg_samples = 2;
info.diskio_avg_samples = 2;
info.memmax = 0; info.memmax = 0;
top_cpu = 0; top_cpu = 0;
cpu_separate = 0; cpu_separate = 0;
@ -6934,6 +6935,18 @@ static void load_config_file(const char *f)
CONF_ERR; CONF_ERR;
} }
} }
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;
}
}
#ifdef HAVE_XDBE #ifdef HAVE_XDBE
CONF("double_buffer") { CONF("double_buffer") {

View File

@ -229,6 +229,8 @@ struct information {
unsigned int net_avg_samples; unsigned int net_avg_samples;
unsigned int diskio_avg_samples;
float loadavg[3]; float loadavg[3];
struct mail_s *mail; struct mail_s *mail;

View File

@ -52,6 +52,9 @@
* also containing the totals. */ * also containing the totals. */
static struct diskio_stat stats = { static struct diskio_stat stats = {
.next = NULL, .next = NULL,
.sample = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
.sample_read = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
.sample_write = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
.current = 0, .current = 0,
.current_read = 0, .current_read = 0,
.current_write = 0, .current_write = 0,
@ -98,19 +101,40 @@ struct diskio_stat *prepare_diskio_stat(const char *s)
static void update_diskio_values(struct diskio_stat *ds, static void update_diskio_values(struct diskio_stat *ds,
unsigned int reads, unsigned int writes) unsigned int reads, unsigned int writes)
{ {
int i;
double sum=0, sum_r=0, sum_w=0;
if (reads < ds->last_read || writes < ds->last_write) { if (reads < ds->last_read || writes < ds->last_write) {
/* counter overflow or reset - rebase to sane values */ /* counter overflow or reset - rebase to sane values */
ds->last = 0; ds->last = reads+writes;
ds->last_read = 0; ds->last_read = reads;
ds->last_write = 0; ds->last_write = writes;
} }
/* since the values in /proc/diskstats are absolute, we have to substract /* since the values in /proc/diskstats are absolute, we have to substract
* our last reading. The numbers stand for "sectors read", and we therefore * our last reading. The numbers stand for "sectors read", and we therefore
* have to divide by two to get KB */ * have to divide by two to get KB */
ds->current_read = (reads - ds->last_read) / 2; ds->sample_read[0] = (reads - ds->last_read) / 2;
ds->current_write = (writes - ds->last_write) / 2; ds->sample_write[0] = (writes - ds->last_write) / 2;
ds->current = ds->current_read + ds->current_write; ds->sample[0] = ds->sample_read[0] + ds->sample_write[0];
/* compute averages */
for (i = 0; i < (signed) info.diskio_avg_samples; i++) {
sum += ds->sample[i];
sum_r += ds->sample_read[i];
sum_w += ds->sample_write[i];
}
ds->current = sum / (double) info.diskio_avg_samples;
ds->current_read = sum_r / (double) info.diskio_avg_samples;
ds->current_write = sum_w / (double) info.diskio_avg_samples;
/* shift sample history */
for (i = info.diskio_avg_samples-1; i > 0; i--) {
ds->sample[i] = ds->sample[i-1];
ds->sample_read[i] = ds->sample_read[i-1];
ds->sample_write[i] = ds->sample_write[i-1];
}
/* save last */
ds->last_read = reads; ds->last_read = reads;
ds->last_write = writes; ds->last_write = writes;
ds->last = ds->last_read + ds->last_write; ds->last = ds->last_read + ds->last_write;
@ -125,7 +149,7 @@ void update_diskio(void)
char buf[512], devbuf[64]; char buf[512], devbuf[64];
unsigned int major, minor; unsigned int major, minor;
unsigned int reads, writes; unsigned int reads, writes;
unsigned int total_reads, total_writes; unsigned int total_reads=0, total_writes=0;
int col_count = 0; int col_count = 0;
stats.current = 0; stats.current = 0;
@ -146,7 +170,7 @@ void update_diskio(void)
* *
* XXX: ignore devices which are part of a SW RAID (MD_MAJOR) */ * XXX: ignore devices which are part of a SW RAID (MD_MAJOR) */
if (col_count == 5 && major != LVM_BLK_MAJOR && major != NBD_MAJOR if (col_count == 5 && major != LVM_BLK_MAJOR && major != NBD_MAJOR
&& major != RAMDISK_MAJOR && major != LOOP_MAJOR) { && major != RAMDISK_MAJOR && major != LOOP_MAJOR && minor==0) {
total_reads += reads; total_reads += reads;
total_writes += writes; total_writes += writes;
} else { } else {

View File

@ -32,12 +32,15 @@
struct diskio_stat { struct diskio_stat {
struct diskio_stat *next; struct diskio_stat *next;
char *dev; char *dev;
unsigned int current; double sample[15];
unsigned int current_read; double sample_read[15];
unsigned int current_write; double sample_write[15];
unsigned int last; double current;
unsigned int last_read; double current_read;
unsigned int last_write; double current_write;
double last;
double last_read;
double last_write;
}; };
struct diskio_stat *prepare_diskio_stat(const char *s); struct diskio_stat *prepare_diskio_stat(const char *s);