[monitoring-plugins] check_hpjd: Fixing port option

RincewindsHat git at monitoring-plugins.org
Thu Nov 25 09:10:12 CET 2021


 Module: monitoring-plugins
 Branch: master
 Commit: 40d4e8a057a77e357c26d701c5fd304b51787b93
 Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com>
   Date: Wed Nov 24 15:38:18 2021 +0100
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=40d4e8a

check_hpjd: Fixing port option

---

 plugins/check_hpjd.c | 17 +++++++++--------
 1 file 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);
 
 char *community = NULL;
 char *address = NULL;
-char *port = NULL;
+unsigned int port = 0;
 int  check_paper_out = 1;
 
 int
@@ -121,8 +121,12 @@ main (int argc, char **argv)
 		 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY);
 
 	/* get the command to run */
-	sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%s %s", PATH_TO_SNMPGET, community,
-									address, port, query_string);
+	sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%u %s",
+			PATH_TO_SNMPGET,
+			community,
+			address,
+			port,
+			query_string);
 
 	/* run the command */
 	child_process = spopen (command_line);
@@ -380,11 +384,8 @@ process_arguments (int argc, char **argv)
 			community = strdup (DEFAULT_COMMUNITY);
 	}
 
-	if (port == NULL) {
-		if (argv[c] != NULL )
-			port = argv[c];
-		else
-			port = atoi (DEFAULT_PORT);
+	if (port == 0) {
+		port = atoi(DEFAULT_PORT);
 	}
 
 	return validate_arguments ();



More information about the Commits mailing list