]> git.itanic.dy.fi Git - rrdd/commitdiff
Merge scheduler.c into rrdtool.c
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Tue, 17 Jul 2012 11:26:22 +0000 (14:26 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Tue, 17 Jul 2012 11:38:41 +0000 (14:38 +0300)
The schedule calculations were all very much dependent on the rrdtool
code and not something independent. It doesn't make sense to keep it
separate from the rrdtool code.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Makefile
database.h
main.c
rrdtool.c
rrdtool.h
scheduler.c [deleted file]
scheduler.h [deleted file]

index edfeea460730fca3ee9587d4394111a7f1288b44..0681fd77ae852a90c8c97f21b3aabd78c95d2aa1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CC=gcc
 LD=ld
 CFLAGS=-Wall -O2 -g
 
-RRDD_OBJS= main.o process.o rrdtool.o parser.o scheduler.o string.o \
+RRDD_OBJS= main.o process.o rrdtool.o parser.o string.o \
                debug.o config.o onewire_parser.o
 
 ALL_OBJS = $(RRDD_OBJS)
index 2877c882f6d91a6745aea0803979103f0fca62fd..76946fee322dceadd597a375877a2846420a10c9 100644 (file)
@@ -2,7 +2,6 @@
 #define _TESTDATA_H
 
 #include "rrdtool.h"
-#include "scheduler.h"
 #include "parser.h"
 
 const char blank[] = "COMMENT:       ";
diff --git a/main.c b/main.c
index 88a6a82be27d3820f68d40a66223441bfe991ca3..76588c94db9e72a6674180c5842fd4b75f91dc32 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,11 +1,11 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <getopt.h>
+#include <time.h>
 
 #include "process.h"
 #include "rrdtool.h"
 #include "parser.h"
-#include "scheduler.h"
 #include "debug.h"
 
 #include "database.h"
index 76540b8f0c2843fabef3f5c47bcad2563b3f1c20..b69b2fbeeee12733db2697c782730451aca85295 100644 (file)
--- a/rrdtool.c
+++ b/rrdtool.c
@@ -232,6 +232,50 @@ int rrdtool_update_data(struct rrd_database *rrd)
        exit(0);
 }
 
+/*
+ * Walk through the database list and return the first database which
+ * last update is too far in past
+ */
+struct rrd_database *get_outdated_db(struct rrd_database **dblist)
+{
+       int i;
+       time_t now = time(0);
+
+       for (i = 0; dblist[i]; i++) {
+               if ((dblist[i]->last_update + dblist[i]->interval) - now <= 0)
+                       return dblist[i];
+       }
+
+       /* Nothing to update this time, return null */
+       return NULL;
+}
+
+/*
+ * See how long we may sleep until it is required to run an update
+ * again
+ */
+int get_next_update(struct rrd_database **dblist, const char **name)
+{
+       int i, sleeptime = 0, diff;
+       time_t now = time(0);
+
+       for (i = 0; dblist[i]; i++) {
+               diff = dblist[i]->last_update + dblist[i]->interval - now;
+               if (!sleeptime) {
+                       sleeptime = diff;
+                       *name = dblist[i]->name;
+               }
+               if (sleeptime > diff) {
+                       sleeptime = diff;
+                       *name = dblist[i]->name;
+               }
+               if (sleeptime <= 0)
+                       return 0;
+       }
+
+       return sleeptime;
+}
+
 static int database_exists(struct rrd_database *db)
 {
        struct stat s;
index 9dda9b3621023ba90639c9c6d85c14ff30356408..b57a276855be8beff4386c7c254a1b79ed9ccf54 100644 (file)
--- a/rrdtool.h
+++ b/rrdtool.h
@@ -51,7 +51,8 @@ struct rrd_database {
 int rrdtool_draw_image(struct rrd_image *image);
 int rrdtool_draw_images(struct rrd_image **image);
 int rrdtool_update_data(struct rrd_database *rrd);
+struct rrd_database *get_outdated_db(struct rrd_database **dblist);
+int get_next_update(struct rrd_database **dblist, const char **name);
 int rrdtool_create_missing_databases(struct rrd_database *dbs[]);
 
-
 #endif
diff --git a/scheduler.c b/scheduler.c
deleted file mode 100644 (file)
index 44378c0..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "scheduler.h"
-#include "process.h"
-
-/*
- * Walk through the database list and return the first database which
- * last update is too far in past
- */
-struct rrd_database *get_outdated_db(struct rrd_database **dblist)
-{
-       int i;
-       time_t now = time(0);
-
-       for (i = 0; dblist[i]; i++) {
-               if ((dblist[i]->last_update + dblist[i]->interval) - now <= 0)
-                       return dblist[i];
-       }
-
-       /* Nothing to update this time, return null */
-       return NULL;
-}
-
-/*
- * See how long we may sleep until it is required to run an update
- * again
- */
-
-int get_next_update(struct rrd_database **dblist, const char **name)
-{
-       int i, sleeptime = 0, diff;
-       time_t now = time(0);
-
-       for (i = 0; dblist[i]; i++) {
-               diff = dblist[i]->last_update + dblist[i]->interval - now;
-               if (!sleeptime) {
-                       sleeptime = diff;
-                       *name = dblist[i]->name;
-               }
-               if (sleeptime > diff) {
-                       sleeptime = diff;
-                       *name = dblist[i]->name;
-               }
-               if (sleeptime <= 0)
-                       return 0;
-       }
-
-       return sleeptime;
-}
diff --git a/scheduler.h b/scheduler.h
deleted file mode 100644 (file)
index 5932df9..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _SCHEDULER_H
-#define _SCHEDULER_H
-
-#include <time.h>
-
-#include "rrdtool.h"
-
-struct rrd_database *get_outdated_db(struct rrd_database **dblist);
-int get_next_update(struct rrd_database **dblist, const char **name);
-
-#endif