1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-24 11:55:43 +00:00

disk_protect - show queue protection state

* disk protection needs a kernel patch and is useful in combination with hdaps


git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1045 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Phil 2008-03-24 20:08:16 +00:00
parent d6953f4864
commit 004d1cb7ba
5 changed files with 47 additions and 0 deletions

View File

@ -643,6 +643,10 @@ Displays current disk IO for writes. Device as in diskio.
\fB\*(T<\fBdiskiograph_write\fR\*(T>\fR \*(T<\fB(device) (height),(width) (gradient colour 1) (gradient colour 2) (scale)\fR\*(T>
Disk IO graph for writes, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph. Device as in diskio.
.TP
\fB\*(T<\fBdisk_protect\fR\*(T>\fR \*(T<\fBdevice\fR\*(T>
Disk protection status, if supported (needs kernel-patch). Prints either "frozen" or "free " (note the padding).
.TP
\fB\*(T<\fBdownspeed\fR\*(T>\fR \*(T<\fBnet\fR\*(T>
Download speed in kilobytes

View File

@ -572,6 +572,17 @@
<varlistentry>
<term>
<command><option>disk_protect</option></command>
<option>device</option>
</term>
<listitem>
Disk protection status, if supported (needs kernel-patch). Prints either "frozen" or "free " (note the padding).
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>downspeed</option></command>
<option>net</option>
</term>

View File

@ -1128,6 +1128,7 @@ enum text_object_type {
OBJ_platform,
OBJ_hwmon,
#if defined(__linux__)
OBJ_disk_protect,
OBJ_i8k_version,
OBJ_i8k_bios,
OBJ_i8k_serial,
@ -2049,6 +2050,9 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
break;
#endif
#ifdef __LINUX__
case OBJ_disk_protect:
free(objs[i].data.s);
break;
case OBJ_if_up:
free(objs[i].data.ifblock.s);
free(objs[i].data.ifblock.str);
@ -2443,6 +2447,11 @@ static struct text_object *construct_text_object(const char *s,
#endif /* !__OpenBSD__ */
#if defined(__linux__)
END OBJ(disk_protect, 0)
if (arg)
obj->data.s = strdup(arg);
else
CRIT_ERR("disk_protect needs an argument");
END OBJ(i8k_version, INFO_I8K)
END OBJ(i8k_bios, INFO_I8K)
END OBJ(i8k_serial, INFO_I8K)
@ -4342,6 +4351,10 @@ static void generate_text_internal(char *p, int p_max_size,
snprintf(p, p_max_size, "%s", BUILD_ARCH);
}
#if defined(__linux__)
OBJ(disk_protect) {
snprintf(p, p_max_size, "%s",
get_disk_protect_queue(obj->data.s));
}
OBJ(i8k_version) {
snprintf(p, p_max_size, "%s", i8k.version);
}

View File

@ -584,6 +584,7 @@ void get_ibm_acpi_fan(char *buf, size_t client_buffer_size);
void get_ibm_acpi_temps(void);
void get_ibm_acpi_volume(char *buf, size_t client_buffer_size);
void get_ibm_acpi_brightness(char *buf, size_t client_buffer_size);
char *get_disk_protect_queue(char *disk);
void get_cpu_count();
struct ibm_acpi_struct {

View File

@ -2416,3 +2416,21 @@ void update_entropy(void)
info.mask |= (1 << INFO_ENTROPY);
}
char *get_disk_protect_queue(char *disk)
{
FILE *fp;
char path[128];
int state;
snprintf(path, 127, "/sys/block/%s/queue/protect", disk);
if ((fp = fopen(path, "r")) == NULL)
return "n/a ";
if (fscanf(fp, "%d\n", &state) != 1) {
fclose(fp);
return "failed";
}
fclose(fp);
return state ? "frozen" : "free ";
}