This takes arguments in the form:top (name) (number) Basically,
processes are ranked from highest to lowest in terms of cpu us-
age, which is what (num) represents. The types are: "name",
- "pid", "cpu", "mem", and "time". There can be a max of 10 pro-
- cesses listed.
+ "pid", "cpu", "mem", "mem_res", "mem_vsize", and "time". There
+ can be a max of 10 processes listed.
top_mem type, num
.TP
\fB\*(T<\fBtop\fR\*(T>\fR \*(T<\fBtype, num\fR\*(T>
-This takes arguments in the form:top (name) (number) Basically, processes are ranked from highest to lowest in terms of cpu usage, which is what (num) represents. The types are: "name", "pid", "cpu", "mem", and "time". There can be a max of 10 processes listed.
+This takes arguments in the form:top (name) (number) Basically, processes are ranked from highest to lowest in terms of cpu usage, which is what (num) represents. The types are: "name", "pid", "cpu", "mem", "mem_res", "mem_vsize", and "time". There can be a max of 10 processes listed.
.TP
\fB\*(T<\fBtop_mem\fR\*(T>\fR \*(T<\fBtype, num\fR\*(T>
#include "conky.h"
#include <limits.h>
+#include <stdio.h>
static struct diskio_stat diskio_stats_[MAX_DISKIO_STATS];
struct diskio_stat *diskio_stats = diskio_stats_;
{
struct diskio_stat *new = 0;
unsigned i;
+ FILE *fp;
+ int found = 0;
+ char device[text_buffer_size], fbuf[text_buffer_size];
+ static int rep = 0;
/* lookup existing or get new */
for (i = 0; i < MAX_DISKIO_STATS; i++) {
if (diskio_stats[i].dev) {
ERR("too many diskio stats");
return 0;
}
- new->dev = strdup(s);
+ if (strncmp(s, "/dev/", 5) == 0) {
+ // supplied a /dev/device arg, so cut off the /dev part
+ new->dev = strndup(s + 5, text_buffer_size);
+ } else {
+ new->dev = strndup(s, text_buffer_size);
+ }
+ /*
+ * check that device actually exists
+ */
+
+ if (!(fp = open_file("/proc/diskstats", &rep))) {
+ ERR("cannot read from /proc/diskstats");
+ return 0;
+ }
+
+ while (!feof(fp)) {
+ fgets(fbuf, text_buffer_size, fp);
+ if (sscanf(fbuf, "%*u %*u %255s %*u %*u %*u %*u %*u %*u %*u", device)) {
+ // check for device match
+ if (strncmp(new->dev, device, 256) == 0) {
+ found = 1;
+ break;
+ }
+ }
+ }
+ fclose(fp);
+ fp = 0;
+ if (!found) {
+ ERR("diskio device '%s' does not exist", s);
+ }
new->current = 0;
new->current_read = 0;
new ->current_write = 0;
free(string);
}
-void mpd_sendSeekCommand(mpd_Connection *connection, int song, int time)
+void mpd_sendSeekCommand(mpd_Connection *connection, int song, int seek_time)
{
int len = strlen("seek") + 2 + INTLEN + 3 + INTLEN + 3;
char *string = malloc(len);
- snprintf(string, len, "seek \"%i\" \"%i\"\n", song, time);
+ snprintf(string, len, "seek \"%i\" \"%i\"\n", song, seek_time);
mpd_sendInfoCommand(connection, string);
free(string);
}
-void mpd_sendSeekIdCommand(mpd_Connection *connection, int id, int time)
+void mpd_sendSeekIdCommand(mpd_Connection *connection, int id, int seek_time)
{
int len = strlen("seekid") + 2 + INTLEN + 3 + INTLEN + 3;
char *string = malloc(len);
- snprintf(string, len, "seekid \"%i\" \"%i\"\n", id, time);
+ snprintf(string, len, "seekid \"%i\" \"%i\"\n", id, seek_time);
mpd_sendInfoCommand(connection, string);
free(string);
}
void mpd_sendSwapIdCommand(mpd_Connection *connection, int song1, int song2);
-void mpd_sendSeekCommand(mpd_Connection *connection, int song, int time);
+void mpd_sendSeekCommand(mpd_Connection *connection, int song, int seek_time);
-void mpd_sendSeekIdCommand(mpd_Connection *connection, int song, int time);
+void mpd_sendSeekIdCommand(mpd_Connection *connection, int song, int seek_time);
void mpd_sendRepeatCommand(mpd_Connection *connection, int repeatMode);
}
for (i = 0; i < MAX_DISKIO_STATS; i++) {
if (diskio_stats[i].dev &&
- strcmp(devbuf, diskio_stats[i].dev) == 0) {
+ strncmp(devbuf, diskio_stats[i].dev, text_buffer_size) == 0) {
diskio_stats[i].current =
(reads + writes - diskio_stats[i].last) / 2;
diskio_stats[i].current_read =