summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_nt.c170
-rw-r--r--plugins/check_smtp.c188
2 files changed, 186 insertions, 172 deletions
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 85c67531..91022bac 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -64,9 +64,10 @@ int show_all=FALSE;
64const char *progname = "check_nt"; 64const char *progname = "check_nt";
65 65
66int process_arguments(int, char **); 66int process_arguments(int, char **);
67void print_usage(void);
68void print_help(void);
69void preparelist(char *string); 67void preparelist(char *string);
68int strtoularray(unsigned long *array, char *string, char *delim);
69void print_help(void);
70void print_usage(void);
70 71
71int main(int argc, char **argv){ 72int main(int argc, char **argv){
72 int result; 73 int result;
@@ -91,10 +92,10 @@ int main(int argc, char **argv){
91 int uphours=0; 92 int uphours=0;
92 int upminutes=0; 93 int upminutes=0;
93 94
94 asprintf(&req_password,"None"); 95 asprintf(&req_password, _("None"));
95 96
96 if(process_arguments(argc,argv)==ERROR) 97 if(process_arguments(argc,argv)==ERROR)
97 usage("Could not parse arguments\n"); 98 usage(_("Could not parse arguments\n"));
98 99
99 /* initialize alarm signal handling */ 100 /* initialize alarm signal handling */
100 signal(SIGALRM,socket_timeout_alarm_handler); 101 signal(SIGALRM,socket_timeout_alarm_handler);
@@ -116,15 +117,15 @@ int main(int argc, char **argv){
116 else if(vars_to_check==CHECK_CPULOAD){ 117 else if(vars_to_check==CHECK_CPULOAD){
117 118
118 if (check_value_list==TRUE) { 119 if (check_value_list==TRUE) {
119 if (strtolarray(&lvalue_list,value_list,",")==TRUE) { 120 if (strtoularray(&lvalue_list,value_list,",")==TRUE) {
120 /* -l parameters is present with only integers */ 121 /* -l parameters is present with only integers */
121 return_code=STATE_OK; 122 return_code=STATE_OK;
122 asprintf(&temp_string,"CPU Load"); 123 asprintf(&temp_string,_("CPU Load"));
123 while (lvalue_list[0+offset]>(unsigned long)0 && 124 while (lvalue_list[0+offset]> (unsigned long)0 &&
124 lvalue_list[0+offset]<=(unsigned long)17280 && 125 lvalue_list[0+offset]<=(unsigned long)17280 &&
125 lvalue_list[1+offset]>=(unsigned long)0 && 126 lvalue_list[1+offset]> (unsigned long)0 &&
126 lvalue_list[1+offset]<=(unsigned long)100 && 127 lvalue_list[1+offset]<=(unsigned long)100 &&
127 lvalue_list[2+offset]>=(unsigned long)0 && 128 lvalue_list[2+offset]> (unsigned long)0 &&
128 lvalue_list[2+offset]<=(unsigned long)100) { 129 lvalue_list[2+offset]<=(unsigned long)100) {
129 /* loop until one of the parameters is wrong or not present */ 130 /* loop until one of the parameters is wrong or not present */
130 131
@@ -147,7 +148,7 @@ int main(int argc, char **argv){
147 else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING) 148 else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING)
148 return_code=STATE_WARNING; 149 return_code=STATE_WARNING;
149 150
150 asprintf(&output_message," %lu%% (%lu min average)", utilization, lvalue_list[0+offset]); 151 asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]);
151 asprintf(&temp_string,"%s%s",temp_string,output_message); 152 asprintf(&temp_string,"%s%s",temp_string,output_message);
152 offset+=3; /* move across the array */ 153 offset+=3; /* move across the array */
153 } 154 }
@@ -156,13 +157,13 @@ int main(int argc, char **argv){
156 asprintf(&output_message,"%s",temp_string); 157 asprintf(&output_message,"%s",temp_string);
157 } 158 }
158 else 159 else
159 asprintf(&output_message,"%s","not enough values for -l parameters"); 160 asprintf(&output_message,"%s",_("not enough values for -l parameters"));
160 161
161 } else 162 } else
162 asprintf(&output_message,"wrong -l parameter."); 163 asprintf(&output_message,_("wrong -l parameter."));
163 164
164 } else 165 } else
165 asprintf(&output_message,"missing -l parameters"); 166 asprintf(&output_message,_("missing -l parameters"));
166 } 167 }
167 168
168 else if(vars_to_check==CHECK_UPTIME){ 169 else if(vars_to_check==CHECK_UPTIME){
@@ -181,7 +182,7 @@ int main(int argc, char **argv){
181 updays = uptime / 86400; 182 updays = uptime / 86400;
182 uphours = (uptime % 86400) / 3600; 183 uphours = (uptime % 86400) / 3600;
183 upminutes = ((uptime % 86400) % 3600) / 60; 184 upminutes = ((uptime % 86400) % 3600) / 60;
184 asprintf(&output_message,"System Uptime : %u day(s) %u hour(s) %u minute(s)",updays,uphours, upminutes); 185 asprintf(&output_message,_("System Uptime : %u day(s) %u hour(s) %u minute(s)"),updays,uphours, upminutes);
185 return_code=STATE_OK; 186 return_code=STATE_OK;
186 } 187 }
187 188
@@ -205,7 +206,7 @@ int main(int argc, char **argv){
205 percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100; 206 percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
206 207
207 if (free_disk_space>=0) { 208 if (free_disk_space>=0) {
208 asprintf(&temp_string,"%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)", 209 asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
209 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, percent_used_space, 210 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, percent_used_space,
210 free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100); 211 free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
211 212
@@ -221,14 +222,14 @@ int main(int argc, char **argv){
221 222
222 } 223 }
223 else { 224 else {
224 asprintf(&output_message,"Free disk space : Invalid drive "); 225 asprintf(&output_message,_("Free disk space : Invalid drive "));
225 return_code=STATE_UNKNOWN; 226 return_code=STATE_UNKNOWN;
226 } 227 }
227 } 228 }
228 else 229 else
229 asprintf(&output_message,"wrong -l argument"); 230 asprintf(&output_message,_("wrong -l argument"));
230 } else 231 } else
231 asprintf(&output_message,"missing -l parameters"); 232 asprintf(&output_message,_("missing -l parameters"));
232 233
233 } 234 }
234 235
@@ -237,7 +238,7 @@ int main(int argc, char **argv){
237 if (check_value_list==TRUE) { 238 if (check_value_list==TRUE) {
238 preparelist(value_list); /* replace , between services with & to send the request */ 239 preparelist(value_list); /* replace , between services with & to send the request */
239 asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6, 240 asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
240 (show_all==TRUE)?"ShowAll":"ShowFail",value_list); 241 (show_all==TRUE)?_("ShowAll"):_("ShowFail"),value_list);
241 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); 242 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
242 if(result!=STATE_OK) 243 if(result!=STATE_OK)
243 return result; 244 return result;
@@ -251,7 +252,7 @@ int main(int argc, char **argv){
251 asprintf(&output_message, "%s",temp_string); 252 asprintf(&output_message, "%s",temp_string);
252 } 253 }
253 else 254 else
254 asprintf(&output_message,"No service/process specified"); 255 asprintf(&output_message,_("No service/process specified"));
255 } 256 }
256 257
257 else if(vars_to_check==CHECK_MEMUSE) { 258 else if(vars_to_check==CHECK_MEMUSE) {
@@ -269,7 +270,7 @@ int main(int argc, char **argv){
269 mem_commitLimit=atof(strtok(recv_buffer,"&")); 270 mem_commitLimit=atof(strtok(recv_buffer,"&"));
270 mem_commitByte=atof(strtok(NULL,"&")); 271 mem_commitByte=atof(strtok(NULL,"&"));
271 percent_used_space = (mem_commitByte / mem_commitLimit) * 100; 272 percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
272 asprintf(&output_message,"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)", 273 asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"),
273 mem_commitLimit / 1048576, mem_commitByte / 1048567, percent_used_space, 274 mem_commitLimit / 1048576, mem_commitByte / 1048567, percent_used_space,
274 (mem_commitLimit - mem_commitByte) / 1048576, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100); 275 (mem_commitLimit - mem_commitByte) / 1048576, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
275 276
@@ -325,7 +326,7 @@ int main(int argc, char **argv){
325 326
326 } 327 }
327 else { 328 else {
328 asprintf(&output_message,"No counter specified"); 329 asprintf(&output_message,_("No counter specified"));
329 result=STATE_UNKNOWN; 330 result=STATE_UNKNOWN;
330 } 331 }
331 } 332 }
@@ -368,7 +369,7 @@ int main(int argc, char **argv){
368 369
369 } 370 }
370 else { 371 else {
371 asprintf(&output_message,"No file specified"); 372 asprintf(&output_message,_("No file specified"));
372 result=STATE_UNKNOWN; 373 result=STATE_UNKNOWN;
373 } 374 }
374 } 375 }
@@ -382,6 +383,10 @@ int main(int argc, char **argv){
382} 383}
383 384
384 385
386
387
388
389
385/* process command-line arguments */ 390/* process command-line arguments */
386int process_arguments(int argc, char **argv){ 391int process_arguments(int argc, char **argv){
387 int c; 392 int c;
@@ -448,7 +453,7 @@ int process_arguments(int argc, char **argv){
448 if (is_intnonneg(optarg)) 453 if (is_intnonneg(optarg))
449 server_port=atoi(optarg); 454 server_port=atoi(optarg);
450 else 455 else
451 die(STATE_UNKNOWN,"Server port an integer (seconds)\nType '%s -h' for additional help\n",progname); 456 die(STATE_UNKNOWN,_("Server port an integer (seconds)\nType '%s -h' for additional help\n"),progname);
452 break; 457 break;
453 case 'v': 458 case 'v':
454 if(strlen(optarg)<4) 459 if(strlen(optarg)<4)
@@ -505,21 +510,53 @@ int process_arguments(int argc, char **argv){
505} 510}
506 511
507 512
508void print_usage(void) 513
509{ 514
510 printf("Usage: %s -H host -v variable [-p port] [-w warning] [-c critical] [-l params] [-d SHOWALL] [-t timeout]\n",progname); 515
516
517int strtoularray(unsigned long *array, char *string, char *delim) {
518 /* split a <delim> delimited string into a long array */
519 int idx=0;
520 char *t1;
521
522 for (idx=0;idx<MAX_VALUE_LIST;idx++)
523 array[idx]=0;
524
525 idx=0;
526 for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
527 if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
528 array[idx]=strtoul(t1,NULL,10);
529 idx++;
530 } else
531 return FALSE;
532 }
533 return TRUE;
511} 534}
512 535
536void preparelist(char *string) {
537 /* Replace all , with & which is the delimiter for the request */
538 int i;
513 539
540 for (i = 0; (size_t)i < strlen(string); i++)
541 if (string[i] == ',') {
542 string[i]='&';
543 }
544}
545
546
547
548
549
550
514void print_help(void) 551void print_help(void)
515{ 552{
516 print_revision(progname,"$Revision$"); 553 print_revision(progname,"$Revision$");
517 printf ("\ 554 printf (_("\
518Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n\n\ 555Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n\n\
519This plugin collects data from the NSClient service running on a\n\ 556This plugin collects data from the NSClient service running on a\n\
520Windows NT/2000/XP server.\n\n"); 557Windows NT/2000/XP server.\n\n"));
521 print_usage(); 558 print_usage();
522 printf ("\nOptions:\n\ 559 printf (_("\nOptions:\n\
523-H, --hostname=HOST\n\ 560-H, --hostname=HOST\n\
524 Name of the host to check\n\ 561 Name of the host to check\n\
525-p, --port=INTEGER\n\ 562-p, --port=INTEGER\n\
@@ -535,40 +572,40 @@ Windows NT/2000/XP server.\n\n");
535-h, --help\n\ 572-h, --help\n\
536 Print this help screen\n\ 573 Print this help screen\n\
537-V, --version\n\ 574-V, --version\n\
538 Print version information\n", 575 Print version information\n"),
539 PORT, DEFAULT_SOCKET_TIMEOUT); 576 PORT, DEFAULT_SOCKET_TIMEOUT);
540 printf ("\ 577 printf (_("\
541-v, --variable=STRING\n\ 578-v, --variable=STRING\n\
542 Variable to check. Valid variables are:\n"); 579 Variable to check. Valid variables are:\n"));
543 printf ("\ 580 printf (_("\
544 CLIENTVERSION = Get the NSClient version\n"); 581 CLIENTVERSION = Get the NSClient version\n"));
545 printf ("\ 582 printf (_("\
546 CPULOAD = Average CPU load on last x minutes.\n\ 583 CPULOAD = Average CPU load on last x minutes.\n\
547 Request a -l parameter with the following syntax:\n\ 584 Request a -l parameter with the following syntax:\n\
548 -l <minutes range>,<warning threshold>,<critical threshold>.\n\ 585 -l <minutes range>,<warning threshold>,<critical threshold>.\n\
549 <minute range> should be less than 24*60.\n\ 586 <minute range> should be less than 24*60.\n\
550 Thresholds are percentage and up to 10 requests can be done in one shot.\n\ 587 Thresholds are percentage and up to 10 requests can be done in one shot.\n\
551 ie: -l 60,90,95,120,90,95\n"); 588 ie: -l 60,90,95,120,90,95\n"));
552 printf ("\ 589 printf (_("\
553 UPTIME = Get the uptime of the machine.\n\ 590 UPTIME = Get the uptime of the machine.\n\
554 No specific parameters. No warning or critical threshold\n"); 591 No specific parameters. No warning or critical threshold\n"));
555 printf ("\ 592 printf (_("\
556 USEDDISKSPACE = Size and percentage of disk use.\n\ 593 USEDDISKSPACE = Size and percentage of disk use.\n\
557 Request a -l parameter containing the drive letter only.\n\ 594 Request a -l parameter containing the drive letter only.\n\
558 Warning and critical thresholds can be specified with -w and -c.\n"); 595 Warning and critical thresholds can be specified with -w and -c.\n"));
559 printf ("\ 596 printf (_("\
560 MEMUSE = Memory use.\n\ 597 MEMUSE = Memory use.\n\
561 Warning and critical thresholds can be specified with -w and -c.\n"); 598 Warning and critical thresholds can be specified with -w and -c.\n"));
562 printf ("\ 599 printf (_("\
563 SERVICESTATE = Check the state of one or several services.\n\ 600 SERVICESTATE = Check the state of one or several services.\n\
564 Request a -l parameters with the following syntax:\n\ 601 Request a -l parameters with the following syntax:\n\
565 -l <service1>,<service2>,<service3>,...\n\ 602 -l <service1>,<service2>,<service3>,...\n\
566 You can specify -d SHOWALL in case you want to see working services\n\ 603 You can specify -d SHOWALL in case you want to see working services\n\
567 in the returned string.\n"); 604 in the returned string.\n"));
568 printf ("\ 605 printf (_("\
569 PROCSTATE = Check if one or several process are running.\n\ 606 PROCSTATE = Check if one or several process are running.\n\
570 Same syntax as SERVICESTATE.\n"); 607 Same syntax as SERVICESTATE.\n"));
571 printf ("\ 608 printf (_("\
572 COUNTER = Check any performance counter of Windows NT/2000.\n\ 609 COUNTER = Check any performance counter of Windows NT/2000.\n\
573 Request a -l parameters with the following syntax:\n\ 610 Request a -l parameters with the following syntax:\n\
574 -l \"\\\\<performance object>\\\\counter\",\"<description>\n\ 611 -l \"\\\\<performance object>\\\\counter\",\"<description>\n\
@@ -576,39 +613,20 @@ Windows NT/2000/XP server.\n\n");
576 is given to a printf output command which require a float parameters.\n\ 613 is given to a printf output command which require a float parameters.\n\
577 Some examples:\n\ 614 Some examples:\n\
578 \"Paging file usage is %%.2f %%%%\"\n\ 615 \"Paging file usage is %%.2f %%%%\"\n\
579 \"%%.f %%%% paging file used.\"\n"); 616 \"%%.f %%%% paging file used.\"\n"));
580 printf ("Notes:\n\ 617 printf (_("Notes:\n\
581 - The NSClient service should be running on the server to get any information\n\ 618 - The NSClient service should be running on the server to get any information\n\
582 (http://nsclient.ready2run.nl).\n\ 619 (http://nsclient.ready2run.nl).\n\
583 - Critical thresholds should be lower than warning thresholds\n"); 620 - Critical thresholds should be lower than warning thresholds\n"));
584} 621}
585 622
586int strtolarray(unsigned long *array, char *string, char *delim) {
587 /* split a <delim> delimited string into a long array */
588 int idx=0;
589 char *t1;
590 623
591 for (idx=0;idx<MAX_VALUE_LIST;idx++)
592 array[idx]=-1;
593
594 idx=0;
595 for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
596 if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
597 array[idx]=strtoul(t1,NULL,10);
598 idx++;
599 } else
600 return FALSE;
601 }
602 return TRUE;
603}
604 624
605void preparelist(char *string) {
606 /* Replace all , with & which is the delimiter for the request */
607 int i;
608 625
609 for (i = 0; (size_t)i < strlen(string); i++) 626void print_usage(void)
610 if (string[i] == ',') { 627{
611 string[i]='&'; 628 printf(_("\
612 } 629Usage: %s -H host -v variable [-p port] [-w warning] [-c critical]\n\
630 [-l params] [-d SHOWALL] [-t timeout]\n"), progname);
631 printf (_(UT_HLP_VRS), progname, progname);
613} 632}
614
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 7562c4c6..f7c826b2 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -1,70 +1,29 @@
1/****************************************************************************** 1/******************************************************************************
2* 2
3* This program is free software; you can redistribute it and/or modify 3 This program is free software; you can redistribute it and/or modify
4* it under the terms of the GNU General Public License as published by 4 it under the terms of the GNU General Public License as published by
5* the Free Software Foundation; either version 2 of the License, or 5 the Free Software Foundation; either version 2 of the License, or
6* (at your option) any later version. 6 (at your option) any later version.
7* 7
8* This program is distributed in the hope that it will be useful, 8 This program is distributed in the hope that it will be useful,
9* but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details. 11 GNU General Public License for more details.
12* 12
13* You should have received a copy of the GNU General Public License 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 14 along with this program; if not, write to the Free Software
15* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16* 16
17*****************************************************************************/ 17******************************************************************************/
18 18
19const char *progname = "check_smtp"; 19const char *progname = "check_smtp";
20const char *revision = "$Revision$"; 20const char *revision = "$Revision$";
21const char *copyright = "1999-2003"; 21const char *copyright = "2000-2003";
22const char *authors = "Nagios Plugin Development Team";
23const char *email = "nagiosplug-devel@lists.sourceforge.net"; 22const char *email = "nagiosplug-devel@lists.sourceforge.net";
24 23
25const char *summary = "\ 24#include "common.h"
26This plugin will attempt to open an SMTP connection with the host.\n"; 25#include "netutils.h"
27 26#include "utils.h"
28const char *description = "\
29Successul connects return STATE_OK, refusals and timeouts return\n\
30STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful\n\
31connects, but incorrect reponse messages from the host result in\n\
32STATE_WARNING return values.\n";
33
34const char *option_summary = "\
35-H host [-p port] [-e expect] [-C command] [-f from addr]\n\
36 [-w warn] [-c crit] [-t timeout] [-n] [-v] [-4|-6]";
37
38const char *options = "\
39 -H, --hostname=STRING or IPADDRESS\n\
40 Check server on the indicated host\n\
41 -4, --use-ipv4\n\
42 Use IPv4 protocol\n\
43 -6, --use-ipv6\n\
44 Use IPv6 protocol\n\
45 -p, --port=INTEGER\n\
46 Make connection on the indicated port (default: %d)\n\
47 -e, --expect=STRING\n\
48 String to expect in first line of server response (default: '%s')\n\
49 -n, nocommand\n\
50 Suppress SMTP command\n\
51 -C, --command=STRING\n\
52 SMTP command (default: '%s')\n\
53 -f, --from=STRING\n\
54 FROM-address to include in MAIL command, required by Exchange 2000\n\
55 (default: '%s')\n\
56 -w, --warning=INTEGER\n\
57 Seconds necessary to result in a warning status\n\
58 -c, --critical=INTEGER\n\
59 Seconds necessary to result in a critical status\n\
60 -t, --timeout=INTEGER\n\
61 Seconds before connection attempt times out (default: %d)\n\
62 -v, --verbose\n\
63 Print extra information (command-line use only)\n\
64 -h, --help\n\
65 Print detailed help screen\n\
66 -V, --version\n\
67 Print version information\n\n";
68 27
69enum { 28enum {
70 SMTP_PORT = 25 29 SMTP_PORT = 25
@@ -73,11 +32,6 @@ const char *SMTP_EXPECT = "220";
73const char *SMTP_HELO = "HELO "; 32const char *SMTP_HELO = "HELO ";
74const char *SMTP_QUIT = "QUIT\r\n"; 33const char *SMTP_QUIT = "QUIT\r\n";
75 34
76#include "config.h"
77#include "common.h"
78#include "netutils.h"
79#include "utils.h"
80
81int process_arguments (int, char **); 35int process_arguments (int, char **);
82int validate_arguments (void); 36int validate_arguments (void);
83void print_help (void); 37void print_help (void);
@@ -95,6 +49,11 @@ int critical_time = 0;
95int check_critical_time = FALSE; 49int check_critical_time = FALSE;
96int verbose = 0; 50int verbose = 0;
97 51
52
53
54
55
56
98int 57int
99main (int argc, char **argv) 58main (int argc, char **argv)
100{ 59{
@@ -107,7 +66,7 @@ main (int argc, char **argv)
107 struct timeval tv; 66 struct timeval tv;
108 67
109 if (process_arguments (argc, argv) != OK) 68 if (process_arguments (argc, argv) != OK)
110 usage ("Invalid command arguments supplied\n"); 69 usage (_("Invalid command arguments supplied\n"));
111 70
112 /* initialize the HELO command with the localhostname */ 71 /* initialize the HELO command with the localhostname */
113#ifndef HOST_MAX_BYTES 72#ifndef HOST_MAX_BYTES
@@ -141,7 +100,7 @@ main (int argc, char **argv)
141 /* watch for the SMTP connection string and */ 100 /* watch for the SMTP connection string and */
142 /* return a WARNING status if we couldn't read any data */ 101 /* return a WARNING status if we couldn't read any data */
143 if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) == -1) { 102 if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) == -1) {
144 printf ("recv() failed\n"); 103 printf (_("recv() failed\n"));
145 result = STATE_WARNING; 104 result = STATE_WARNING;
146 } 105 }
147 else { 106 else {
@@ -150,9 +109,9 @@ main (int argc, char **argv)
150 /* make sure we find the response we are looking for */ 109 /* make sure we find the response we are looking for */
151 if (!strstr (buffer, server_expect)) { 110 if (!strstr (buffer, server_expect)) {
152 if (server_port == SMTP_PORT) 111 if (server_port == SMTP_PORT)
153 printf ("Invalid SMTP response received from host\n"); 112 printf (_("Invalid SMTP response received from host\n"));
154 else 113 else
155 printf ("Invalid SMTP response received from host on port %d\n", 114 printf (_("Invalid SMTP response received from host on port %d\n"),
156 server_port); 115 server_port);
157 result = STATE_WARNING; 116 result = STATE_WARNING;
158 } 117 }
@@ -182,7 +141,7 @@ main (int argc, char **argv)
182 recv(sd, buffer, MAX_INPUT_BUFFER-1, 0); 141 recv(sd, buffer, MAX_INPUT_BUFFER-1, 0);
183 142
184 if (verbose) 143 if (verbose)
185 printf("DUMMYCMD: %s\n%s\n",from_str,buffer); 144 printf(_("DUMMYCMD: %s\n%s\n"),from_str,buffer);
186 145
187 } /* smtp_use_dummycmd */ 146 } /* smtp_use_dummycmd */
188 147
@@ -204,10 +163,10 @@ main (int argc, char **argv)
204 result = STATE_WARNING; 163 result = STATE_WARNING;
205 164
206 if (verbose) 165 if (verbose)
207 printf ("SMTP %s - %.3f sec. response time, %s|time=%.3f\n", 166 printf (_("SMTP %s - %.3f sec. response time, %s|time=%.3f\n"),
208 state_text (result), elapsed_time, buffer, elapsed_time); 167 state_text (result), elapsed_time, buffer, elapsed_time);
209 else 168 else
210 printf ("SMTP %s - %.3f second response time|time=%.3f\n", 169 printf (_("SMTP %s - %.3f second response time|time=%.3f\n"),
211 state_text (result), elapsed_time, elapsed_time); 170 state_text (result), elapsed_time, elapsed_time);
212 171
213 return result; 172 return result;
@@ -217,7 +176,7 @@ main (int argc, char **argv)
217 176
218 177
219 178
220 179
221/* process command-line arguments */ 180/* process command-line arguments */
222int 181int
223process_arguments (int argc, char **argv) 182process_arguments (int argc, char **argv)
@@ -268,16 +227,14 @@ process_arguments (int argc, char **argv)
268 server_address = optarg; 227 server_address = optarg;
269 } 228 }
270 else { 229 else {
271 usage ("Invalid host name\n"); 230 usage (_("Invalid host name\n"));
272 } 231 }
273 break; 232 break;
274 case 'p': /* port */ 233 case 'p': /* port */
275 if (is_intpos (optarg)) { 234 if (is_intpos (optarg))
276 server_port = atoi (optarg); 235 server_port = atoi (optarg);
277 } 236 else
278 else { 237 usage (_("Server port must be a positive integer\n"));
279 usage ("Server port must be a positive integer\n");
280 }
281 break; 238 break;
282 case 'f': /* from argument */ 239 case 'f': /* from argument */
283 from_arg = optarg; 240 from_arg = optarg;
@@ -298,7 +255,7 @@ process_arguments (int argc, char **argv)
298 check_critical_time = TRUE; 255 check_critical_time = TRUE;
299 } 256 }
300 else { 257 else {
301 usage ("Critical time must be a nonnegative integer\n"); 258 usage (_("Critical time must be a nonnegative integer\n"));
302 } 259 }
303 break; 260 break;
304 case 'w': /* warning time threshold */ 261 case 'w': /* warning time threshold */
@@ -307,7 +264,7 @@ process_arguments (int argc, char **argv)
307 check_warning_time = TRUE; 264 check_warning_time = TRUE;
308 } 265 }
309 else { 266 else {
310 usage ("Warning time must be a nonnegative integer\n"); 267 usage (_("Warning time must be a nonnegative integer\n"));
311 } 268 }
312 break; 269 break;
313 case 'v': /* verbose */ 270 case 'v': /* verbose */
@@ -318,7 +275,7 @@ process_arguments (int argc, char **argv)
318 socket_timeout = atoi (optarg); 275 socket_timeout = atoi (optarg);
319 } 276 }
320 else { 277 else {
321 usage ("Time interval must be a nonnegative integer\n"); 278 usage (_("Time interval must be a nonnegative integer\n"));
322 } 279 }
323 break; 280 break;
324 case '4': 281 case '4':
@@ -328,7 +285,7 @@ process_arguments (int argc, char **argv)
328#ifdef USE_IPV6 285#ifdef USE_IPV6
329 address_family = AF_INET6; 286 address_family = AF_INET6;
330#else 287#else
331 usage ("IPv6 support not available\n"); 288 usage (_("IPv6 support not available\n"));
332#endif 289#endif
333 break; 290 break;
334 case 'V': /* version */ 291 case 'V': /* version */
@@ -338,7 +295,7 @@ process_arguments (int argc, char **argv)
338 print_help (); 295 print_help ();
339 exit (STATE_OK); 296 exit (STATE_OK);
340 case '?': /* help */ 297 case '?': /* help */
341 usage ("Invalid argument\n"); 298 usage (_("Invalid argument\n"));
342 } 299 }
343 } 300 }
344 301
@@ -348,7 +305,7 @@ process_arguments (int argc, char **argv)
348 if (is_host (argv[c])) 305 if (is_host (argv[c]))
349 server_address = argv[c]; 306 server_address = argv[c];
350 else 307 else
351 usage ("Invalid host name"); 308 usage (_("Invalid host name"));
352 } 309 }
353 else { 310 else {
354 asprintf (&server_address, "127.0.0.1"); 311 asprintf (&server_address, "127.0.0.1");
@@ -375,17 +332,53 @@ validate_arguments (void)
375 332
376 333
377 334
335
378void 336void
379print_help (void) 337print_help (void)
380{ 338{
339 char *myport;
340 asprintf (&myport, "%d", SMTP_PORT);
341
381 print_revision (progname, revision); 342 print_revision (progname, revision);
382 printf ("Copyright (c) %s %s\n\t<%s>\n\n%s\n", 343
383 copyright, authors, email, summary); 344 printf (_("Copyright (c) 1999-2001 Ethan Galstad <nagios@nagios.org>\n"));
345 printf (_(COPYRIGHT), copyright, email);
346
347 printf(_("\
348This plugin will attempt to open an SMTP connection with the host.\n\n"));
349
384 print_usage (); 350 print_usage ();
385 printf ("\nOptions:\n"); 351
386 printf (options, SMTP_PORT, SMTP_EXPECT, mail_command, from_arg, 352 printf (_(UT_HELP_VRSN));
387 DEFAULT_SOCKET_TIMEOUT); 353
388 support (); 354 printf (_(UT_HOST_PORT), 'p', myport);
355
356 printf (_(UT_IPv46));
357
358 printf (_("\
359 -e, --expect=STRING\n\
360 String to expect in first line of server response (default: '%s')\n\
361 -n, nocommand\n\
362 Suppress SMTP command\n\
363 -C, --command=STRING\n\
364 SMTP command (default: '%s')\n\
365 -f, --from=STRING\n\
366 FROM-address to include in MAIL command, required by Exchange 2000\n\
367 (default: '%s')\n"), SMTP_EXPECT, mail_command, from_arg);
368
369 printf (_(UT_WARN_CRIT));
370
371 printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
372
373 printf (_(UT_VERBOSE));
374
375 printf(_("\n\
376Successul connects return STATE_OK, refusals and timeouts return\n\
377STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful\n\
378connects, but incorrect reponse messages from the host result in\n\
379STATE_WARNING return values.\n"));
380
381 printf (_(UT_SUPPORT));
389} 382}
390 383
391 384
@@ -395,8 +388,11 @@ print_help (void)
395void 388void
396print_usage (void) 389print_usage (void)
397{ 390{
398 printf ("Usage: %s %s\n" 391 printf ("\
399 " %s --help\n" 392Usage: %s -H host [-p port] [-e expect] [-C command] [-f from addr]\n\
400 " %s --version\n", 393 [-w warn] [-c crit] [-t timeout] [-n] [-v] [-4|-6]\n", progname);
401 progname, option_summary, progname, progname); 394 printf (_(UT_HLP_VRS), progname, progname);
402} 395}
396
397
398