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)
#include <unistd.h>
#include "process.h"
-#include "draw_graphs.h"
+#include "rrdtool.h"
#include "parser.h"
#include "scheduler.h"
#include "debug.h"
*/
while ((db = check_update_need((struct rrd_database **)
&all_rrds)))
- update_data(db);
+ rrdtool_update_data(db);
/*
* Let the updates finish
#include <time.h>
-#include "draw_graphs.h"
+#include "rrdtool.h"
#include "process.h"
#define MAX_ARGS 512
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";
print(" ");
print("graph");
- print(image->image_filename);
+ print("%s", image->image_filename);
print("--start");
print("%s", image->timestart);
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);
+}
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
#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
#include <time.h>
-#include "draw_graphs.h"
+#include "rrdtool.h"
struct rrd_database {
char *filename; /* rrd database location */
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);