[Nagiosplug-checkins] nagiosplug/plugins-root check_dhcp.c,1.2,1.3
Ethan Galstad
egalstad at users.sourceforge.net
Thu May 25 09:54:15 CEST 2006
Update of /cvsroot/nagiosplug/nagiosplug/plugins-root
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17553
Modified Files:
check_dhcp.c
Log Message:
Fixed short interface name length, UNKNOWN return code (patches from tracker)
Index: check_dhcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-root/check_dhcp.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- check_dhcp.c 18 May 2006 22:05:43 -0000 1.2
+++ check_dhcp.c 25 May 2006 16:53:42 -0000 1.3
@@ -5,6 +5,7 @@
* Program: DHCP plugin for Nagios
* License: GPL
* Copyright (c) 2001-2004 Ethan Galstad (nagios at nagios.org)
+* Copyright (c) 2001-2006 Nagios Plugin Development Team
*
* License Information:
*
@@ -28,7 +29,7 @@
const char *progname = "check_dhcp";
const char *revision = "$Revision$";
-const char *copyright = "2001-2004";
+const char *copyright = "2001-2006";
const char *email = "nagiosplug-devel at lists.sourceforge.net";
#include "common.h"
@@ -105,11 +106,6 @@
/**** Common definitions ****/
-#define STATE_OK 0
-#define STATE_WARNING 1
-#define STATE_CRITICAL 2
-#define STATE_UNKNOWN -1
-
#define OK 0
#define ERROR -1
@@ -191,7 +187,7 @@
unsigned char client_hardware_address[MAX_DHCP_CHADDR_LENGTH]="";
-char network_interface_name[8]="eth0";
+char network_interface_name[IFNAMSIZ]="eth0";
u_int32_t packet_xid=0;
@@ -240,7 +236,7 @@
int main(int argc, char **argv){
int dhcp_socket;
- int result;
+ int result = STATE_UNKNOWN;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
@@ -920,8 +916,14 @@
else if(request_specific_address==TRUE && received_requested_address==FALSE)
result=STATE_WARNING;
-
- printf("DHCP %s: ",(result==STATE_OK)?"ok":"problem");
+ if(result==0) /* garrett honeycutt 2005 */
+ printf("OK: ");
+ else if(result==1)
+ printf("WARNING: ");
+ else if(result==2)
+ printf("CRITICAL: ");
+ else if(result==3)
+ printf("UNKNOWN: ");
/* we didn't receive any DHCPOFFERs */
if(dhcp_offer_list==NULL){
@@ -1218,13 +1220,17 @@
print_revision(progname,revision);
- printf("Copyright (c) 2001-2004 Ethan Galstad (nagios at nagios.org)\n\n");
+ printf("Copyright (c) 2001-2004 Ethan Galstad (nagios at nagios.org)\n");
printf (COPYRIGHT, copyright, email);
printf(_("This plugin tests the availability of DHCP servers on a network.\n\n"));
print_usage();
+ printf (_(UT_HELP_VRSN));
+
+ printf (_(UT_VERBOSE));
+
printf(_("\
-s, --serverip=IPADDRESS\n\
IP address of DHCP server that we must hear from\n\
@@ -1233,21 +1239,14 @@
-t, --timeout=INTEGER\n\
Seconds to wait for DHCPOFFER before timeout occurs\n\
-i, --interface=STRING\n\
- Interface to to use for listening (i.e. eth0)\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"));
+ Interface to to use for listening (i.e. eth0)\n"));
}
void print_usage(void)
{
printf("\
-Usage: %s [-s serverip] [-r requestedip] [-t timeout] [-i interface]\n\
- [-v]",progname);
+Usage: %s [-s serverip] [-r requestedip] [-t timeout] [-i interface] [-v]\n",progname);
}
More information about the Commits
mailing list