Make it possible to replace the "Last update ..." string with
something that fits better for the needs of the end user. The string
is passed through strftime so one can use arbitrary timestamp formats.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
const char *database = NULL, *filename = NULL, *timestart = NULL;
const char *timeend = NULL, *imageformat = NULL;
const char **options = NULL, **text = NULL;
const char *database = NULL, *filename = NULL, *timestart = NULL;
const char *timeend = NULL, *imageformat = NULL;
const char **options = NULL, **text = NULL;
+ const char *updatestr = NULL;
int width = 0, height = 0, text_lead = 0;
count = config_setting_length(list);
int width = 0, height = 0, text_lead = 0;
count = config_setting_length(list);
+ config_setting_lookup_string(image, "update_string",
+ &updatestr);
+
str_list = config_setting_get_member(image, "options");
if (str_list)
read_strings_from_list(str_list, &options);
str_list = config_setting_get_member(image, "options");
if (str_list)
read_strings_from_list(str_list, &options);
db->images[i]->options = options;
db->images[i]->text_lead = text_lead;
db->images[i]->text = text;
db->images[i]->options = options;
db->images[i]->text_lead = text_lead;
db->images[i]->text = text;
+
+ if (updatestr)
+ db->images[i]->updatestr = strdup(updatestr);
char *args[512], argstr[ARGSTR_LEN];
int idx = 0, argcnt = 0, i,j;
char timestamp[256];
char *args[512], argstr[ARGSTR_LEN];
int idx = 0, argcnt = 0, i,j;
char timestamp[256];
+ char tmp[sizeof(timestamp)];
char tmpfile[256];
time_t t = time(0);
char tmpfile[256];
time_t t = time(0);
+ const char *updatestr = "Last update %d.%m.%Y %T (%Z)";
pid = do_fork_limited();
if (pid)
pid = do_fork_limited();
if (pid)
strncat(tmpfile, image->image_filename, sizeof(tmp) - strlen(tmp) - 1);
strncat(tmpfile, ".tmp", sizeof(tmp) - strlen(tmp) - 1);
strncat(tmpfile, image->image_filename, sizeof(tmp) - strlen(tmp) - 1);
strncat(tmpfile, ".tmp", sizeof(tmp) - strlen(tmp) - 1);
- strftime(tmp, 256, "%d.%m.%Y %T (%Z) ", localtime(&t));
- for (i = 0, j = 0; j < 256;) {
+ if (image->updatestr)
+ updatestr = image->updatestr;
+
+ strftime(tmp, sizeof(tmp), updatestr, localtime(&t));
+ for (i = 0, j = 0; j < sizeof(tmp);) {
if (tmp[i] == ':') {
timestamp[j++] = '\\';
}
if (tmp[i] == ':') {
timestamp[j++] = '\\';
}
args[argcnt++] = (char *)image->text[i];
}
args[argcnt++] = (char *)image->text[i];
}
- add_arg(args, argcnt, argstr, idx, "COMMENT:Last update %s\\c", timestamp);
+ add_arg(args, argcnt, argstr, idx, "COMMENT: %s\\c", timestamp);
const char **options; /* Null terminated list of rrdgraph options */
int text_lead; /* Number of spaces at the beginning of line */
const char **text; /* Null terminated list of text lines */
const char **options; /* Null terminated list of rrdgraph options */
int text_lead; /* Number of spaces at the beginning of line */
const char **text; /* Null terminated list of text lines */
+ const char *updatestr; /* "Last update" string comment */
};
struct rrd_data_source {
};
struct rrd_data_source {