summaryrefslogtreecommitdiff
path: root/src/status.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/status.c')
-rw-r--r--src/status.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/src/status.c b/src/status.c
index f7148f9..3422887 100644
--- a/src/status.c
+++ b/src/status.c
@@ -20,29 +20,33 @@
int status_init(struct status* s) {
int status = 0;
- s->memtotal = 0;
- s->memusedmax = 0;
- s->memusedavg = 0;
- s->loadavg = 0;
- s->loadmax = 0;
- s->nettx = 0;
- s->netrx = 0;
- s->count = 0;
- s->uptime = 0;
+ s->memtotal = 0;
+ s->memusedmax = 0;
+ s->memusedavg = 0;
+ s->loadavg = 0;
+ s->loadmax = 0;
+ s->nettx = 0;
+ s->netrx = 0;
+ s->diskreadkb = 0;
+ s->diskwritekb = 0;
+ s->count = 0;
+ s->uptime = 0;
FILE* fd = fopen("/tmp/cmon.status", "r");
if(fd) {
- status += fscanf(fd, "memtotal:%ld\n", &s->memtotal);
- status += fscanf(fd, "memusedmax:%ld\n", &s->memusedmax);
- status += fscanf(fd, "memusedavg:%ld\n", &s->memusedavg);
- status += fscanf(fd, "loadmax:%lf\n", &s->loadmax);
- status += fscanf(fd, "loadavg:%lf\n", &s->loadavg);
- status += fscanf(fd, "nprocs:%d\n", &s->nprocs);
- status += fscanf(fd, "nettx:%lld\n", &s->nettx);
- status += fscanf(fd, "netrx:%lld\n", &s->netrx);
- status += fscanf(fd, "uptime:%ld\n", &s->uptime);
- status += fscanf(fd, "count:%ld\n", &s->count);
- if(status != 10) {
+ status += fscanf(fd, "memtotal:%ld\n", &s->memtotal);
+ status += fscanf(fd, "memusedmax:%ld\n", &s->memusedmax);
+ status += fscanf(fd, "memusedavg:%ld\n", &s->memusedavg);
+ status += fscanf(fd, "loadmax:%lf\n", &s->loadmax);
+ status += fscanf(fd, "loadavg:%lf\n", &s->loadavg);
+ status += fscanf(fd, "nprocs:%d\n", &s->nprocs);
+ status += fscanf(fd, "diskreadkb:%lld\n", &s->diskreadkb);
+ status += fscanf(fd, "diskwritekb:%lld\n", &s->diskwritekb);
+ status += fscanf(fd, "nettx:%lld\n", &s->nettx);
+ status += fscanf(fd, "netrx:%lld\n", &s->netrx);
+ status += fscanf(fd, "uptime:%ld\n", &s->uptime);
+ status += fscanf(fd, "count:%ld\n", &s->count);
+ if(status != 12) {
fprintf(stderr, "ERROR reading status file\n");
return 0;
}
@@ -54,16 +58,18 @@ int status_init(struct status* s) {
int status_write(struct status* s) {
FILE* fd = fopen("/tmp/cmon.status", "w");
- fprintf(fd, "memtotal:%ld\n", s->memtotal);
- fprintf(fd, "memusedmax:%ld\n", s->memusedmax);
- fprintf(fd, "memusedavg:%ld\n", s->memusedavg);
- fprintf(fd, "loadmax:%lf\n", s->loadmax);
- fprintf(fd, "loadavg:%lf\n", s->loadavg);
- fprintf(fd, "nprocs:%d\n", s->nprocs);
- fprintf(fd, "nettx:%lld\n", s->nettx);
- fprintf(fd, "netrx:%lld\n", s->netrx);
- fprintf(fd, "uptime:%ld\n", s->uptime);
- fprintf(fd, "count:%ld\n", s->count);
+ fprintf(fd, "memtotal:%ld\n", s->memtotal);
+ fprintf(fd, "memusedmax:%ld\n", s->memusedmax);
+ fprintf(fd, "memusedavg:%ld\n", s->memusedavg);
+ fprintf(fd, "loadmax:%lf\n", s->loadmax);
+ fprintf(fd, "loadavg:%lf\n", s->loadavg);
+ fprintf(fd, "nprocs:%d\n", s->nprocs);
+ fprintf(fd, "diskreadkb:%lld\n", s->diskreadkb);
+ fprintf(fd, "diskwritekb:%lld\n", s->diskwritekb);
+ fprintf(fd, "nettx:%lld\n", s->nettx);
+ fprintf(fd, "netrx:%lld\n", s->netrx);
+ fprintf(fd, "uptime:%ld\n", s->uptime);
+ fprintf(fd, "count:%ld\n", s->count);
fclose(fd);
return 1;

Generated by cgit