summaryrefslogtreecommitdiffstats
path: root/plugins/check_ssh.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-05 11:53:21 +0000
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-05 11:53:21 +0000
commitcb3e39b1aabc697148bef356d81fbacd0655995e (patch)
treed7bf10927ac90a2b8278a54bc47b5ca6cab77a95 /plugins/check_ssh.c
parent1c8510de8a0b1266c3d1bd2b59f809088ec304f1 (diff)
downloadmonitoring-plugins-cb3e39b1aabc697148bef356d81fbacd0655995e.tar.gz
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@647 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ssh.c')
-rw-r--r--plugins/check_ssh.c95
1 files changed, 58 insertions, 37 deletions
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index fba3a862..7fcb8119 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -1,22 +1,29 @@
1/* 1/******************************************************************************
2* check_ssh.c 2
3* 3 This program is free software; you can redistribute it and/or modify
4* Made by (Remi PAULMIER) 4 it under the terms of the GNU General Public License as published by
5* Login <remi@sinfomic.fr> 5 the Free Software Foundation; either version 2 of the License, or
6* 6 (at your option) any later version.
7* Started on Fri Jul 9 09:18:23 1999 Remi PAULMIER 7
8* Update Thu Jul 22 12:50:04 1999 remi paulmier 8 This program is distributed in the hope that it will be useful,
9* $Id$ 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10* 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11*/ 11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
17******************************************************************************/
12 18
13#include "config.h"
14#include "common.h" 19#include "common.h"
15#include "netutils.h" 20#include "netutils.h"
16#include "utils.h" 21#include "utils.h"
17 22
18const char *progname = "check_ssh"; 23const char *progname = "check_ssh";
19#define REVISION "$Revision$" 24const char *revision = "$Revision$";
25const char *copyright = "2000-2003";
26const char *email = "nagiosplug-devel@lists.sourceforge.net";
20 27
21#ifndef MSG_DONTWAIT 28#ifndef MSG_DONTWAIT
22#define MSG_DONTWAIT 0 29#define MSG_DONTWAIT 0
@@ -42,7 +49,7 @@ main (int argc, char **argv)
42 int result; 49 int result;
43 50
44 if (process_arguments (argc, argv) == ERROR) 51 if (process_arguments (argc, argv) == ERROR)
45 usage ("Could not parse arguments\n"); 52 usage (_("Could not parse arguments\n"));
46 53
47 /* initialize alarm signal handling */ 54 /* initialize alarm signal handling */
48 signal (SIGALRM, socket_timeout_alarm_handler); 55 signal (SIGALRM, socket_timeout_alarm_handler);
@@ -62,17 +69,17 @@ int
62process_arguments (int argc, char **argv) 69process_arguments (int argc, char **argv)
63{ 70{
64 int c; 71 int c;
65 char *tmp = NULL;
66 72
67 int option_index = 0; 73 int option_index = 0;
68 static struct option long_options[] = { 74 static struct option long_options[] = {
69 {"version", no_argument, 0, 'V'},
70 {"help", no_argument, 0, 'h'}, 75 {"help", no_argument, 0, 'h'},
76 {"version", no_argument, 0, 'V'},
77 {"host", required_argument, 0, 'H'},
78 {"port", required_argument, 0, 'p'},
71 {"use-ipv4", no_argument, 0, '4'}, 79 {"use-ipv4", no_argument, 0, '4'},
72 {"use-ipv6", no_argument, 0, '6'}, 80 {"use-ipv6", no_argument, 0, '6'},
73 {"verbose", no_argument, 0, 'v'},
74 {"timeout", required_argument, 0, 't'}, 81 {"timeout", required_argument, 0, 't'},
75 {"host", required_argument, 0, 'H'}, 82 {"verbose", no_argument, 0, 'v'},
76 {0, 0, 0, 0} 83 {0, 0, 0, 0}
77 }; 84 };
78 85
@@ -93,7 +100,7 @@ process_arguments (int argc, char **argv)
93 case '?': /* help */ 100 case '?': /* help */
94 usage (""); 101 usage ("");
95 case 'V': /* version */ 102 case 'V': /* version */
96 print_revision (progname, REVISION); 103 print_revision (progname, revision);
97 exit (STATE_OK); 104 exit (STATE_OK);
98 case 'h': /* help */ 105 case 'h': /* help */
99 print_help (); 106 print_help ();
@@ -103,7 +110,7 @@ process_arguments (int argc, char **argv)
103 break; 110 break;
104 case 't': /* timeout period */ 111 case 't': /* timeout period */
105 if (!is_integer (optarg)) 112 if (!is_integer (optarg))
106 usage ("Timeout Interval must be an integer!\n\n"); 113 usage (_("Timeout Interval must be an integer!\n\n"));
107 socket_timeout = atoi (optarg); 114 socket_timeout = atoi (optarg);
108 break; 115 break;
109 case '4': 116 case '4':
@@ -113,7 +120,7 @@ process_arguments (int argc, char **argv)
113#ifdef USE_IPV6 120#ifdef USE_IPV6
114 address_family = AF_INET6; 121 address_family = AF_INET6;
115#else 122#else
116 usage ("IPv6 support not available\n"); 123 usage (_("IPv6 support not available\n"));
117#endif 124#endif
118 break; 125 break;
119 case 'H': /* host */ 126 case 'H': /* host */
@@ -179,9 +186,9 @@ ssh_connect (char *haddr, short hport)
179 char *buffer = NULL; 186 char *buffer = NULL;
180 char *ssh_proto = NULL; 187 char *ssh_proto = NULL;
181 char *ssh_server = NULL; 188 char *ssh_server = NULL;
182 char revision[20]; 189 char rev_no[20];
183 190
184 sscanf ("$Revision$", "$Revision: %[0123456789.]", revision); 191 sscanf ("$Revision$", "$Revision: %[0123456789.]", rev_no);
185 192
186 result = my_tcp_connect (haddr, hport, &sd); 193 result = my_tcp_connect (haddr, hport, &sd);
187 194
@@ -192,7 +199,7 @@ ssh_connect (char *haddr, short hport)
192 memset (output, 0, BUFF_SZ + 1); 199 memset (output, 0, BUFF_SZ + 1);
193 recv (sd, output, BUFF_SZ, 0); 200 recv (sd, output, BUFF_SZ, 0);
194 if (strncmp (output, "SSH", 3)) { 201 if (strncmp (output, "SSH", 3)) {
195 printf ("Server answer: %s", output); 202 printf (_("Server answer: %s"), output);
196 exit (STATE_CRITICAL); 203 exit (STATE_CRITICAL);
197 } 204 }
198 else { 205 else {
@@ -203,9 +210,9 @@ ssh_connect (char *haddr, short hport)
203 ssh_server = ssh_proto + strspn (ssh_proto, "-0123456789. "); 210 ssh_server = ssh_proto + strspn (ssh_proto, "-0123456789. ");
204 ssh_proto[strspn (ssh_proto, "0123456789. ")] = 0; 211 ssh_proto[strspn (ssh_proto, "0123456789. ")] = 0;
205 printf 212 printf
206 ("SSH OK - %s (protocol %s)\n", 213 (_("SSH OK - %s (protocol %s)\n"),
207 ssh_server, ssh_proto); 214 ssh_server, ssh_proto);
208 asprintf (&buffer, "SSH-%s-check_ssh_%s\r\n", ssh_proto, revision); 215 asprintf (&buffer, "SSH-%s-check_ssh_%s\r\n", ssh_proto, rev_no);
209 send (sd, buffer, strlen (buffer), MSG_DONTWAIT); 216 send (sd, buffer, strlen (buffer), MSG_DONTWAIT);
210 if (verbose) 217 if (verbose)
211 printf ("%s\n", buffer); 218 printf ("%s\n", buffer);
@@ -216,23 +223,37 @@ ssh_connect (char *haddr, short hport)
216void 223void
217print_help (void) 224print_help (void)
218{ 225{
219 print_revision (progname, REVISION); 226 char *myport;
220 printf ("Copyright (c) 1999 Remi Paulmier (remi@sinfomic.fr)\n\n"); 227 asprintf (&myport, "%d", SSH_DFL_PORT);
228
229 print_revision (progname, revision);
230
231 printf (_("Copyright (c) 1999 Remi Paulmier <remi@sinfomic.fr>\n"));
232 printf (_(COPYRIGHT), copyright, email);
233
234 printf (_("Try to connect to SSH server at specified server and port\n\n"));
235
221 print_usage (); 236 print_usage ();
222 printf ("by default, port is %d\n", SSH_DFL_PORT); 237
238 printf (_(UT_HELP_VRSN));
239
240 printf (_(UT_HOST_PORT), 'p', myport);
241
242 printf (_(UT_IPv46));
243
244 printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
245
246 printf (_(UT_VERBOSE));
247
248 printf (_(UT_SUPPORT));
223} 249}
224 250
225void 251void
226print_usage (void) 252print_usage (void)
227{ 253{
228 printf 254 printf (_("\
229 ("Usage:\n" 255Usage: %s [-46] [-t <timeout>] [-p <port>] <host>\n"), progname);
230 " %s -t [timeout] -p [port] <host>\n" 256 printf (_(UT_HLP_VRS), progname, progname);
231 " %s -V prints version info\n"
232 " %s -4 use IPv4 connection\n"
233 " %s -6 use IPv6 connection\n"
234 " %s -h prints more detailed help\n",
235 progname, progname, progname, progname, progname);
236} 257}
237 258
238/* end of check_ssh.c */ 259/* end of check_ssh.c */