diff options
-rw-r--r-- | plugins-root/check_dhcp.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index 836bafb3..cec44b57 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c | |||
@@ -5,6 +5,7 @@ | |||
5 | * Program: DHCP plugin for Nagios | 5 | * Program: DHCP plugin for Nagios |
6 | * License: GPL | 6 | * License: GPL |
7 | * Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org) | 7 | * Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org) |
8 | * Copyright (c) 2001-2006 Nagios Plugin Development Team | ||
8 | * | 9 | * |
9 | * License Information: | 10 | * License Information: |
10 | * | 11 | * |
@@ -28,7 +29,7 @@ | |||
28 | 29 | ||
29 | const char *progname = "check_dhcp"; | 30 | const char *progname = "check_dhcp"; |
30 | const char *revision = "$Revision$"; | 31 | const char *revision = "$Revision$"; |
31 | const char *copyright = "2001-2004"; | 32 | const char *copyright = "2001-2006"; |
32 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | 33 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; |
33 | 34 | ||
34 | #include "common.h" | 35 | #include "common.h" |
@@ -105,11 +106,6 @@ long mac_addr_dlpi( const char *, int, u_char *); | |||
105 | 106 | ||
106 | /**** Common definitions ****/ | 107 | /**** Common definitions ****/ |
107 | 108 | ||
108 | #define STATE_OK 0 | ||
109 | #define STATE_WARNING 1 | ||
110 | #define STATE_CRITICAL 2 | ||
111 | #define STATE_UNKNOWN -1 | ||
112 | |||
113 | #define OK 0 | 109 | #define OK 0 |
114 | #define ERROR -1 | 110 | #define ERROR -1 |
115 | 111 | ||
@@ -191,7 +187,7 @@ typedef struct requested_server_struct{ | |||
191 | 187 | ||
192 | unsigned char client_hardware_address[MAX_DHCP_CHADDR_LENGTH]=""; | 188 | unsigned char client_hardware_address[MAX_DHCP_CHADDR_LENGTH]=""; |
193 | 189 | ||
194 | char network_interface_name[8]="eth0"; | 190 | char network_interface_name[IFNAMSIZ]="eth0"; |
195 | 191 | ||
196 | u_int32_t packet_xid=0; | 192 | u_int32_t packet_xid=0; |
197 | 193 | ||
@@ -240,7 +236,7 @@ int receive_dhcp_packet(void *,int,int,int,struct sockaddr_in *); | |||
240 | 236 | ||
241 | int main(int argc, char **argv){ | 237 | int main(int argc, char **argv){ |
242 | int dhcp_socket; | 238 | int dhcp_socket; |
243 | int result; | 239 | int result = STATE_UNKNOWN; |
244 | 240 | ||
245 | setlocale (LC_ALL, ""); | 241 | setlocale (LC_ALL, ""); |
246 | bindtextdomain (PACKAGE, LOCALEDIR); | 242 | bindtextdomain (PACKAGE, LOCALEDIR); |
@@ -920,8 +916,14 @@ int get_results(void){ | |||
920 | else if(request_specific_address==TRUE && received_requested_address==FALSE) | 916 | else if(request_specific_address==TRUE && received_requested_address==FALSE) |
921 | result=STATE_WARNING; | 917 | result=STATE_WARNING; |
922 | 918 | ||
923 | 919 | if(result==0) /* garrett honeycutt 2005 */ | |
924 | printf("DHCP %s: ",(result==STATE_OK)?"ok":"problem"); | 920 | printf("OK: "); |
921 | else if(result==1) | ||
922 | printf("WARNING: "); | ||
923 | else if(result==2) | ||
924 | printf("CRITICAL: "); | ||
925 | else if(result==3) | ||
926 | printf("UNKNOWN: "); | ||
925 | 927 | ||
926 | /* we didn't receive any DHCPOFFERs */ | 928 | /* we didn't receive any DHCPOFFERs */ |
927 | if(dhcp_offer_list==NULL){ | 929 | if(dhcp_offer_list==NULL){ |
@@ -1218,13 +1220,17 @@ void print_help(void){ | |||
1218 | 1220 | ||
1219 | print_revision(progname,revision); | 1221 | print_revision(progname,revision); |
1220 | 1222 | ||
1221 | printf("Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)\n\n"); | 1223 | printf("Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)\n"); |
1222 | printf (COPYRIGHT, copyright, email); | 1224 | printf (COPYRIGHT, copyright, email); |
1223 | 1225 | ||
1224 | printf(_("This plugin tests the availability of DHCP servers on a network.\n\n")); | 1226 | printf(_("This plugin tests the availability of DHCP servers on a network.\n\n")); |
1225 | 1227 | ||
1226 | print_usage(); | 1228 | print_usage(); |
1227 | 1229 | ||
1230 | printf (_(UT_HELP_VRSN)); | ||
1231 | |||
1232 | printf (_(UT_VERBOSE)); | ||
1233 | |||
1228 | printf(_("\ | 1234 | printf(_("\ |
1229 | -s, --serverip=IPADDRESS\n\ | 1235 | -s, --serverip=IPADDRESS\n\ |
1230 | IP address of DHCP server that we must hear from\n\ | 1236 | IP address of DHCP server that we must hear from\n\ |
@@ -1233,21 +1239,14 @@ void print_help(void){ | |||
1233 | -t, --timeout=INTEGER\n\ | 1239 | -t, --timeout=INTEGER\n\ |
1234 | Seconds to wait for DHCPOFFER before timeout occurs\n\ | 1240 | Seconds to wait for DHCPOFFER before timeout occurs\n\ |
1235 | -i, --interface=STRING\n\ | 1241 | -i, --interface=STRING\n\ |
1236 | Interface to to use for listening (i.e. eth0)\n\ | 1242 | Interface to to use for listening (i.e. eth0)\n")); |
1237 | -v, --verbose\n\ | ||
1238 | Print extra information (command-line use only)\n\ | ||
1239 | -h, --help\n\ | ||
1240 | Print detailed help screen\n\ | ||
1241 | -V, --version\n\ | ||
1242 | Print version information\n")); | ||
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | 1245 | ||
1246 | void print_usage(void) | 1246 | void print_usage(void) |
1247 | { | 1247 | { |
1248 | printf("\ | 1248 | printf("\ |
1249 | Usage: %s [-s serverip] [-r requestedip] [-t timeout] [-i interface]\n\ | 1249 | Usage: %s [-s serverip] [-r requestedip] [-t timeout] [-i interface] [-v]\n",progname); |
1250 | [-v]",progname); | ||
1251 | } | 1250 | } |
1252 | 1251 | ||
1253 | 1252 | ||