* Please see COPYING for details
*
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.
*
if (!s)
return &stats;
-#if defined(__FreeBSD__)
- if (strncmp(s, "/dev/", 5) == 0) {
- // supplied a /dev/device arg, so cut off the /dev part
- strncpy(device_name, s + 5, text_buffer_size);
- } else
-#endif
strncpy(device_name, s, text_buffer_size);
snprintf(stat_name, text_buffer_size, "/dev/%s", device_name);
* 0: read + write
* 1: write
*/
-void print_diskio(struct text_object *obj, int dir, char *p, int p_max_size)
+static void print_diskio_dir(struct text_object *obj, int dir, char *p, int p_max_size)
{
struct diskio_stat *diskio = obj->data.opaque;
double val;
if (dir < 0)
val = diskio->current_read;
- if (dir == 0)
+ else if (dir == 0)
val = diskio->current;
else
val = diskio->current_write;
human_readable((val / update_interval) * 1024LL, p, p_max_size);
}
+void print_diskio(struct text_object *obj, char *p, int p_max_size)
+{
+ print_diskio_dir(obj, 0, p, p_max_size);
+}
+
+void print_diskio_read(struct text_object *obj, char *p, int p_max_size)
+{
+ print_diskio_dir(obj, -1, p, p_max_size);
+}
+
+void print_diskio_write(struct text_object *obj, char *p, int p_max_size)
+{
+ print_diskio_dir(obj, 1, p, p_max_size);
+}
+
#ifdef X11
void parse_diskiograph_arg(struct text_object *obj, const char *arg)
{
char *buf = 0;
- SIZE_DEFAULTS(graph);
- buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
- &obj->e, &obj->char_a, &obj->char_b);
+ buf = scan_graph(obj, arg, 0);
obj->data.opaque = prepare_diskio_stat(dev_name(buf));
if (buf)
free(buf);
}
-void print_diskiograph(struct text_object *obj, int dir, char *p)
+static void print_diskiograph_dir(struct text_object *obj, int dir, char *p, int p_max_size)
{
struct diskio_stat *diskio = obj->data.opaque;
double val;
if (!diskio)
return;
+ if (!p_max_size)
+ return;
+
if (dir < 0)
val = diskio->current_read;
else if (dir == 0)
else
val = diskio->current_write;
- new_graph(p, obj->a, obj->b, obj->c, obj->d,
- val, obj->e, 1, obj->char_a, obj->char_b);
+ new_graph(obj, p, p_max_size, val);
+}
+
+void print_diskiograph(struct text_object *obj, char *p, int p_max_size)
+{
+ print_diskiograph_dir(obj, 0, p, p_max_size);
+}
+
+void print_diskiograph_read(struct text_object *obj, char *p, int p_max_size)
+{
+ print_diskiograph_dir(obj, -1, p, p_max_size);
+}
+
+void print_diskiograph_write(struct text_object *obj, char *p, int p_max_size)
+{
+ print_diskiograph_dir(obj, 1, p, p_max_size);
}
#endif /* X11 */
ds->last_read = reads;
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 subtract
* our last reading. The numbers stand for "sectors read", and we therefore
* have to divide by two to get KB */
ds->sample_read[0] = (reads - ds->last_read) / 2;