Skip to content

Commit

Permalink
Fixing #329 - CLI thread feature for testing
Browse files Browse the repository at this point in the history
Allow users to override the threads setting at the command line
  • Loading branch information
TheWitness committed Nov 13, 2023
1 parent 14e89ec commit 1a15dfe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions spine.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 7 additions & 5 deletions util.c
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit 1a15dfe

Please sign in to comment.