diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-08 04:33:21 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-08 04:33:21 +0000 |
commit | 65ca899d2c98b6342783922a5709c4b61e6b2b1f (patch) | |
tree | 81bff537f3ba725e1d214d548199868572baf76b /plugins/check_by_ssh.c | |
parent | 92cd137176830bcdfbd477f151ba22d456b2e31c (diff) | |
download | monitoring-plugins-65ca899d2c98b6342783922a5709c4b61e6b2b1f.tar.gz |
fix a variety of compiler warnings about qualifier discards and other pedantic stuff
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@662 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_by_ssh.c')
-rw-r--r-- | plugins/check_by_ssh.c | 203 |
1 files changed, 104 insertions, 99 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 1211daa3..8527b727 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c | |||
@@ -1,25 +1,19 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | |
3 | * This file is part of the Nagios Plugins. | 3 | The Nagios Plugins are free software; you can redistribute them |
4 | * | 4 | and/or modify them under the terms of the GNU General Public |
5 | * Copyright (c) 1999, 2000, 2001 Karl DeBisschop <karl@debisschop.net> | 5 | License as published by the Free Software Foundation; either |
6 | * | 6 | version 2 of the License, or (at your option) any later version. |
7 | * The Nagios Plugins are free software; you can redistribute them | 7 | |
8 | * and/or modify them under the terms of the GNU General Public | 8 | This program is distributed in the hope that it will be useful, but |
9 | * License as published by the Free Software Foundation; either | 9 | WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * version 2 of the License, or (at your option) any later version. | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | * | 11 | General Public License for more details. |
12 | * This program is distributed in the hope that it will be useful, but | 12 | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | You should have received a copy of the GNU General Public License |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | along with this program; if not, write to the Free Software |
15 | * General Public License for more details. | 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | * | 16 | |
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | * | ||
21 | * $Id$ | ||
22 | * | ||
23 | *****************************************************************************/ | 17 | *****************************************************************************/ |
24 | 18 | ||
25 | const char *progname = "check_by_ssh"; | 19 | const char *progname = "check_by_ssh"; |
@@ -27,7 +21,6 @@ const char *revision = "$Revision$"; | |||
27 | const char *copyright = "2000-2003"; | 21 | const char *copyright = "2000-2003"; |
28 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | 22 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; |
29 | 23 | ||
30 | #include "config.h" | ||
31 | #include "common.h" | 24 | #include "common.h" |
32 | #include "netutils.h" | 25 | #include "netutils.h" |
33 | #include "utils.h" | 26 | #include "utils.h" |
@@ -38,83 +31,10 @@ int validate_arguments (void); | |||
38 | void print_help (void); | 31 | void print_help (void); |
39 | void print_usage (void); | 32 | void print_usage (void); |
40 | 33 | ||
41 | void | ||
42 | print_help (void) | ||
43 | { | ||
44 | print_revision (progname, revision); | ||
45 | |||
46 | printf (_(COPYRIGHT), copyright, email); | ||
47 | |||
48 | printf (_("This plugin uses SSH to execute commands on a remote host\n\n")); | ||
49 | |||
50 | print_usage (); | ||
51 | |||
52 | printf (_(UT_HELP_VRSN)); | ||
53 | |||
54 | printf (_(UT_HOST_PORT), 'p', "none"); | ||
55 | |||
56 | printf (_(UT_IPv46)); | ||
57 | |||
58 | printf (_("\ | ||
59 | -1, --proto1\n\ | ||
60 | tell ssh to use Protocol 1\n\ | ||
61 | -2, --proto2\n\ | ||
62 | tell ssh to use Protocol 2\n\ | ||
63 | -f\n\ | ||
64 | tells ssh to fork rather than create a tty\n")); | ||
65 | |||
66 | printf (_("\ | ||
67 | -C, --command='COMMAND STRING'\n\ | ||
68 | command to execute on the remote machine\n\ | ||
69 | -l, --logname=USERNAME\n\ | ||
70 | SSH user name on remote host [optional]\n\ | ||
71 | -i, --identity=KEYFILE\n\ | ||
72 | identity of an authorized key [optional]\n\ | ||
73 | -O, --output=FILE\n\ | ||
74 | external command file for nagios [optional]\n\ | ||
75 | -s, --services=LIST\n\ | ||
76 | list of nagios service names, separated by ':' [optional]\n\ | ||
77 | -n, --name=NAME\n\ | ||
78 | short name of host in nagios configuration [optional]\n")); | ||
79 | |||
80 | printf (_(UT_WARN_CRIT)); | ||
81 | |||
82 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
83 | |||
84 | printf (_("\n\ | ||
85 | The most common mode of use is to refer to a local identity file with\n\ | ||
86 | the '-i' option. In this mode, the identity pair should have a null\n\ | ||
87 | passphrase and the public key should be listed in the authorized_keys\n\ | ||
88 | file of the remote host. Usually the key will be restricted to running\n\ | ||
89 | only one command on the remote server. If the remote SSH server tracks\n\ | ||
90 | invocation agruments, the one remote program may be an agent that can\n\ | ||
91 | execute additional commands as proxy\n")); | ||
92 | |||
93 | printf (_("\n\ | ||
94 | To use passive mode, provide multiple '-C' options, and provide\n\ | ||
95 | all of -O, -s, and -n options (servicelist order must match '-C'\n\ | ||
96 | options)\n")); | ||
97 | } | ||
98 | |||
99 | |||
100 | |||
101 | |||
102 | |||
103 | void | ||
104 | print_usage (void) | ||
105 | { | ||
106 | printf (_("Usage:\n\ | ||
107 | check_by_ssh [-f46] [-t timeout] [-i identity] [-l user] -H <host> -C <command>\n\ | ||
108 | [-n name] [-s servicelist] [-O outputfile] [-p port]\n\ | ||
109 | check_by_ssh -V prints version info\n\ | ||
110 | check_by_ssh -h prints more detailed help\n")); | ||
111 | } | ||
112 | |||
113 | |||
114 | int commands = 0; | 34 | int commands = 0; |
115 | int services = 0; | 35 | int services = 0; |
116 | char *remotecmd = ""; | 36 | char *remotecmd = NULL; |
117 | char *comm = SSH_COMMAND; | 37 | char *comm = NULL; |
118 | char *hostname = NULL; | 38 | char *hostname = NULL; |
119 | char *outputfile = NULL; | 39 | char *outputfile = NULL; |
120 | char *host_shortname = NULL; | 40 | char *host_shortname = NULL; |
@@ -123,20 +43,26 @@ int passive = FALSE; | |||
123 | int verbose = FALSE; | 43 | int verbose = FALSE; |
124 | 44 | ||
125 | 45 | ||
46 | |||
47 | |||
48 | |||
49 | |||
126 | int | 50 | int |
127 | main (int argc, char **argv) | 51 | main (int argc, char **argv) |
128 | { | 52 | { |
129 | 53 | ||
130 | char input_buffer[MAX_INPUT_BUFFER]; | 54 | char input_buffer[MAX_INPUT_BUFFER]; |
131 | char *result_text = ""; | 55 | char *result_text; |
132 | char *status_text; | 56 | char *status_text; |
133 | char *output = ""; | 57 | char *output; |
134 | char *eol = NULL; | 58 | char *eol = NULL; |
135 | int cresult; | 59 | int cresult; |
136 | int result = STATE_UNKNOWN; | 60 | int result = STATE_UNKNOWN; |
137 | time_t local_time; | 61 | time_t local_time; |
138 | FILE *fp = NULL; | 62 | FILE *fp = NULL; |
139 | 63 | ||
64 | asprintf (&remotecmd, "%s", ""); | ||
65 | asprintf (&comm, "%s", SSH_COMMAND); | ||
140 | 66 | ||
141 | /* process arguments */ | 67 | /* process arguments */ |
142 | if (process_arguments (argc, argv) == ERROR) | 68 | if (process_arguments (argc, argv) == ERROR) |
@@ -235,6 +161,7 @@ main (int argc, char **argv) | |||
235 | 161 | ||
236 | 162 | ||
237 | 163 | ||
164 | |||
238 | /* process command-line arguments */ | 165 | /* process command-line arguments */ |
239 | int | 166 | int |
240 | process_arguments (int argc, char **argv) | 167 | process_arguments (int argc, char **argv) |
@@ -392,3 +319,81 @@ validate_arguments (void) | |||
392 | 319 | ||
393 | return OK; | 320 | return OK; |
394 | } | 321 | } |
322 | |||
323 | |||
324 | |||
325 | |||
326 | |||
327 | |||
328 | void | ||
329 | print_help (void) | ||
330 | { | ||
331 | print_revision (progname, revision); | ||
332 | |||
333 | printf (_("Copyright (c) 1999 Karl DeBisschop <kdebisschop@users.sourceforge.net>\n")); | ||
334 | printf (_(COPYRIGHT), copyright, email); | ||
335 | |||
336 | printf (_("This plugin uses SSH to execute commands on a remote host\n\n")); | ||
337 | |||
338 | print_usage (); | ||
339 | |||
340 | printf (_(UT_HELP_VRSN)); | ||
341 | |||
342 | printf (_(UT_HOST_PORT), 'p', "none"); | ||
343 | |||
344 | printf (_(UT_IPv46)); | ||
345 | |||
346 | printf (_("\ | ||
347 | -1, --proto1\n\ | ||
348 | tell ssh to use Protocol 1\n\ | ||
349 | -2, --proto2\n\ | ||
350 | tell ssh to use Protocol 2\n\ | ||
351 | -f\n\ | ||
352 | tells ssh to fork rather than create a tty\n")); | ||
353 | |||
354 | printf (_("\ | ||
355 | -C, --command='COMMAND STRING'\n\ | ||
356 | command to execute on the remote machine\n\ | ||
357 | -l, --logname=USERNAME\n\ | ||
358 | SSH user name on remote host [optional]\n\ | ||
359 | -i, --identity=KEYFILE\n\ | ||
360 | identity of an authorized key [optional]\n\ | ||
361 | -O, --output=FILE\n\ | ||
362 | external command file for nagios [optional]\n\ | ||
363 | -s, --services=LIST\n\ | ||
364 | list of nagios service names, separated by ':' [optional]\n\ | ||
365 | -n, --name=NAME\n\ | ||
366 | short name of host in nagios configuration [optional]\n")); | ||
367 | |||
368 | printf (_(UT_WARN_CRIT)); | ||
369 | |||
370 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
371 | |||
372 | printf (_("\n\ | ||
373 | The most common mode of use is to refer to a local identity file with\n\ | ||
374 | the '-i' option. In this mode, the identity pair should have a null\n\ | ||
375 | passphrase and the public key should be listed in the authorized_keys\n\ | ||
376 | file of the remote host. Usually the key will be restricted to running\n\ | ||
377 | only one command on the remote server. If the remote SSH server tracks\n\ | ||
378 | invocation agruments, the one remote program may be an agent that can\n\ | ||
379 | execute additional commands as proxy\n")); | ||
380 | |||
381 | printf (_("\n\ | ||
382 | To use passive mode, provide multiple '-C' options, and provide\n\ | ||
383 | all of -O, -s, and -n options (servicelist order must match '-C'\n\ | ||
384 | options)\n")); | ||
385 | } | ||
386 | |||
387 | |||
388 | |||
389 | |||
390 | |||
391 | void | ||
392 | print_usage (void) | ||
393 | { | ||
394 | printf (_("\n\ | ||
395 | Usage: %s [-f46] [-t timeout] [-i identity] [-l user] -H <host> \n\ | ||
396 | -C <command> [-n name] [-s servicelist] [-O outputfile] [-p port]\n"), | ||
397 | progname); | ||
398 | printf (_(UT_HLP_VRS), progname, progname); | ||
399 | } | ||