2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/tools/munin-plugins-busybox/uptime.c
Helmut Grohne bb7bf0bcd7 refactor code
Added common functions autoconf_check_readable and fail.
Added some TODOs for later completion.
Updated messages from upstream plugins.
2013-02-05 12:38:12 +01:00

31 lines
687 B
C

#include <stdio.h>
#include <string.h>
#include "common.h"
int uptime(int argc, char **argv) {
FILE *f;
float uptime;
if(argc > 1) {
if(!strcmp(argv[1], "config")) {
puts("graph_title Uptime\n"
"graph_args --base 1000 -l 0 \n"
"graph_vlabel uptime in days\n"
"uptime.label uptime\n"
"uptime.draw AREA");
print_warncrit("uptime");
return 0;
}
if(!strcmp(argv[1], "autoconf"))
return writeyes();
}
if(!(f=fopen("/proc/uptime", "r")))
return fail("cannot open /proc/uptime");
if(1 != fscanf(f, "%f", &uptime)) {
fclose(f);
return fail("cannot read from /proc/uptime");
}
fclose(f);
printf("uptime.value %.2f\n", uptime/86400);
return 0;
}