13 #include "built_in_parsers.h"
15 #include "plugin_manager.h"
22 int read_args(int argc, char *argv[], struct user_options *opts)
24 int option_index = 0, c;
25 static struct option long_options[] = {
26 { .val = 'j', .has_arg = 1, .name = "jobs", },
27 { .val = 'c', .has_arg = 1, .name = "config", },
30 char short_options[] = "j:c:";
33 c = getopt_long(argc, argv, short_options, long_options,
41 opts->max_jobs = atoi(optarg);
45 opts->config_file = optarg;
53 while (optind < argc) {
54 opts->config_file = argv[optind];
61 int main(int argc, char *argv[])
63 struct user_options opts;
64 struct rrd_database *db, **db_list = NULL;
68 pr_info("%s Version %s starting\n", argv[0], RRDD_VERSION);
70 bzero(&opts, sizeof(opts));
72 if (read_args(argc, argv, &opts) < 0)
75 init_plugin_manager(argv[0]);
76 register_built_in_parsers();
78 if (!opts.config_file) {
79 pr_err("No database config file given. Nothing to do\n");
83 db_list = populate_database(opts.config_file);
88 if (rrdtool_create_missing_databases(db_list))
91 if (init_jobcontrol(opts.max_jobs))
99 pr_info("loop start\n");
101 * Update all databases parallel in one shot
103 while ((db = get_outdated_db(db_list)))
104 rrdtool_update_data(db);
106 sleeptime = get_next_update(db_list, &db_name);
108 t = time(0) + sleeptime;
109 strftime(timestr, sizeof(timestr), "%T", localtime(&t));
110 pr_info("Next scheduled event \"%s\" at %s, in %d seconds\n",
111 db_name, timestr, sleeptime);
113 poll_job_requests(sleeptime);