summaryrefslogtreecommitdiffstats
path: root/plugins/check_by_ssh.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-22 06:22:38 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-22 06:22:38 (GMT)
commit22bd672d19c378f1e6124ee18e64e5a88cf53739 (patch)
tree127016323f2f3059819f75adb5568a00a0431fc2 /plugins/check_by_ssh.c
parentd35f99c8a9f546a0f02f09ad3f722f66322e813d (diff)
downloadmonitoring-plugins-22bd672d19c378f1e6124ee18e64e5a88cf53739.tar.gz
- bindtextdomain for gettext, a few other smale cleanups here and there
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@690 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_by_ssh.c')
-rw-r--r--plugins/check_by_ssh.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index b0aa189..560ae0c 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -42,11 +42,6 @@ char **service;
42int passive = FALSE; 42int passive = FALSE;
43int verbose = FALSE; 43int verbose = FALSE;
44 44
45
46
47
48
49
50int 45int
51main (int argc, char **argv) 46main (int argc, char **argv)
52{ 47{
@@ -61,8 +56,13 @@ main (int argc, char **argv)
61 time_t local_time; 56 time_t local_time;
62 FILE *fp = NULL; 57 FILE *fp = NULL;
63 58
64 asprintf (&remotecmd, "%s", ""); 59 remotecmd = strdup ("");
65 asprintf (&comm, "%s", SSH_COMMAND); 60 comm = strdup (SSH_COMMAND);
61 result_text = strdup ("");
62
63 setlocale (LC_ALL, "");
64 bindtextdomain (PACKAGE, LOCALEDIR);
65 textdomain (PACKAGE);
66 66
67 /* process arguments */ 67 /* process arguments */
68 if (process_arguments (argc, argv) == ERROR) 68 if (process_arguments (argc, argv) == ERROR)
@@ -71,7 +71,7 @@ main (int argc, char **argv)
71 71
72 /* Set signal handling and alarm timeout */ 72 /* Set signal handling and alarm timeout */
73 if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { 73 if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) {
74 printf ("Cannot catch SIGALRM"); 74 printf (_("Cannot catch SIGALRM"));
75 return STATE_UNKNOWN; 75 return STATE_UNKNOWN;
76 } 76 }
77 alarm (timeout_interval); 77 alarm (timeout_interval);
@@ -97,7 +97,7 @@ main (int argc, char **argv)
97 } 97 }
98 98
99 99
100 /* get results from remote command */ 100 /* build up results from remote command in result_text */
101 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) 101 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process))
102 asprintf (&result_text, "%s%s", result_text, input_buffer); 102 asprintf (&result_text, "%s%s", result_text, input_buffer);
103 103
@@ -105,6 +105,8 @@ main (int argc, char **argv)
105 /* WARNING if output found on stderr */ 105 /* WARNING if output found on stderr */
106 if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { 106 if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
107 printf ("%s\n", input_buffer); 107 printf ("%s\n", input_buffer);
108 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process))
109 printf ("%s\n", input_buffer);
108 return STATE_WARNING; 110 return STATE_WARNING;
109 } 111 }
110 (void) fclose (child_stderr); 112 (void) fclose (child_stderr);
@@ -122,10 +124,10 @@ main (int argc, char **argv)
122 exit (STATE_UNKNOWN); 124 exit (STATE_UNKNOWN);
123 } 125 }
124 126
125 time (&local_time); 127 local_time = time (NULL);
126 commands = 0; 128 commands = 0;
127 while (result_text && strlen(result_text) > 0) { 129 while (result_text && strlen(result_text) > 0) {
128 status_text = strstr (result_text, _("STATUS CODE: ")); 130 status_text = strstr (result_text, "STATUS CODE: ");
129 if (status_text == NULL) { 131 if (status_text == NULL) {
130 printf ("%s", result_text); 132 printf ("%s", result_text);
131 return result; 133 return result;
@@ -136,7 +138,7 @@ main (int argc, char **argv)
136 if (eol != NULL) 138 if (eol != NULL)
137 eol[0] = 0; 139 eol[0] = 0;
138 if (service[commands] && status_text 140 if (service[commands] && status_text
139 && sscanf (status_text, _("STATUS CODE: %d"), &cresult) == 1) { 141 && sscanf (status_text, "STATUS CODE: %d", &cresult) == 1) {
140 fprintf (fp, _("[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n"), 142 fprintf (fp, _("[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n"),
141 (int) local_time, host_shortname, service[commands++], cresult, 143 (int) local_time, host_shortname, service[commands++], cresult,
142 output); 144 output);
@@ -145,6 +147,7 @@ main (int argc, char **argv)
145 147
146 } 148 }
147 149
150
148 /* print the first line from the remote command */ 151 /* print the first line from the remote command */
149 else { 152 else {
150 eol = strpbrk (result_text, "\r\n"); 153 eol = strpbrk (result_text, "\r\n");
@@ -153,7 +156,8 @@ main (int argc, char **argv)
153 printf ("%s\n", result_text); 156 printf ("%s\n", result_text);
154 } 157 }
155 158
156 /* return error status from remote command */ 159
160 /* return error status from remote command */
157 return result; 161 return result;
158} 162}
159 163
@@ -222,7 +226,8 @@ process_arguments (int argc, char **argv)
222 case 't': /* timeout period */ 226 case 't': /* timeout period */
223 if (!is_integer (optarg)) 227 if (!is_integer (optarg))
224 usage2 (_("timeout interval must be an integer"), optarg); 228 usage2 (_("timeout interval must be an integer"), optarg);
225 timeout_interval = atoi (optarg); 229 else
230 timeout_interval = atoi (optarg);
226 break; 231 break;
227 case 'H': /* host */ 232 case 'H': /* host */
228 if (!is_host (optarg)) 233 if (!is_host (optarg))
@@ -382,6 +387,8 @@ execute additional commands as proxy\n"));
382To use passive mode, provide multiple '-C' options, and provide\n\ 387To use passive mode, provide multiple '-C' options, and provide\n\
383all of -O, -s, and -n options (servicelist order must match '-C'\n\ 388all of -O, -s, and -n options (servicelist order must match '-C'\n\
384options)\n")); 389options)\n"));
390
391 printf (_(UT_SUPPORT));
385} 392}
386 393
387 394