The tiny daemon that creates the server graph(s) for mirror.csclub. Will add document...
[public/mirror.git] / rrdtool / mirror-rrd.c
1 #include "mirror-nl-glue.h"
2 #include <rrd.h>
3
4 int main(void) {
5         char *argv[3];
6         unsigned long packet_count;
7
8         switch(fork()) {
9                 case -1:
10                         return -1;
11                 case 0:
12                         break;
13                 default:
14                         _exit(0);
15         }       
16
17     mirror_stats_initialize();
18     argv[0] = malloc(1024);     
19     for (;;) {
20         packet_count = get_class_byte_count(&cogent_class);
21         snprintf(argv[0], 1024, "N:%lu", packet_count);
22         rrd_update_r("/var/rrdtool/cogent.rrd", NULL, 1, argv);
23         packet_count = get_class_byte_count(&orion_class);
24         snprintf(argv[0], 1024, "N:%lu", packet_count);
25         rrd_update_r("/var/rrdtool/orion.rrd", NULL, 1, argv);
26         packet_count = get_class_byte_count(&campus_class);
27         snprintf(argv[0], 1024, "N:%lu", packet_count);
28         rrd_update_r("/var/rrdtool/campus.rrd", NULL, 1, argv);
29         if (rrd_test_error()) {
30                 fprintf(stderr, "ERROR: %s\n", rrd_get_error());
31                 rrd_clear_error();
32         }
33         sleep(5);
34         mirror_stats_refresh();
35     }
36 }
37