mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-23 19:39:06 +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:
parent
d2ed065fdd
commit
bcbca8cb5b
@ -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>
|
||||
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
|
||||
\fB\*(T<\fBkernel\fR\*(T>\fR
|
||||
Kernel version
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBlaptop_mode\fR\*(T>\fR
|
||||
value of /proc/sys/vm/laptop_mode
|
||||
The value of /proc/sys/vm/laptop_mode
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBloadavg\fR\*(T>\fR
|
||||
|
@ -1168,6 +1168,16 @@
|
||||
<para></para></listitem>
|
||||
</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>
|
||||
<term>
|
||||
<command><option>kernel</option></command>
|
||||
@ -1182,7 +1192,7 @@
|
||||
<command><option>laptop_mode</option></command>
|
||||
</term>
|
||||
<listitem>
|
||||
value of /proc/sys/vm/laptop_mode
|
||||
The value of /proc/sys/vm/laptop_mode
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
14
src/conky.c
14
src/conky.c
@ -1145,6 +1145,7 @@ enum text_object_type {
|
||||
OBJ_ibm_brightness,
|
||||
OBJ_if_up,
|
||||
OBJ_if_gw,
|
||||
OBJ_ioscheduler,
|
||||
OBJ_gw_iface,
|
||||
OBJ_gw_ip,
|
||||
OBJ_laptop_mode,
|
||||
@ -2065,6 +2066,10 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
|
||||
info.gw_info.ip = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_ioscheduler:
|
||||
if(objs[i].data.s)
|
||||
free(objs[i].data.s);
|
||||
break;
|
||||
#endif
|
||||
#ifdef XMMS2
|
||||
case OBJ_xmms2_artist:
|
||||
@ -2477,6 +2482,12 @@ static struct text_object *construct_text_object(const char *s,
|
||||
blockstart[blockdepth] = object_count;
|
||||
obj->data.ifblock.pos = object_count + 2;
|
||||
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(pb_battery, 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;
|
||||
}
|
||||
}
|
||||
OBJ(ioscheduler) {
|
||||
snprintf(p, p_max_size, "%s", get_ioscheduler(obj->data.s));
|
||||
}
|
||||
OBJ(kernel) {
|
||||
snprintf(p, p_max_size, "%s", cur->uname_s.release);
|
||||
}
|
||||
|
@ -544,6 +544,7 @@ void get_freq_dynamic(char *, size_t, char *, int);
|
||||
char get_voltage(char *, size_t, char *, int, unsigned int); /* ptarjan */
|
||||
void update_load_average();
|
||||
int interface_up(const char *dev);
|
||||
char *get_ioscheduler(char *);
|
||||
int get_laptop_mode(void);
|
||||
void update_gateway_info(void);
|
||||
|
||||
|
28
src/linux.c
28
src/linux.c
@ -178,6 +178,34 @@ int get_laptop_mode()
|
||||
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 fd;
|
||||
|
Loading…
Reference in New Issue
Block a user