tload: Report on lack of /proc/loadavg
Now that the library correctly returns an error if loadavg
is not available, tload can tell the user the bad news.
References:
procps-ng/procps#227
commit 8fcd14de18
Signed-off-by: Craig Small <csmall@dropbear.xyz>
This commit is contained in:
parent
8fcd14de18
commit
3111334ddd
11
tload.c
11
tload.c
@ -170,11 +170,20 @@ int main(int argc, char **argv)
|
||||
alrm(0);
|
||||
|
||||
while (1) {
|
||||
int rc;
|
||||
|
||||
if (scale_fact < max_scale)
|
||||
scale_fact *= 2.0; /* help it drift back up. */
|
||||
|
||||
procps_loadavg(&av[0], &av[1], &av[2]);
|
||||
if ((rc = procps_loadavg(&av[0], &av[1], &av[2])) < 0)
|
||||
{
|
||||
if (rc == -ENOENT)
|
||||
xerrx(EXIT_FAILURE,
|
||||
_("Load average file /proc/loadavg does not exist"));
|
||||
else
|
||||
xerrx(EXIT_FAILURE,
|
||||
_("Unable to get load average"));
|
||||
}
|
||||
|
||||
do {
|
||||
lines = av[0] * scale_fact;
|
||||
|
Loading…
Reference in New Issue
Block a user