#include <sys/types.h>
#include <unistd.h>
+#include <getopt.h>
#include "process.h"
#include "rrdtool.h"
#include "database.h"
+struct user_options {
+ int max_jobs;
+};
+
+int read_args(int argc, char *argv[], struct user_options *opts)
+{
+ int option_index = 0, c;
+ static struct option long_options[] = {
+ { .val = 'j', .name = "jobs", .has_arg = 1, },
+ };
+ char short_options[] = "j:";
+
+ while (1) {
+ c = getopt_long(argc, argv, short_options, long_options,
+ &option_index);
+
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case 'j':
+ opts->max_jobs = atoi(optarg);
+ break;
+
+ case '?':
+ return -1;
+ }
+ }
+ return 0;
+}
int main(int argc, char *argv[])
{
+ struct user_options opts;
struct rrd_database *db;
int sleeptime;
+ bzero(&opts, sizeof(opts));
+
+ if (read_args(argc, argv, &opts) < 0)
+ return -1;
+
rrdtool_create_missing_databases(all_rrds);
- init_max_jobs(0);
+ init_max_jobs(opts.max_jobs);
while (1) {
pr_info("loop start\n");