]> git.itanic.dy.fi Git - rrdd/commitdiff
Collect all rrdtool handling in one file
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 6 Mar 2011 16:31:00 +0000 (18:31 +0200)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 6 Mar 2011 17:06:05 +0000 (19:06 +0200)
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
Makefile
main.c
rrdtool.c [moved from draw_graphs.c with 65% similarity]
rrdtool.h [moved from draw_graphs.h with 76% similarity]
scheduler.c
scheduler.h

index aeae43cd7c5533a513f62010a125858ad80cbd7a..27daa3e157e2ddbfd08443a2b39253a8b3395604 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CC=gcc
 LD=ld
 CFLAGS=-Wall -O2 -g
 
-RRDD_OBJS= main.o process.o draw_graphs.o parser.o scheduler.o string.o \
+RRDD_OBJS= main.o process.o rrdtool.o parser.o scheduler.o string.o \
                debug.o
 
 ALL_OBJS = $(RRDD_OBJS)
diff --git a/main.c b/main.c
index c91ac60d130bfd50e6ad7af44840a7a15b3f8359..345f93a0ef4dacb58ed7229bdad65169ebbfb0fb 100644 (file)
--- a/main.c
+++ b/main.c
@@ -2,7 +2,7 @@
 #include <unistd.h>
 
 #include "process.h"
-#include "draw_graphs.h"
+#include "rrdtool.h"
 #include "parser.h"
 #include "scheduler.h"
 #include "debug.h"
@@ -22,7 +22,7 @@ int main(int argc, char *argv[])
                 */
                while ((db = check_update_need((struct rrd_database **)
                                               &all_rrds)))
-                       update_data(db);
+                       rrdtool_update_data(db);
 
                /*
                 * Let the updates finish
similarity index 65%
rename from draw_graphs.c
rename to rrdtool.c
index fba8ded479b0c86da59b8734b4f9436299cbfad7..0aff0294364f840f6532705bf15425df91f12b17 100644 (file)
+++ b/rrdtool.c
@@ -1,6 +1,6 @@
 #include <time.h>
 
-#include "draw_graphs.h"
+#include "rrdtool.h"
 #include "process.h"
 
 #define MAX_ARGS       512
@@ -12,7 +12,7 @@
        argcnt++;                                       \
        argstr[++idx] = 0
 
-int draw_image(struct rrd_image *image)
+int rrdtool_draw_image(struct rrd_image *image)
 {
        char cmd[] = "/usr/bin/rrdtool";
 //     char cmd[] = "echo";
@@ -36,7 +36,7 @@ int draw_image(struct rrd_image *image)
 
        print(" ");
        print("graph");
-       print(image->image_filename);
+       print("%s", image->image_filename);
 
        print("--start");
        print("%s", image->timestart);
@@ -66,11 +66,43 @@ int draw_image(struct rrd_image *image)
        return 0;
 }
 
-int draw_images(struct rrd_image **image)
+int rrdtool_draw_images(struct rrd_image **image)
 {
        int i;
        for (i = 0; image[i]; i++)
-               draw_image(image[i]);
+               rrdtool_draw_image(image[i]);
 
        return 0;
 }
+
+int rrdtool_update_data(struct rrd_database *rrd)
+{
+       char data[1024];
+       char cmd[] = "/usr/bin/rrdtool";
+//     char cmd[] = "echo";
+       char *cmdline[] = {
+               "",
+               "update",
+               rrd->filename,
+               data,
+               0
+       };
+       int l;
+
+       rrd->last_update = time(0);
+       if (do_fork())
+               return 0;
+
+       l = sprintf(data, "N:");
+
+       if (rrd->parse) {
+               rrd->parse(data + l);
+               run(cmd, cmdline);
+       }
+
+       if (rrd->images)
+               rrdtool_draw_images(rrd->images);
+
+       while (harvest_zombies(0));
+       exit(0);
+}
similarity index 76%
rename from draw_graphs.h
rename to rrdtool.h
index 783305a5664bf9dc6ab2d5b69efb820aa135cc96..a045db4db5e426a10d696225ae385f6474f57155 100644 (file)
+++ b/rrdtool.h
@@ -16,7 +16,8 @@ struct rrd_image {
        char    **text;         /* Null terminated list of text lines */
 };
 
-int draw_image(struct rrd_image *image);
-int draw_images(struct rrd_image **image);
+int rrdtool_draw_image(struct rrd_image *image);
+int rrdtool_draw_images(struct rrd_image **image);
+int rrdtool_update_data(struct rrd_database *rrd);
 
 #endif
index 5029fca9e281b75a2e956124f25532d309be110f..1c32b52dd4232e43859caa4a49cb0381b1bb01ef 100644 (file)
@@ -1,38 +1,6 @@
 #include "scheduler.h"
 #include "process.h"
 
-int update_data(struct rrd_database *rrd)
-{
-       char data[1024];
-       char cmd[] = "/usr/bin/rrdtool";
-//     char cmd[] = "echo";
-       char *cmdline[] = {
-               "",
-               "update",
-               rrd->filename,
-               data,
-               0
-       };
-       int l;
-
-       rrd->last_update = time(0);
-       if (do_fork())
-               return 0;
-
-       l = sprintf(data, "N:");
-
-       if (rrd->parse) {
-               rrd->parse(data + l);
-               run(cmd, cmdline);
-       }
-
-       if (rrd->images)
-               draw_images(rrd->images);
-
-       while (harvest_zombies(0));
-       exit(0);
-}
-
 /*
  * Walk through the database list and return the first database which
  * last update is too far in past
index a23f848536d1f232195e2657b9ba24386a1a1189..92ec2d2048f63c77ac70d381547a43f3274cdec9 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <time.h>
 
-#include "draw_graphs.h"
+#include "rrdtool.h"
 
 struct rrd_database {
        char    *filename;      /* rrd database location */
@@ -14,7 +14,6 @@ struct rrd_database {
        char    *name;          /* Name of the database */
 };
 
-int update_data(struct rrd_database *rrd);
 struct rrd_database *check_update_need(struct rrd_database **dblist);
 int get_next_update(struct rrd_database **dblist);