diff --git a/CHANGELOG b/CHANGELOG index 2faf22c..ea9787e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ The Cacti Group | spine -issue#317: WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version. -issue#321: Spine does not check a host with no poller items -issue#323: Wrong number of devices in stats due to device 0 assumption +-feature#329: Allow users to override the threads setting at the command line 1.2.25 -issue#234: Spine should see if script to be executed is executable diff --git a/spine.c b/spine.c index 2e83c1c..d71d31c 100644 --- a/spine.c +++ b/spine.c @@ -256,6 +256,9 @@ int main(int argc, char *argv[]) { /* initialize icmp_avail */ set.icmp_avail = TRUE; + /* initialize number of threads */ + set.threads = 1; + /* detect and compensate for stdin/stderr ttys */ if (!isatty(fileno(stdout))) { set.stdout_notty = TRUE; @@ -358,6 +361,10 @@ int main(int argc, char *argv[]) { set.poller_id = atoi(getarg(opt, &argv)); } + else if (STRMATCH(arg, "-t") || STRIMATCH(arg, "--threads")) { + set.threads = atoi(getarg(opt, &argv)); + } + else if (STRMATCH(arg, "-P") || STRIMATCH(arg, "--pingonly")) { set.ping_only = TRUE; } @@ -1125,6 +1132,7 @@ static void display_help(int only_version) { " -l/--last=X End polling with host id X", " -H/--hostlist=X Poll the list of host ids, separated by comma's", " -p/--poller=X Set the poller id to X", + " -t/--threads=X Override the database threads setting.", " -C/--conf=F Read spine configuration from file F", " -O/--option=S:V Override DB settings 'set' with value 'V'", " -M/--mibs Refresh the device System Mib data", diff --git a/util.c b/util.c index 910c6ad..d97a00d 100644 --- a/util.c +++ b/util.c @@ -555,11 +555,13 @@ void read_config_options() { SPINE_LOG_DEBUG(("DEBUG: The log_pstats variable is %i", set.log_pstats)); /* get Cacti defined max threads override spine.conf */ - if ((res = getpsetting(&mysql, mode, "threads")) != 0) { - set.threads = atoi(res); - free((char *)res); - if (set.threads > MAX_THREADS) { - set.threads = MAX_THREADS; + if (set.threads == 1) { + if ((res = getpsetting(&mysql, mode, "threads")) != 0) { + set.threads = atoi(res); + free((char *)res); + if (set.threads > MAX_THREADS) { + set.threads = MAX_THREADS; + } } }