load avg
This commit is contained in:
parent
1d43e2f2b2
commit
83c98554ed
4 changed files with 19 additions and 0 deletions
|
@ -17,6 +17,7 @@ The following information is included:
|
||||||
- available entropy
|
- available entropy
|
||||||
- hostname
|
- hostname
|
||||||
- ip addresses
|
- ip addresses
|
||||||
|
- load avg
|
||||||
- ram numbers (free ram, percentage, total ram and used ram)
|
- ram numbers (free ram, percentage, total ram and used ram)
|
||||||
- temperature
|
- temperature
|
||||||
- volume percentage (alsa)
|
- volume percentage (alsa)
|
||||||
|
|
|
@ -26,6 +26,7 @@ static const char unknowntext[] = "n/a";
|
||||||
- gid (gid of current user) [argument: NULL]
|
- gid (gid of current user) [argument: NULL]
|
||||||
- hostname [argument: NULL]
|
- hostname [argument: NULL]
|
||||||
- ip (ip address) [argument: interface]
|
- ip (ip address) [argument: interface]
|
||||||
|
- load_avg (load average) [argument: NULL]
|
||||||
- ram_free (ram usage in percent) [argument: NULL]
|
- ram_free (ram usage in percent) [argument: NULL]
|
||||||
- ram_perc (ram usage in percent) [argument: NULL]
|
- ram_perc (ram usage in percent) [argument: NULL]
|
||||||
- ram_total (ram usage in percent) [argument: NULL]
|
- ram_total (ram usage in percent) [argument: NULL]
|
||||||
|
|
16
slstatus.c
16
slstatus.c
|
@ -342,6 +342,22 @@ ip(const char *interface)
|
||||||
return smprintf(unknowntext);
|
return smprintf(unknowntext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* load avg */
|
||||||
|
char *
|
||||||
|
load_avg(const char *null)
|
||||||
|
{
|
||||||
|
double avgs[3];
|
||||||
|
|
||||||
|
/* try to get load avg */
|
||||||
|
if (getloadavg(avgs, 3) < 0) {
|
||||||
|
fprintf(stderr, "Error getting load avg.\n");
|
||||||
|
return smprintf(unknowntext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return it */
|
||||||
|
return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
|
||||||
|
}
|
||||||
|
|
||||||
/* ram free */
|
/* ram free */
|
||||||
char *
|
char *
|
||||||
ram_free(const char *null)
|
ram_free(const char *null)
|
||||||
|
|
|
@ -25,6 +25,7 @@ char *entropy(const char*);
|
||||||
char *gid(const char*);
|
char *gid(const char*);
|
||||||
char *hostname(const char *);
|
char *hostname(const char *);
|
||||||
char *ip(const char *);
|
char *ip(const char *);
|
||||||
|
char *load_avg(const char *);
|
||||||
char *ram_free(const char *);
|
char *ram_free(const char *);
|
||||||
char *ram_perc(const char *);
|
char *ram_perc(const char *);
|
||||||
char *ram_used(const char *);
|
char *ram_used(const char *);
|
||||||
|
|
Loading…
Reference in a new issue