summaryrefslogtreecommitdiffstats
path: root/plugins/check_by_ssh.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_by_ssh.c')
-rw-r--r--plugins/check_by_ssh.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 5c505309..34e67274 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -283,14 +283,19 @@ process_arguments (int argc, char **argv)
283 283
284 c = optind; 284 c = optind;
285 if (hostname == NULL) { 285 if (hostname == NULL) {
286 if (!is_host (argv[c])) 286 if (c <= argc) {
287 terminate (STATE_UNKNOWN, "%s: You must provide a host name\n", progname);
288 } else if (!is_host (argv[c]))
287 terminate (STATE_UNKNOWN, "%s: Invalid host name %s\n", progname, argv[c]); 289 terminate (STATE_UNKNOWN, "%s: Invalid host name %s\n", progname, argv[c]);
288 hostname = argv[c++]; 290 hostname = argv[c++];
289 } 291 }
290 292
291 if (strlen(remotecmd) == 0) { 293 if (strlen(remotecmd) == 0) {
292 for (; c < argc; c++) 294 for (; c < argc; c++)
293 asprintf (&remotecmd, "%s %s", remotecmd, argv[c]); 295 if (strlen(remotecmd) > 0)
296 asprintf (&remotecmd, "%s %s", remotecmd, argv[c]);
297 else
298 asprintf (&remotecmd, "%s", argv[c]);
294 } 299 }
295 300
296 if (commands > 1) 301 if (commands > 1)