summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-02-25 11:32:18 +0100
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-03-07 23:38:50 +0100
commitadd5bfb1e4029e406f7f331407c9d0f28d6d789b (patch)
treeb8833d0ab3506c0308ad2105ab8d521d9affbc6d
parent5ee9a5eadd7c9252fc4deb6cc502535d8e0e49d5 (diff)
downloadmonitoring-plugins-add5bfb1e4029e406f7f331407c9d0f28d6d789b.tar.gz
check_ssh: Move default SSH constant around a bit
-rw-r--r--plugins/check_ssh.c7
-rw-r--r--plugins/check_ssh.d/config.h4
2 files changed, 5 insertions, 6 deletions
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index 0f1c0835..b73cdf24 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -44,7 +44,6 @@ const char *email = "devel@monitoring-plugins.org";
44# define MSG_DONTWAIT 0 44# define MSG_DONTWAIT 0
45#endif 45#endif
46 46
47#define SSH_DFL_PORT 22
48#define BUFF_SZ 256 47#define BUFF_SZ 256
49 48
50static bool verbose = false; 49static bool verbose = false;
@@ -219,9 +218,7 @@ process_arguments_wrapper process_arguments(int argc, char **argv) {
219 result.errorcode = ERROR; 218 result.errorcode = ERROR;
220 return result; 219 return result;
221 } 220 }
222 if (result.config.port == -1) { /* funky, but allows -p to override stray integer in args */ 221
223 result.config.port = SSH_DFL_PORT;
224 }
225 return result; 222 return result;
226} 223}
227 224
@@ -398,7 +395,7 @@ int ssh_connect(mp_check *overall, char *haddr, int hport, char *desired_remote_
398 395
399void print_help(void) { 396void print_help(void) {
400 char *myport; 397 char *myport;
401 xasprintf(&myport, "%d", SSH_DFL_PORT); 398 xasprintf(&myport, "%d", default_ssh_port);
402 399
403 print_revision(progname, NP_VERSION); 400 print_revision(progname, NP_VERSION);
404 401
diff --git a/plugins/check_ssh.d/config.h b/plugins/check_ssh.d/config.h
index d739c57c..c150fd30 100644
--- a/plugins/check_ssh.d/config.h
+++ b/plugins/check_ssh.d/config.h
@@ -3,6 +3,8 @@
3#include <stddef.h> 3#include <stddef.h>
4#include "../../lib/monitoringplug.h" 4#include "../../lib/monitoringplug.h"
5 5
6const int default_ssh_port = 22;
7
6typedef struct check_ssh_config { 8typedef struct check_ssh_config {
7 int port; 9 int port;
8 char *server_name; 10 char *server_name;
@@ -15,7 +17,7 @@ typedef struct check_ssh_config {
15 17
16check_ssh_config check_ssh_config_init(void) { 18check_ssh_config check_ssh_config_init(void) {
17 check_ssh_config tmp = { 19 check_ssh_config tmp = {
18 .port = -1, 20 .port = default_ssh_port,
19 .server_name = NULL, 21 .server_name = NULL,
20 .remote_version = NULL, 22 .remote_version = NULL,
21 .remote_protocol = NULL, 23 .remote_protocol = NULL,