summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ee37af8)
raw | patch | inline | side by side (parent: ee37af8)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 8 Aug 2003 03:51:02 +0000 (03:51 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 8 Aug 2003 03:51:02 +0000 (03:51 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@661 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_nt.c | patch | blob | history | |
plugins/check_smtp.c | patch | blob | history |
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 85c67531faabee25d9ea1e9edfb5b35a141410d6..91022bac9a05bf4a398a6fd992b5c93d27f30d32 100644 (file)
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
const char *progname = "check_nt";
int process_arguments(int, char **);
-void print_usage(void);
-void print_help(void);
void preparelist(char *string);
+int strtoularray(unsigned long *array, char *string, char *delim);
+void print_help(void);
+void print_usage(void);
int main(int argc, char **argv){
int result;
int uphours=0;
int upminutes=0;
- asprintf(&req_password,"None");
+ asprintf(&req_password, _("None"));
if(process_arguments(argc,argv)==ERROR)
- usage("Could not parse arguments\n");
+ usage(_("Could not parse arguments\n"));
/* initialize alarm signal handling */
signal(SIGALRM,socket_timeout_alarm_handler);
else if(vars_to_check==CHECK_CPULOAD){
if (check_value_list==TRUE) {
- if (strtolarray(&lvalue_list,value_list,",")==TRUE) {
+ if (strtoularray(&lvalue_list,value_list,",")==TRUE) {
/* -l parameters is present with only integers */
return_code=STATE_OK;
- asprintf(&temp_string,"CPU Load");
- while (lvalue_list[0+offset]>(unsigned long)0 &&
+ asprintf(&temp_string,_("CPU Load"));
+ while (lvalue_list[0+offset]> (unsigned long)0 &&
lvalue_list[0+offset]<=(unsigned long)17280 &&
- lvalue_list[1+offset]>=(unsigned long)0 &&
+ lvalue_list[1+offset]> (unsigned long)0 &&
lvalue_list[1+offset]<=(unsigned long)100 &&
- lvalue_list[2+offset]>=(unsigned long)0 &&
+ lvalue_list[2+offset]> (unsigned long)0 &&
lvalue_list[2+offset]<=(unsigned long)100) {
/* loop until one of the parameters is wrong or not present */
else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING)
return_code=STATE_WARNING;
- asprintf(&output_message," %lu%% (%lu min average)", utilization, lvalue_list[0+offset]);
+ asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]);
asprintf(&temp_string,"%s%s",temp_string,output_message);
offset+=3; /* move across the array */
}
asprintf(&output_message,"%s",temp_string);
}
else
- asprintf(&output_message,"%s","not enough values for -l parameters");
+ asprintf(&output_message,"%s",_("not enough values for -l parameters"));
} else
- asprintf(&output_message,"wrong -l parameter.");
+ asprintf(&output_message,_("wrong -l parameter."));
} else
- asprintf(&output_message,"missing -l parameters");
+ asprintf(&output_message,_("missing -l parameters"));
}
else if(vars_to_check==CHECK_UPTIME){
updays = uptime / 86400;
uphours = (uptime % 86400) / 3600;
upminutes = ((uptime % 86400) % 3600) / 60;
- asprintf(&output_message,"System Uptime : %u day(s) %u hour(s) %u minute(s)",updays,uphours, upminutes);
+ asprintf(&output_message,_("System Uptime : %u day(s) %u hour(s) %u minute(s)"),updays,uphours, upminutes);
return_code=STATE_OK;
}
percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
if (free_disk_space>=0) {
- asprintf(&temp_string,"%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)",
+ asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, percent_used_space,
free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
}
else {
- asprintf(&output_message,"Free disk space : Invalid drive ");
+ asprintf(&output_message,_("Free disk space : Invalid drive "));
return_code=STATE_UNKNOWN;
}
}
else
- asprintf(&output_message,"wrong -l argument");
+ asprintf(&output_message,_("wrong -l argument"));
} else
- asprintf(&output_message,"missing -l parameters");
+ asprintf(&output_message,_("missing -l parameters"));
}
if (check_value_list==TRUE) {
preparelist(value_list); /* replace , between services with & to send the request */
asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
- (show_all==TRUE)?"ShowAll":"ShowFail",value_list);
+ (show_all==TRUE)?_("ShowAll"):_("ShowFail"),value_list);
result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
if(result!=STATE_OK)
return result;
asprintf(&output_message, "%s",temp_string);
}
else
- asprintf(&output_message,"No service/process specified");
+ asprintf(&output_message,_("No service/process specified"));
}
else if(vars_to_check==CHECK_MEMUSE) {
mem_commitLimit=atof(strtok(recv_buffer,"&"));
mem_commitByte=atof(strtok(NULL,"&"));
percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
- asprintf(&output_message,"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)",
+ asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"),
mem_commitLimit / 1048576, mem_commitByte / 1048567, percent_used_space,
(mem_commitLimit - mem_commitByte) / 1048576, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
}
else {
- asprintf(&output_message,"No counter specified");
+ asprintf(&output_message,_("No counter specified"));
result=STATE_UNKNOWN;
}
}
}
else {
- asprintf(&output_message,"No file specified");
+ asprintf(&output_message,_("No file specified"));
result=STATE_UNKNOWN;
}
}
}
+
+
+
+\f
/* process command-line arguments */
int process_arguments(int argc, char **argv){
int c;
if (is_intnonneg(optarg))
server_port=atoi(optarg);
else
- die(STATE_UNKNOWN,"Server port an integer (seconds)\nType '%s -h' for additional help\n",progname);
+ die(STATE_UNKNOWN,_("Server port an integer (seconds)\nType '%s -h' for additional help\n"),progname);
break;
case 'v':
if(strlen(optarg)<4)
}
-void print_usage(void)
-{
- printf("Usage: %s -H host -v variable [-p port] [-w warning] [-c critical] [-l params] [-d SHOWALL] [-t timeout]\n",progname);
+
+
+
+\f
+int strtoularray(unsigned long *array, char *string, char *delim) {
+ /* split a <delim> delimited string into a long array */
+ int idx=0;
+ char *t1;
+
+ for (idx=0;idx<MAX_VALUE_LIST;idx++)
+ array[idx]=0;
+
+ idx=0;
+ for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
+ if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
+ array[idx]=strtoul(t1,NULL,10);
+ idx++;
+ } else
+ return FALSE;
+ }
+ return TRUE;
}
+void preparelist(char *string) {
+ /* Replace all , with & which is the delimiter for the request */
+ int i;
+ for (i = 0; (size_t)i < strlen(string); i++)
+ if (string[i] == ',') {
+ string[i]='&';
+ }
+}
+
+
+
+
+
+\f
void print_help(void)
{
print_revision(progname,"$Revision$");
- printf ("\
+ printf (_("\
Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n\n\
This plugin collects data from the NSClient service running on a\n\
-Windows NT/2000/XP server.\n\n");
+Windows NT/2000/XP server.\n\n"));
print_usage();
- printf ("\nOptions:\n\
+ printf (_("\nOptions:\n\
-H, --hostname=HOST\n\
Name of the host to check\n\
-p, --port=INTEGER\n\
-h, --help\n\
Print this help screen\n\
-V, --version\n\
- Print version information\n",
+ Print version information\n"),
PORT, DEFAULT_SOCKET_TIMEOUT);
- printf ("\
+ printf (_("\
-v, --variable=STRING\n\
- Variable to check. Valid variables are:\n");
- printf ("\
- CLIENTVERSION = Get the NSClient version\n");
- printf ("\
+ Variable to check. Valid variables are:\n"));
+ printf (_("\
+ CLIENTVERSION = Get the NSClient version\n"));
+ printf (_("\
CPULOAD = Average CPU load on last x minutes.\n\
Request a -l parameter with the following syntax:\n\
-l <minutes range>,<warning threshold>,<critical threshold>.\n\
<minute range> should be less than 24*60.\n\
Thresholds are percentage and up to 10 requests can be done in one shot.\n\
- ie: -l 60,90,95,120,90,95\n");
- printf ("\
+ ie: -l 60,90,95,120,90,95\n"));
+ printf (_("\
UPTIME = Get the uptime of the machine.\n\
- No specific parameters. No warning or critical threshold\n");
- printf ("\
+ No specific parameters. No warning or critical threshold\n"));
+ printf (_("\
USEDDISKSPACE = Size and percentage of disk use.\n\
Request a -l parameter containing the drive letter only.\n\
- Warning and critical thresholds can be specified with -w and -c.\n");
- printf ("\
+ Warning and critical thresholds can be specified with -w and -c.\n"));
+ printf (_("\
MEMUSE = Memory use.\n\
- Warning and critical thresholds can be specified with -w and -c.\n");
- printf ("\
+ Warning and critical thresholds can be specified with -w and -c.\n"));
+ printf (_("\
SERVICESTATE = Check the state of one or several services.\n\
Request a -l parameters with the following syntax:\n\
-l <service1>,<service2>,<service3>,...\n\
You can specify -d SHOWALL in case you want to see working services\n\
- in the returned string.\n");
- printf ("\
+ in the returned string.\n"));
+ printf (_("\
PROCSTATE = Check if one or several process are running.\n\
- Same syntax as SERVICESTATE.\n");
- printf ("\
+ Same syntax as SERVICESTATE.\n"));
+ printf (_("\
COUNTER = Check any performance counter of Windows NT/2000.\n\
Request a -l parameters with the following syntax:\n\
-l \"\\\\<performance object>\\\\counter\",\"<description>\n\
is given to a printf output command which require a float parameters.\n\
Some examples:\n\
\"Paging file usage is %%.2f %%%%\"\n\
- \"%%.f %%%% paging file used.\"\n");
- printf ("Notes:\n\
+ \"%%.f %%%% paging file used.\"\n"));
+ printf (_("Notes:\n\
- The NSClient service should be running on the server to get any information\n\
(http://nsclient.ready2run.nl).\n\
- - Critical thresholds should be lower than warning thresholds\n");
+ - Critical thresholds should be lower than warning thresholds\n"));
}
-int strtolarray(unsigned long *array, char *string, char *delim) {
- /* split a <delim> delimited string into a long array */
- int idx=0;
- char *t1;
- for (idx=0;idx<MAX_VALUE_LIST;idx++)
- array[idx]=-1;
-
- idx=0;
- for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
- if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
- array[idx]=strtoul(t1,NULL,10);
- idx++;
- } else
- return FALSE;
- }
- return TRUE;
-}
-void preparelist(char *string) {
- /* Replace all , with & which is the delimiter for the request */
- int i;
- for (i = 0; (size_t)i < strlen(string); i++)
- if (string[i] == ',') {
- string[i]='&';
- }
+void print_usage(void)
+{
+ printf(_("\
+Usage: %s -H host -v variable [-p port] [-w warning] [-c critical]\n\
+ [-l params] [-d SHOWALL] [-t timeout]\n"), progname);
+ printf (_(UT_HLP_VRS), progname, progname);
}
-
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 7562c4c67550fcd8794ac9cffb5fef624bf2345b..f7c826b2a25729f97e83299cb28eed2884f161cd 100644 (file)
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
/******************************************************************************
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*
-*****************************************************************************/
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+******************************************************************************/
const char *progname = "check_smtp";
const char *revision = "$Revision$";
-const char *copyright = "1999-2003";
-const char *authors = "Nagios Plugin Development Team";
+const char *copyright = "2000-2003";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
-const char *summary = "\
-This plugin will attempt to open an SMTP connection with the host.\n";
-
-const char *description = "\
-Successul connects return STATE_OK, refusals and timeouts return\n\
-STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful\n\
-connects, but incorrect reponse messages from the host result in\n\
-STATE_WARNING return values.\n";
-
-const char *option_summary = "\
--H host [-p port] [-e expect] [-C command] [-f from addr]\n\
- [-w warn] [-c crit] [-t timeout] [-n] [-v] [-4|-6]";
-
-const char *options = "\
- -H, --hostname=STRING or IPADDRESS\n\
- Check server on the indicated host\n\
- -4, --use-ipv4\n\
- Use IPv4 protocol\n\
- -6, --use-ipv6\n\
- Use IPv6 protocol\n\
- -p, --port=INTEGER\n\
- Make connection on the indicated port (default: %d)\n\
- -e, --expect=STRING\n\
- String to expect in first line of server response (default: '%s')\n\
- -n, nocommand\n\
- Suppress SMTP command\n\
- -C, --command=STRING\n\
- SMTP command (default: '%s')\n\
- -f, --from=STRING\n\
- FROM-address to include in MAIL command, required by Exchange 2000\n\
- (default: '%s')\n\
- -w, --warning=INTEGER\n\
- Seconds necessary to result in a warning status\n\
- -c, --critical=INTEGER\n\
- Seconds necessary to result in a critical status\n\
- -t, --timeout=INTEGER\n\
- Seconds before connection attempt times out (default: %d)\n\
- -v, --verbose\n\
- Print extra information (command-line use only)\n\
- -h, --help\n\
- Print detailed help screen\n\
- -V, --version\n\
- Print version information\n\n";
+#include "common.h"
+#include "netutils.h"
+#include "utils.h"
enum {
SMTP_PORT = 25
const char *SMTP_HELO = "HELO ";
const char *SMTP_QUIT = "QUIT\r\n";
-#include "config.h"
-#include "common.h"
-#include "netutils.h"
-#include "utils.h"
-
int process_arguments (int, char **);
int validate_arguments (void);
void print_help (void);
int check_critical_time = FALSE;
int verbose = 0;
+
+
+
+
+\f
int
main (int argc, char **argv)
{
struct timeval tv;
if (process_arguments (argc, argv) != OK)
- usage ("Invalid command arguments supplied\n");
+ usage (_("Invalid command arguments supplied\n"));
/* initialize the HELO command with the localhostname */
#ifndef HOST_MAX_BYTES
/* watch for the SMTP connection string and */
/* return a WARNING status if we couldn't read any data */
if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) == -1) {
- printf ("recv() failed\n");
+ printf (_("recv() failed\n"));
result = STATE_WARNING;
}
else {
/* make sure we find the response we are looking for */
if (!strstr (buffer, server_expect)) {
if (server_port == SMTP_PORT)
- printf ("Invalid SMTP response received from host\n");
+ printf (_("Invalid SMTP response received from host\n"));
else
- printf ("Invalid SMTP response received from host on port %d\n",
+ printf (_("Invalid SMTP response received from host on port %d\n"),
server_port);
result = STATE_WARNING;
}
recv(sd, buffer, MAX_INPUT_BUFFER-1, 0);
if (verbose)
- printf("DUMMYCMD: %s\n%s\n",from_str,buffer);
+ printf(_("DUMMYCMD: %s\n%s\n"),from_str,buffer);
} /* smtp_use_dummycmd */
result = STATE_WARNING;
if (verbose)
- printf ("SMTP %s - %.3f sec. response time, %s|time=%.3f\n",
+ printf (_("SMTP %s - %.3f sec. response time, %s|time=%.3f\n"),
state_text (result), elapsed_time, buffer, elapsed_time);
else
- printf ("SMTP %s - %.3f second response time|time=%.3f\n",
+ printf (_("SMTP %s - %.3f second response time|time=%.3f\n"),
state_text (result), elapsed_time, elapsed_time);
return result;
-
+\f
/* process command-line arguments */
int
process_arguments (int argc, char **argv)
server_address = optarg;
}
else {
- usage ("Invalid host name\n");
+ usage (_("Invalid host name\n"));
}
break;
case 'p': /* port */
- if (is_intpos (optarg)) {
+ if (is_intpos (optarg))
server_port = atoi (optarg);
- }
- else {
- usage ("Server port must be a positive integer\n");
- }
+ else
+ usage (_("Server port must be a positive integer\n"));
break;
case 'f': /* from argument */
from_arg = optarg;
check_critical_time = TRUE;
}
else {
- usage ("Critical time must be a nonnegative integer\n");
+ usage (_("Critical time must be a nonnegative integer\n"));
}
break;
case 'w': /* warning time threshold */
check_warning_time = TRUE;
}
else {
- usage ("Warning time must be a nonnegative integer\n");
+ usage (_("Warning time must be a nonnegative integer\n"));
}
break;
case 'v': /* verbose */
socket_timeout = atoi (optarg);
}
else {
- usage ("Time interval must be a nonnegative integer\n");
+ usage (_("Time interval must be a nonnegative integer\n"));
}
break;
case '4':
#ifdef USE_IPV6
address_family = AF_INET6;
#else
- usage ("IPv6 support not available\n");
+ usage (_("IPv6 support not available\n"));
#endif
break;
case 'V': /* version */
print_help ();
exit (STATE_OK);
case '?': /* help */
- usage ("Invalid argument\n");
+ usage (_("Invalid argument\n"));
}
}
if (is_host (argv[c]))
server_address = argv[c];
else
- usage ("Invalid host name");
+ usage (_("Invalid host name"));
}
else {
asprintf (&server_address, "127.0.0.1");
+\f
void
print_help (void)
{
+ char *myport;
+ asprintf (&myport, "%d", SMTP_PORT);
+
print_revision (progname, revision);
- printf ("Copyright (c) %s %s\n\t<%s>\n\n%s\n",
- copyright, authors, email, summary);
+
+ printf (_("Copyright (c) 1999-2001 Ethan Galstad <nagios@nagios.org>\n"));
+ printf (_(COPYRIGHT), copyright, email);
+
+ printf(_("\
+This plugin will attempt to open an SMTP connection with the host.\n\n"));
+
print_usage ();
- printf ("\nOptions:\n");
- printf (options, SMTP_PORT, SMTP_EXPECT, mail_command, from_arg,
- DEFAULT_SOCKET_TIMEOUT);
- support ();
+
+ printf (_(UT_HELP_VRSN));
+
+ printf (_(UT_HOST_PORT), 'p', myport);
+
+ printf (_(UT_IPv46));
+
+ printf (_("\
+ -e, --expect=STRING\n\
+ String to expect in first line of server response (default: '%s')\n\
+ -n, nocommand\n\
+ Suppress SMTP command\n\
+ -C, --command=STRING\n\
+ SMTP command (default: '%s')\n\
+ -f, --from=STRING\n\
+ FROM-address to include in MAIL command, required by Exchange 2000\n\
+ (default: '%s')\n"), SMTP_EXPECT, mail_command, from_arg);
+
+ printf (_(UT_WARN_CRIT));
+
+ printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+
+ printf (_(UT_VERBOSE));
+
+ printf(_("\n\
+Successul connects return STATE_OK, refusals and timeouts return\n\
+STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful\n\
+connects, but incorrect reponse messages from the host result in\n\
+STATE_WARNING return values.\n"));
+
+ printf (_(UT_SUPPORT));
}
void
print_usage (void)
{
- printf ("Usage: %s %s\n"
- " %s --help\n"
- " %s --version\n",
- progname, option_summary, progname, progname);
+ printf ("\
+Usage: %s -H host [-p port] [-e expect] [-C command] [-f from addr]\n\
+ [-w warn] [-c crit] [-t timeout] [-n] [-v] [-4|-6]\n", progname);
+ printf (_(UT_HLP_VRS), progname, progname);
}
+
+
+