diff options
Diffstat (limited to 'plugins/check_by_ssh.c')
-rw-r--r-- | plugins/check_by_ssh.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 1ad547ed..2a23b397 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c | |||
@@ -50,7 +50,7 @@ unsigned int services = 0; | |||
50 | int skip_stdout = 0; | 50 | int skip_stdout = 0; |
51 | int skip_stderr = 0; | 51 | int skip_stderr = 0; |
52 | int warn_on_stderr = 0; | 52 | int warn_on_stderr = 0; |
53 | bool unknown_timeout = FALSE; | 53 | bool unknown_timeout = false; |
54 | char *remotecmd = NULL; | 54 | char *remotecmd = NULL; |
55 | char **commargv = NULL; | 55 | char **commargv = NULL; |
56 | int commargc = 0; | 56 | int commargc = 0; |
@@ -58,8 +58,8 @@ char *hostname = NULL; | |||
58 | char *outputfile = NULL; | 58 | char *outputfile = NULL; |
59 | char *host_shortname = NULL; | 59 | char *host_shortname = NULL; |
60 | char **service; | 60 | char **service; |
61 | int passive = FALSE; | 61 | bool passive = false; |
62 | int verbose = FALSE; | 62 | bool verbose = false; |
63 | 63 | ||
64 | int | 64 | int |
65 | main (int argc, char **argv) | 65 | main (int argc, char **argv) |
@@ -68,7 +68,6 @@ main (int argc, char **argv) | |||
68 | char *status_text; | 68 | char *status_text; |
69 | int cresult; | 69 | int cresult; |
70 | int result = STATE_UNKNOWN; | 70 | int result = STATE_UNKNOWN; |
71 | int i; | ||
72 | time_t local_time; | 71 | time_t local_time; |
73 | FILE *fp = NULL; | 72 | FILE *fp = NULL; |
74 | output chld_out, chld_err; | 73 | output chld_out, chld_err; |
@@ -96,7 +95,7 @@ main (int argc, char **argv) | |||
96 | /* run the command */ | 95 | /* run the command */ |
97 | if (verbose) { | 96 | if (verbose) { |
98 | printf ("Command: %s\n", commargv[0]); | 97 | printf ("Command: %s\n", commargv[0]); |
99 | for (i=1; i<commargc; i++) | 98 | for (int i = 1; i < commargc; i++) |
100 | printf ("Argument %i: %s\n", i, commargv[i]); | 99 | printf ("Argument %i: %s\n", i, commargv[i]); |
101 | } | 100 | } |
102 | 101 | ||
@@ -110,9 +109,9 @@ main (int argc, char **argv) | |||
110 | } | 109 | } |
111 | 110 | ||
112 | if (verbose) { | 111 | if (verbose) { |
113 | for(i = 0; i < chld_out.lines; i++) | 112 | for(size_t i = 0; i < chld_out.lines; i++) |
114 | printf("stdout: %s\n", chld_out.line[i]); | 113 | printf("stdout: %s\n", chld_out.line[i]); |
115 | for(i = 0; i < chld_err.lines; i++) | 114 | for(size_t i = 0; i < chld_err.lines; i++) |
116 | printf("stderr: %s\n", chld_err.line[i]); | 115 | printf("stderr: %s\n", chld_err.line[i]); |
117 | } | 116 | } |
118 | 117 | ||
@@ -122,7 +121,7 @@ main (int argc, char **argv) | |||
122 | skip_stderr = chld_err.lines; | 121 | skip_stderr = chld_err.lines; |
123 | 122 | ||
124 | /* UNKNOWN or worse if (non-skipped) output found on stderr */ | 123 | /* UNKNOWN or worse if (non-skipped) output found on stderr */ |
125 | if(chld_err.lines > skip_stderr) { | 124 | if(chld_err.lines > (size_t)skip_stderr) { |
126 | printf (_("Remote command execution failed: %s\n"), | 125 | printf (_("Remote command execution failed: %s\n"), |
127 | chld_err.line[skip_stderr]); | 126 | chld_err.line[skip_stderr]); |
128 | if ( warn_on_stderr ) | 127 | if ( warn_on_stderr ) |
@@ -134,8 +133,8 @@ main (int argc, char **argv) | |||
134 | /* this is simple if we're not supposed to be passive. | 133 | /* this is simple if we're not supposed to be passive. |
135 | * Wrap up quickly and keep the tricks below */ | 134 | * Wrap up quickly and keep the tricks below */ |
136 | if(!passive) { | 135 | if(!passive) { |
137 | if (chld_out.lines > skip_stdout) | 136 | if (chld_out.lines > (size_t)skip_stdout) |
138 | for (i = skip_stdout; i < chld_out.lines; i++) | 137 | for (size_t i = skip_stdout; i < chld_out.lines; i++) |
139 | puts (chld_out.line[i]); | 138 | puts (chld_out.line[i]); |
140 | else | 139 | else |
141 | printf (_("%s - check_by_ssh: Remote command '%s' returned status %d\n"), | 140 | printf (_("%s - check_by_ssh: Remote command '%s' returned status %d\n"), |
@@ -156,7 +155,7 @@ main (int argc, char **argv) | |||
156 | 155 | ||
157 | local_time = time (NULL); | 156 | local_time = time (NULL); |
158 | commands = 0; | 157 | commands = 0; |
159 | for(i = skip_stdout; i < chld_out.lines; i++) { | 158 | for(size_t i = skip_stdout; i < chld_out.lines; i++) { |
160 | status_text = chld_out.line[i++]; | 159 | status_text = chld_out.line[i++]; |
161 | if (i == chld_out.lines || strstr (chld_out.line[i], "STATUS CODE: ") == NULL) | 160 | if (i == chld_out.lines || strstr (chld_out.line[i], "STATUS CODE: ") == NULL) |
162 | die (STATE_UNKNOWN, _("%s: Error parsing output\n"), progname); | 161 | die (STATE_UNKNOWN, _("%s: Error parsing output\n"), progname); |
@@ -235,7 +234,7 @@ process_arguments (int argc, char **argv) | |||
235 | print_help (); | 234 | print_help (); |
236 | exit (STATE_UNKNOWN); | 235 | exit (STATE_UNKNOWN); |
237 | case 'v': /* help */ | 236 | case 'v': /* help */ |
238 | verbose = TRUE; | 237 | verbose = true; |
239 | break; | 238 | break; |
240 | case 't': /* timeout period */ | 239 | case 't': /* timeout period */ |
241 | if (!is_integer (optarg)) | 240 | if (!is_integer (optarg)) |
@@ -244,7 +243,7 @@ process_arguments (int argc, char **argv) | |||
244 | timeout_interval = atoi (optarg); | 243 | timeout_interval = atoi (optarg); |
245 | break; | 244 | break; |
246 | case 'U': | 245 | case 'U': |
247 | unknown_timeout = TRUE; | 246 | unknown_timeout = true; |
248 | break; | 247 | break; |
249 | case 'H': /* host */ | 248 | case 'H': /* host */ |
250 | hostname = optarg; | 249 | hostname = optarg; |
@@ -257,7 +256,7 @@ process_arguments (int argc, char **argv) | |||
257 | break; | 256 | break; |
258 | case 'O': /* output file */ | 257 | case 'O': /* output file */ |
259 | outputfile = optarg; | 258 | outputfile = optarg; |
260 | passive = TRUE; | 259 | passive = true; |
261 | break; | 260 | break; |
262 | case 's': /* description of service to check */ | 261 | case 's': /* description of service to check */ |
263 | p1 = optarg; | 262 | p1 = optarg; |