summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2021-11-24 14:38:18 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2021-11-24 14:38:18 (GMT)
commit40d4e8a057a77e357c26d701c5fd304b51787b93 (patch)
tree1fbc9ce2d9ad7b73d588613b2ded540266317854 /plugins
parente2f24a5af3fe407035c8c57f539148f2d694973b (diff)
downloadmonitoring-plugins-40d4e8a057a77e357c26d701c5fd304b51787b93.tar.gz
check_hpjd: Fixing port option
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_hpjd.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index d3d72d7..c4b4417 100644
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
@@ -66,7 +66,7 @@ void print_usage (void);
66 66
67char *community = NULL; 67char *community = NULL;
68char *address = NULL; 68char *address = NULL;
69char *port = NULL; 69unsigned int port = 0;
70int check_paper_out = 1; 70int check_paper_out = 1;
71 71
72int 72int
@@ -121,8 +121,12 @@ main (int argc, char **argv)
121 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY); 121 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY);
122 122
123 /* get the command to run */ 123 /* get the command to run */
124 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%s %s", PATH_TO_SNMPGET, community, 124 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%u %s",
125 address, port, query_string); 125 PATH_TO_SNMPGET,
126 community,
127 address,
128 port,
129 query_string);
126 130
127 /* run the command */ 131 /* run the command */
128 child_process = spopen (command_line); 132 child_process = spopen (command_line);
@@ -380,11 +384,8 @@ process_arguments (int argc, char **argv)
380 community = strdup (DEFAULT_COMMUNITY); 384 community = strdup (DEFAULT_COMMUNITY);
381 } 385 }
382 386
383 if (port == NULL) { 387 if (port == 0) {
384 if (argv[c] != NULL ) 388 port = atoi(DEFAULT_PORT);
385 port = argv[c];
386 else
387 port = atoi (DEFAULT_PORT);
388 } 389 }
389 390
390 return validate_arguments (); 391 return validate_arguments ();