]> git.itanic.dy.fi Git - rrdd/commitdiff
scheduler: Give the name of the next db to be updated
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Thu, 28 Jun 2012 07:55:41 +0000 (10:55 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Thu, 28 Jun 2012 07:55:41 +0000 (10:55 +0300)
This is somewhat useful in debugging as the user will be able to know
which database will be updated next, so he can anticipate what kind of
output there is to be expected soon.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
main.c
scheduler.c
scheduler.h

diff --git a/main.c b/main.c
index afbb16269fa7beb8a26342d91183f6279ca60ced..88a6a82be27d3820f68d40a66223441bfe991ca3 100644 (file)
--- a/main.c
+++ b/main.c
@@ -88,6 +88,7 @@ int main(int argc, char *argv[])
                return -1;
 
        while (1) {
+               const char *db_name;
                char timestr[128];
                time_t t;
 
@@ -98,12 +99,12 @@ int main(int argc, char *argv[])
                while ((db = get_outdated_db(db_list)))
                        rrdtool_update_data(db);
 
-               sleeptime = get_next_update(db_list);
+               sleeptime = get_next_update(db_list, &db_name);
 
                t = time(0) + sleeptime;
                strftime(timestr, sizeof(timestr), "%T", localtime(&t));
-               pr_info("Next event at %s, in %d seconds\n",
-                       timestr, sleeptime);
+               pr_info("Next scheduled event \"%s\" at %s, in %d seconds\n",
+                       db_name, timestr, sleeptime);
 
                poll_job_requests(sleeptime);
        }
index 829e1f4fce2231069fac6e8b0d7b89331b0238e8..44378c0edcf6352d2df3c1039e4ee95646485eb1 100644 (file)
@@ -24,17 +24,21 @@ struct rrd_database *get_outdated_db(struct rrd_database **dblist)
  * again
  */
 
-int get_next_update(struct rrd_database **dblist)
+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)
+               if (!sleeptime) {
                        sleeptime = diff;
-               if (sleeptime > diff)
+                       *name = dblist[i]->name;
+               }
+               if (sleeptime > diff) {
                        sleeptime = diff;
+                       *name = dblist[i]->name;
+               }
                if (sleeptime <= 0)
                        return 0;
        }
index 6c1bf541e135f52b8f70835b0b16e722b82ccf01..5932df93da60b3d8a9a602818ffcd34dbb0f286d 100644 (file)
@@ -6,6 +6,6 @@
 #include "rrdtool.h"
 
 struct rrd_database *get_outdated_db(struct rrd_database **dblist);
-int get_next_update(struct rrd_database **dblist);
+int get_next_update(struct rrd_database **dblist, const char **name);
 
 #endif