1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 18:45:10 +00:00

enable displaying the used ioscheduler for a given disk

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1034 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Phil 2008-03-22 21:10:43 +00:00
parent d2ed065fdd
commit bcbca8cb5b
5 changed files with 59 additions and 2 deletions

View File

@ -893,13 +893,17 @@ Displays the number of messages in your global IMAP inbox by default. You can de
\fB\*(T<\fBimap_unseen\fR\*(T>\fR \*(T<\fB(args)\fR\*(T> \fB\*(T<\fBimap_unseen\fR\*(T>\fR \*(T<\fB(args)\fR\*(T>
Displays the number of unseen messages in your global IMAP inbox by default. You can define individual IMAP inboxes seperately by passing arguments to this object. Arguments are: "host user pass [-i interval] [-p port] [-e command]". Default port is 143, default interval is 5 minutes. If the password is supplied as '*', you will be prompted to enter the password when Conky starts. Displays the number of unseen messages in your global IMAP inbox by default. You can define individual IMAP inboxes seperately by passing arguments to this object. Arguments are: "host user pass [-i interval] [-p port] [-e command]". Default port is 143, default interval is 5 minutes. If the password is supplied as '*', you will be prompted to enter the password when Conky starts.
.TP
\fB\*(T<\fBioscheduler\fR\*(T>\fR \*(T<\fB(disk)\fR\*(T>
Prints the current ioscheduler used for the given disk name (i.e. e.g. "hda" or "sdb")
.TP .TP
\fB\*(T<\fBkernel\fR\*(T>\fR \fB\*(T<\fBkernel\fR\*(T>\fR
Kernel version Kernel version
.TP .TP
\fB\*(T<\fBlaptop_mode\fR\*(T>\fR \fB\*(T<\fBlaptop_mode\fR\*(T>\fR
value of /proc/sys/vm/laptop_mode The value of /proc/sys/vm/laptop_mode
.TP .TP
\fB\*(T<\fBloadavg\fR\*(T>\fR \fB\*(T<\fBloadavg\fR\*(T>\fR

View File

@ -1168,6 +1168,16 @@
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command><option>ioscheduler</option></command>
</term>
<option>(disk)</option>
<listitem>
Prints the current ioscheduler used for the given disk name (i.e. e.g. "hda" or "sdb")
<para></para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command><option>kernel</option></command> <command><option>kernel</option></command>
@ -1182,7 +1192,7 @@
<command><option>laptop_mode</option></command> <command><option>laptop_mode</option></command>
</term> </term>
<listitem> <listitem>
value of /proc/sys/vm/laptop_mode The value of /proc/sys/vm/laptop_mode
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>

View File

@ -1145,6 +1145,7 @@ enum text_object_type {
OBJ_ibm_brightness, OBJ_ibm_brightness,
OBJ_if_up, OBJ_if_up,
OBJ_if_gw, OBJ_if_gw,
OBJ_ioscheduler,
OBJ_gw_iface, OBJ_gw_iface,
OBJ_gw_ip, OBJ_gw_ip,
OBJ_laptop_mode, OBJ_laptop_mode,
@ -2065,6 +2066,10 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
info.gw_info.ip = 0; info.gw_info.ip = 0;
} }
break; break;
case OBJ_ioscheduler:
if(objs[i].data.s)
free(objs[i].data.s);
break;
#endif #endif
#ifdef XMMS2 #ifdef XMMS2
case OBJ_xmms2_artist: case OBJ_xmms2_artist:
@ -2477,6 +2482,12 @@ static struct text_object *construct_text_object(const char *s,
blockstart[blockdepth] = object_count; blockstart[blockdepth] = object_count;
obj->data.ifblock.pos = object_count + 2; obj->data.ifblock.pos = object_count + 2;
blockdepth++; blockdepth++;
END OBJ(ioscheduler, 0)
if (!arg) {
CRIT_ERR("get_ioscheduler needs an argument (e.g. hda)");
obj->data.s = 0;
} else
obj->data.s = strdup(arg);
END OBJ(laptop_mode, 0) END OBJ(laptop_mode, 0)
END OBJ(pb_battery, 0) END OBJ(pb_battery, 0)
if (arg && strcmp(arg, "status") == 0) { if (arg && strcmp(arg, "status") == 0) {
@ -5309,6 +5320,9 @@ static void generate_text_internal(char *p, int p_max_size,
if_jumped = 0; if_jumped = 0;
} }
} }
OBJ(ioscheduler) {
snprintf(p, p_max_size, "%s", get_ioscheduler(obj->data.s));
}
OBJ(kernel) { OBJ(kernel) {
snprintf(p, p_max_size, "%s", cur->uname_s.release); snprintf(p, p_max_size, "%s", cur->uname_s.release);
} }

View File

@ -544,6 +544,7 @@ void get_freq_dynamic(char *, size_t, char *, int);
char get_voltage(char *, size_t, char *, int, unsigned int); /* ptarjan */ char get_voltage(char *, size_t, char *, int, unsigned int); /* ptarjan */
void update_load_average(); void update_load_average();
int interface_up(const char *dev); int interface_up(const char *dev);
char *get_ioscheduler(char *);
int get_laptop_mode(void); int get_laptop_mode(void);
void update_gateway_info(void); void update_gateway_info(void);

View File

@ -178,6 +178,34 @@ int get_laptop_mode()
return val; return val;
} }
/* my system says:
* # cat /sys/block/sda/queue/scheduler
* noop [anticipatory] cfq
*/
char *get_ioscheduler(char *disk)
{
FILE *fp;
char buf[128];
if (!disk)
return "n/a";
snprintf(buf, 127, "/sys/block/%s/queue/scheduler", disk);
if ((fp = fopen(buf, "r")) == NULL) {
return strdup("n/a");
}
while (!feof(fp)) {
fscanf(fp, "%127s", buf);
if (buf[0] == '[') {
buf[strlen(buf) - 1] = '\0';
fclose(fp);
return strdup(buf + 1);
}
}
fclose(fp);
return strdup("n/a");
}
int interface_up(const char *dev) int interface_up(const char *dev)
{ {
int fd; int fd;