]> git.itanic.dy.fi Git - rrdd/commitdiff
rrdtool: Add support for post_draw_cmd
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Tue, 28 Oct 2014 19:16:21 +0000 (21:16 +0200)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Tue, 28 Oct 2014 19:16:21 +0000 (21:16 +0200)
Just like pre_draw_cmd, post_draw_cmd is a command that gets to be
executed after graphs are drawn. This is useful for example
transferring generated graphs into final location once rendering is
complete.

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

index 68939bdc499edded4a32346ecfd1356f70f6c513..8ac1b63a867fad23e727938afad3fdcdf9792ebc 100644 (file)
--- a/config.c
+++ b/config.c
@@ -232,6 +232,7 @@ static int parse_database(config_setting_t *rrd, struct rrd_database *db)
        config_setting_t *list, *str_list;
        const char *name, *parser = NULL, *filename, **parser_data;
        const char **pre_draw_cmd;
        config_setting_t *list, *str_list;
        const char *name, *parser = NULL, *filename, **parser_data;
        const char **pre_draw_cmd;
+       const char **post_draw_cmd;
        const char *logfile = NULL, *logfile_timestamp_fmt = NULL;
 
        if (!config_setting_lookup_string(rrd, "name", &name)) {
        const char *logfile = NULL, *logfile_timestamp_fmt = NULL;
 
        if (!config_setting_lookup_string(rrd, "name", &name)) {
@@ -274,6 +275,12 @@ static int parse_database(config_setting_t *rrd, struct rrd_database *db)
                db->pre_draw_cmd = (char *const *)pre_draw_cmd;
        }
 
                db->pre_draw_cmd = (char *const *)pre_draw_cmd;
        }
 
+       str_list = config_setting_get_member(rrd, "post_draw_cmd");
+       if (str_list) {
+               read_strings_from_list(str_list, &post_draw_cmd);
+               db->pre_draw_cmd = (char *const *)post_draw_cmd;
+       }
+
        config_setting_lookup_string(rrd, "logfile", &logfile);
        if (logfile)
                db->logfile = strdup(logfile);
        config_setting_lookup_string(rrd, "logfile", &logfile);
        if (logfile)
                db->logfile = strdup(logfile);
index df9b5c80fba4f788855b9f0c3fe3ceb888137ee1..909e1233ce43becfe2ac8b8ef475ec3ddd086705 100644 (file)
--- a/rrdtool.c
+++ b/rrdtool.c
@@ -298,6 +298,12 @@ int rrdtool_update_data(struct rrd_database *rrd)
                rrdtool_draw_images(rrd->images);
 
        while (harvest_zombies(0));
                rrdtool_draw_images(rrd->images);
 
        while (harvest_zombies(0));
+
+       if (rrd->post_draw_cmd && !strcmp(rrd->post_draw_cmd[0], "shell")) {
+               pid = run(rrd->post_draw_cmd[1], &rrd->post_draw_cmd[1]);
+               harvest_zombies(pid);
+       }
+
        exit(0);
 }
 
        exit(0);
 }
 
index 91fab9cfada4246e7f155a1aa7af12b949ff5add..ec8a9d432dd5b53d3a23d911dff9535bda83981f 100644 (file)
--- a/rrdtool.h
+++ b/rrdtool.h
@@ -41,6 +41,7 @@ struct rrd_database {
        const char **parser_data;       /* data to be fed to the parser */
 
        char *const *pre_draw_cmd; /* Command to execute prior drawing images*/
        const char **parser_data;       /* data to be fed to the parser */
 
        char *const *pre_draw_cmd; /* Command to execute prior drawing images*/
+       char *const *post_draw_cmd; /* ..and after drawing images */
 
        struct  rrd_image **images; /* Images to draw */
 
 
        struct  rrd_image **images; /* Images to draw */