summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorBenoit Mortier <opensides@users.sourceforge.net>2004-12-25 12:09:20 (GMT)
committerBenoit Mortier <opensides@users.sourceforge.net>2004-12-25 12:09:20 (GMT)
commit4014207f5d49948557da313513cfcb2f5e3f0a7c (patch)
tree1df68b9cabb3f76219db9dab4d69cb400ec68793 /plugins
parentd8de534e9fa654b3211497bd62b421e2edd8e9c1 (diff)
downloadmonitoring-plugins-4014207f5d49948557da313513cfcb2f5e3f0a7c.tar.gz
internationalization of check_dhcp
internationalization fixes of check_ssh git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1058 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_by_ssh.c4
-rw-r--r--plugins/check_dhcp.c225
2 files changed, 106 insertions, 123 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index f31c9c6..2ceee28 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -213,9 +213,7 @@ process_arguments (int argc, char **argv)
213 213
214 switch (c) { 214 switch (c) {
215 case '?': /* help */ 215 case '?': /* help */
216 printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); 216 usage2 (_("Unknown argument"), optarg);
217 print_usage ();
218 exit (STATE_UNKNOWN);
219 case 'V': /* version */ 217 case 'V': /* version */
220 print_revision (progname, revision); 218 print_revision (progname, revision);
221 exit (STATE_OK); 219 exit (STATE_OK);
diff --git a/plugins/check_dhcp.c b/plugins/check_dhcp.c
index 623636c..1a16d3e 100644
--- a/plugins/check_dhcp.c
+++ b/plugins/check_dhcp.c
@@ -22,8 +22,15 @@
22* along with this program; if not, write to the Free Software 22* along with this program; if not, write to the Free Software
23* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24* 24*
25* $Id$
26*
25*****************************************************************************/ 27*****************************************************************************/
26 28
29const char *progname = "check_dhcp";
30const char *revision = "$Revision$";
31const char *copyright = "2001-2004";
32const char *email = "nagiosplug-devel@lists.sourceforge.net";
33
27#include "common.h" 34#include "common.h"
28#include "netutils.h" 35#include "netutils.h"
29#include "utils.h" 36#include "utils.h"
@@ -94,8 +101,6 @@ long mac_addr_dlpi( const char *, int, u_char *);
94 101
95#endif 102#endif
96 103
97const char *progname = "check_dhcp";
98
99#define HAVE_GETOPT_H 104#define HAVE_GETOPT_H
100 105
101 106
@@ -238,12 +243,13 @@ int main(int argc, char **argv){
238 int dhcp_socket; 243 int dhcp_socket;
239 int result; 244 int result;
240 245
246 setlocale (LC_ALL, "");
247 bindtextdomain (PACKAGE, LOCALEDIR);
248 textdomain (PACKAGE);
249
241 if(process_arguments(argc,argv)!=OK){ 250 if(process_arguments(argc,argv)!=OK){
242 /*usage("Invalid command arguments supplied\n");*/ 251 usage4 (_("Could not parse arguments"));
243 printf("Invalid command arguments supplied\n"); 252 }
244 exit(STATE_UNKNOWN);
245 }
246
247 253
248 /* create socket for DHCP communications */ 254 /* create socket for DHCP communications */
249 dhcp_socket=create_dhcp_socket(); 255 dhcp_socket=create_dhcp_socket();
@@ -284,7 +290,7 @@ int get_hardware_address(int sock,char *interface_name){
284 290
285 /* try and grab hardware address of requested interface */ 291 /* try and grab hardware address of requested interface */
286 if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){ 292 if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){
287 printf("Error: Could not get hardware address of interface '%s'\n",interface_name); 293 printf(_("Error: Could not get hardware address of interface '%s'\n"),interface_name);
288 exit(STATE_UNKNOWN); 294 exit(STATE_UNKNOWN);
289 } 295 }
290 296
@@ -306,22 +312,22 @@ int get_hardware_address(int sock,char *interface_name){
306 mib[4] = NET_RT_IFLIST; 312 mib[4] = NET_RT_IFLIST;
307 313
308 if ((mib[5] = if_nametoindex(interface_name)) == 0) { 314 if ((mib[5] = if_nametoindex(interface_name)) == 0) {
309 printf("Error: if_nametoindex error - %s.\n", strerror(errno)); 315 printf(_("Error: if_nametoindex error - %s.\n"), strerror(errno));
310 exit(STATE_UNKNOWN); 316 exit(STATE_UNKNOWN);
311 } 317 }
312 318
313 if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) { 319 if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
314 printf("Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n", interface_name, strerror(errno)); 320 printf(_("Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"), interface_name, strerror(errno));
315 exit(STATE_UNKNOWN); 321 exit(STATE_UNKNOWN);
316 } 322 }
317 323
318 if ((buf = malloc(len)) == NULL) { 324 if ((buf = malloc(len)) == NULL) {
319 printf("Error: Couldn't get hardware address from interface %s. malloc error - %s.\n", interface_name, strerror(errno)); 325 printf(_("Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"), interface_name, strerror(errno));
320 exit(4); 326 exit(4);
321 } 327 }
322 328
323 if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) { 329 if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
324 printf("Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n", interface_name, strerror(errno)); 330 printf(_("Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"), interface_name, strerror(errno));
325 exit(STATE_UNKNOWN); 331 exit(STATE_UNKNOWN);
326 } 332 }
327 333
@@ -346,12 +352,12 @@ int get_hardware_address(int sock,char *interface_name){
346 *p = '\0' ; 352 *p = '\0' ;
347 strncat(dev, interface_name, 6) ; 353 strncat(dev, interface_name, 6) ;
348 } else { 354 } else {
349 printf("Error: can't find unit number in interface_name (%s) - expecting TypeNumber eg lnc0.\n", interface_name); 355 printf(_("Error: can't find unit number in interface_name (%s) - expecting TypeNumber eg lnc0.\n"), interface_name);
350 exit(STATE_UNKNOWN); 356 exit(STATE_UNKNOWN);
351 } 357 }
352 stat = mac_addr_dlpi(dev, unit, client_hardware_address); 358 stat = mac_addr_dlpi(dev, unit, client_hardware_address);
353 if (stat != 0) { 359 if (stat != 0) {
354 printf("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n", dev, unit); 360 printf(_("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n"), dev, unit);
355 exit(STATE_UNKNOWN); 361 exit(STATE_UNKNOWN);
356 } 362 }
357 363
@@ -363,18 +369,18 @@ int get_hardware_address(int sock,char *interface_name){
363 369
364 stat = mac_addr_dlpi(dev, unit, client_hardware_address); 370 stat = mac_addr_dlpi(dev, unit, client_hardware_address);
365 if (stat != 0) { 371 if (stat != 0) {
366 printf("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n", dev, unit); 372 printf(_("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n"), dev, unit);
367 exit(STATE_UNKNOWN); 373 exit(STATE_UNKNOWN);
368 } 374 }
369 /* Kompf 2000-2003 */ 375 /* Kompf 2000-2003 */
370 376
371#else 377#else
372 printf("Error: can't get MAC address for this architecture.\n"); 378 printf(_("Error: can't get MAC address for this architecture.\n"));
373 exit(STATE_UNKNOWN); 379 exit(STATE_UNKNOWN);
374#endif 380#endif
375 381
376 if (verbose) { 382 if (verbose) {
377 printf( "Hardware address: "); 383 printf(_("Hardware address: "));
378 for (i=0; i<6; ++i) 384 for (i=0; i<6; ++i)
379 printf("%2.2x", client_hardware_address[i]); 385 printf("%2.2x", client_hardware_address[i]);
380 printf( "\n"); 386 printf( "\n");
@@ -449,7 +455,7 @@ int send_dhcp_discover(int sock){
449 455
450 456
451 if (verbose) { 457 if (verbose) {
452 printf("DHCPDISCOVER to %s port %d\n",inet_ntoa(sockaddr_broadcast.sin_addr),ntohs(sockaddr_broadcast.sin_port)); 458 printf(_("DHCPDISCOVER to %s port %d\n"),inet_ntoa(sockaddr_broadcast.sin_addr),ntohs(sockaddr_broadcast.sin_port));
453 printf("DHCPDISCOVER XID: %lu (0x%X)\n",ntohl(discover_packet.xid),ntohl(discover_packet.xid)); 459 printf("DHCPDISCOVER XID: %lu (0x%X)\n",ntohl(discover_packet.xid),ntohl(discover_packet.xid));
454 printf("DHCDISCOVER ciaddr: %s\n",inet_ntoa(discover_packet.ciaddr)); 460 printf("DHCDISCOVER ciaddr: %s\n",inet_ntoa(discover_packet.ciaddr));
455 printf("DHCDISCOVER yiaddr: %s\n",inet_ntoa(discover_packet.yiaddr)); 461 printf("DHCDISCOVER yiaddr: %s\n",inet_ntoa(discover_packet.yiaddr));
@@ -500,26 +506,26 @@ int get_dhcp_offer(int sock){
500 506
501 if(result!=OK){ 507 if(result!=OK){
502 if (verbose) 508 if (verbose)
503 printf("Result=ERROR\n"); 509 printf(_("Result=ERROR\n"));
504 510
505 continue; 511 continue;
506 } 512 }
507 else{ 513 else{
508 if (verbose) 514 if (verbose)
509 printf("Result=OK\n"); 515 printf(_("Result=OK\n"));
510 516
511 responses++; 517 responses++;
512 } 518 }
513 519
514 if (verbose) { 520 if (verbose) {
515 printf("DHCPOFFER from IP address %s\n",inet_ntoa(source.sin_addr)); 521 printf(_("DHCPOFFER from IP address %s\n"),inet_ntoa(source.sin_addr));
516 printf("DHCPOFFER XID: %lu (0x%X)\n",ntohl(offer_packet.xid),ntohl(offer_packet.xid)); 522 printf("DHCPOFFER XID: %lu (0x%X)\n",ntohl(offer_packet.xid),ntohl(offer_packet.xid));
517 } 523 }
518 524
519 /* check packet xid to see if its the same as the one we used in the discover packet */ 525 /* check packet xid to see if its the same as the one we used in the discover packet */
520 if(ntohl(offer_packet.xid)!=packet_xid){ 526 if(ntohl(offer_packet.xid)!=packet_xid){
521 if (verbose) 527 if (verbose)
522 printf("DHCPOFFER XID (%lu) did not match DHCPDISCOVER XID (%lu) - ignoring packet\n",ntohl(offer_packet.xid),packet_xid); 528 printf(_("DHCPOFFER XID (%lu) did not match DHCPDISCOVER XID (%lu) - ignoring packet\n"),ntohl(offer_packet.xid),packet_xid);
523 529
524 continue; 530 continue;
525 } 531 }
@@ -541,7 +547,7 @@ int get_dhcp_offer(int sock){
541 547
542 if(result==ERROR){ 548 if(result==ERROR){
543 if (verbose) 549 if (verbose)
544 printf("DHCPOFFER hardware address did not match our own - ignoring packet\n"); 550 printf(_("DHCPOFFER hardware address did not match our own - ignoring packet\n"));
545 551
546 continue; 552 continue;
547 } 553 }
@@ -559,8 +565,8 @@ int get_dhcp_offer(int sock){
559 } 565 }
560 566
561 if (verbose) { 567 if (verbose) {
562 printf("Total responses seen on the wire: %d\n",responses); 568 printf(_("Total responses seen on the wire: %d\n"),responses);
563 printf("Valid responses for this machine: %d\n",valid_responses); 569 printf(_("Valid responses for this machine: %d\n"),valid_responses);
564 } 570 }
565 571
566 return OK; 572 return OK;
@@ -576,7 +582,7 @@ int send_dhcp_packet(void *buffer, int buffer_size, int sock, struct sockaddr_in
576 result=sendto(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)dest,sizeof(*dest)); 582 result=sendto(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)dest,sizeof(*dest));
577 583
578 if (verbose) 584 if (verbose)
579 printf("send_dhcp_packet result: %d\n",result); 585 printf(_("send_dhcp_packet result: %d\n"),result);
580 586
581 if(result<0) 587 if(result<0)
582 return ERROR; 588 return ERROR;
@@ -605,7 +611,7 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st
605 /* make sure some data has arrived */ 611 /* make sure some data has arrived */
606 if(!FD_ISSET(sock,&readfds)){ 612 if(!FD_ISSET(sock,&readfds)){
607 if (verbose) 613 if (verbose)
608 printf("No (more) data received\n"); 614 printf(_("No (more) data received\n"));
609 return ERROR; 615 return ERROR;
610 } 616 }
611 617
@@ -624,15 +630,15 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st
624 630
625 if(recv_result==-1){ 631 if(recv_result==-1){
626 if (verbose) { 632 if (verbose) {
627 printf("recvfrom() failed, "); 633 printf(_("recvfrom() failed, "));
628 printf("errno: (%d) -> %s\n",errno,strerror(errno)); 634 printf("errno: (%d) -> %s\n",errno,strerror(errno));
629 } 635 }
630 return ERROR; 636 return ERROR;
631 } 637 }
632 else{ 638 else{
633 if (verbose) { 639 if (verbose) {
634 printf("receive_dhcp_packet() result: %d\n",recv_result); 640 printf(_("receive_dhcp_packet() result: %d\n"),recv_result);
635 printf("receive_dhcp_packet() source: %s\n",inet_ntoa(source_address.sin_addr)); 641 printf(_("receive_dhcp_packet() source: %s\n"),inet_ntoa(source_address.sin_addr));
636 } 642 }
637 643
638 memcpy(address,&source_address,sizeof(source_address)); 644 memcpy(address,&source_address,sizeof(source_address));
@@ -644,7 +650,6 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st
644 } 650 }
645 651
646 652
647
648/* creates a socket for DHCP communication */ 653/* creates a socket for DHCP communication */
649int create_dhcp_socket(void){ 654int create_dhcp_socket(void){
650 struct sockaddr_in myname; 655 struct sockaddr_in myname;
@@ -662,7 +667,7 @@ int create_dhcp_socket(void){
662 /* create a socket for DHCP communications */ 667 /* create a socket for DHCP communications */
663 sock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP); 668 sock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
664 if(sock<0){ 669 if(sock<0){
665 printf("Error: Could not create socket!\n"); 670 printf(_("Error: Could not create socket!\n"));
666 exit(STATE_UNKNOWN); 671 exit(STATE_UNKNOWN);
667 } 672 }
668 673
@@ -672,13 +677,13 @@ int create_dhcp_socket(void){
672 /* set the reuse address flag so we don't get errors when restarting */ 677 /* set the reuse address flag so we don't get errors when restarting */
673 flag=1; 678 flag=1;
674 if(setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(char *)&flag,sizeof(flag))<0){ 679 if(setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(char *)&flag,sizeof(flag))<0){
675 printf("Error: Could not set reuse address option on DHCP socket!\n"); 680 printf(_("Error: Could not set reuse address option on DHCP socket!\n"));
676 exit(STATE_UNKNOWN); 681 exit(STATE_UNKNOWN);
677 } 682 }
678 683
679 /* set the broadcast option - we need this to listen to DHCP broadcast messages */ 684 /* set the broadcast option - we need this to listen to DHCP broadcast messages */
680 if(setsockopt(sock,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof flag)<0){ 685 if(setsockopt(sock,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof flag)<0){
681 printf("Error: Could not set broadcast option on DHCP socket!\n"); 686 printf(_("Error: Could not set broadcast option on DHCP socket!\n"));
682 exit(STATE_UNKNOWN); 687 exit(STATE_UNKNOWN);
683 } 688 }
684 689
@@ -686,7 +691,7 @@ int create_dhcp_socket(void){
686#if defined(__linux__) 691#if defined(__linux__)
687 strncpy(interface.ifr_ifrn.ifrn_name,network_interface_name,IFNAMSIZ); 692 strncpy(interface.ifr_ifrn.ifrn_name,network_interface_name,IFNAMSIZ);
688 if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){ 693 if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){
689 printf("Error: Could not bind socket to interface %s. Check your privileges...\n",network_interface_name); 694 printf(_("Error: Could not bind socket to interface %s. Check your privileges...\n"),network_interface_name);
690 exit(STATE_UNKNOWN); 695 exit(STATE_UNKNOWN);
691 } 696 }
692 697
@@ -696,7 +701,7 @@ int create_dhcp_socket(void){
696 701
697 /* bind the socket */ 702 /* bind the socket */
698 if(bind(sock,(struct sockaddr *)&myname,sizeof(myname))<0){ 703 if(bind(sock,(struct sockaddr *)&myname,sizeof(myname))<0){
699 printf("Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n",DHCP_CLIENT_PORT); 704 printf(_("Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n"),DHCP_CLIENT_PORT);
700 exit(STATE_UNKNOWN); 705 exit(STATE_UNKNOWN);
701 } 706 }
702 707
@@ -704,9 +709,6 @@ int create_dhcp_socket(void){
704 } 709 }
705 710
706 711
707
708
709
710/* closes DHCP socket */ 712/* closes DHCP socket */
711int close_dhcp_socket(int sock){ 713int close_dhcp_socket(int sock){
712 714
@@ -716,8 +718,6 @@ int close_dhcp_socket(int sock){
716 } 718 }
717 719
718 720
719
720
721/* adds a requested server address to list in memory */ 721/* adds a requested server address to list in memory */
722int add_requested_server(struct in_addr server_address){ 722int add_requested_server(struct in_addr server_address){
723 requested_server *new_server; 723 requested_server *new_server;
@@ -734,7 +734,7 @@ int add_requested_server(struct in_addr server_address){
734 requested_servers++; 734 requested_servers++;
735 735
736 if (verbose) 736 if (verbose)
737 printf("Requested server address: %s\n",inet_ntoa(new_server->server_address)); 737 printf(_("Requested server address: %s\n"),inet_ntoa(new_server->server_address));
738 738
739 return OK; 739 return OK;
740 } 740 }
@@ -784,16 +784,16 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
784 784
785 if (verbose) { 785 if (verbose) {
786 if(dhcp_lease_time==DHCP_INFINITE_TIME) 786 if(dhcp_lease_time==DHCP_INFINITE_TIME)
787 printf("Lease Time: Infinite\n"); 787 printf(_("Lease Time: Infinite\n"));
788 else 788 else
789 printf("Lease Time: %lu seconds\n",(unsigned long)dhcp_lease_time); 789 printf(_("Lease Time: %lu seconds\n"),(unsigned long)dhcp_lease_time);
790 if(dhcp_renewal_time==DHCP_INFINITE_TIME) 790 if(dhcp_renewal_time==DHCP_INFINITE_TIME)
791 printf("Renewal Time: Infinite\n"); 791 printf(_("Renewal Time: Infinite\n"));
792 else 792 else
793 printf("Renewal Time: %lu seconds\n",(unsigned long)dhcp_renewal_time); 793 printf(_("Renewal Time: %lu seconds\n"),(unsigned long)dhcp_renewal_time);
794 if(dhcp_rebinding_time==DHCP_INFINITE_TIME) 794 if(dhcp_rebinding_time==DHCP_INFINITE_TIME)
795 printf("Rebinding Time: Infinite\n"); 795 printf(_("Rebinding Time: Infinite\n"));
796 printf("Rebinding Time: %lu seconds\n",(unsigned long)dhcp_rebinding_time); 796 printf(_("Rebinding Time: %lu seconds\n"),(unsigned long)dhcp_rebinding_time);
797 } 797 }
798 798
799 new_offer=(dhcp_offer *)malloc(sizeof(dhcp_offer)); 799 new_offer=(dhcp_offer *)malloc(sizeof(dhcp_offer));
@@ -801,7 +801,6 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
801 if(new_offer==NULL) 801 if(new_offer==NULL)
802 return ERROR; 802 return ERROR;
803 803
804
805 new_offer->server_address=source; 804 new_offer->server_address=source;
806 new_offer->offered_address=offer_packet->yiaddr; 805 new_offer->offered_address=offer_packet->yiaddr;
807 new_offer->lease_time=dhcp_lease_time; 806 new_offer->lease_time=dhcp_lease_time;
@@ -810,8 +809,8 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
810 809
811 810
812 if (verbose) { 811 if (verbose) {
813 printf("Added offer from server @ %s",inet_ntoa(new_offer->server_address)); 812 printf(_("Added offer from server @ %s"),inet_ntoa(new_offer->server_address));
814 printf(" of IP address %s\n",inet_ntoa(new_offer->offered_address)); 813 printf(_(" of IP address %s\n"),inet_ntoa(new_offer->offered_address));
815 } 814 }
816 815
817 /* add new offer to head of list */ 816 /* add new offer to head of list */
@@ -822,8 +821,6 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
822 } 821 }
823 822
824 823
825
826
827/* frees memory allocated to DHCP OFFER list */ 824/* frees memory allocated to DHCP OFFER list */
828int free_dhcp_offer_list(void){ 825int free_dhcp_offer_list(void){
829 dhcp_offer *this_offer; 826 dhcp_offer *this_offer;
@@ -838,8 +835,6 @@ int free_dhcp_offer_list(void){
838 } 835 }
839 836
840 837
841
842
843/* frees memory allocated to requested server list */ 838/* frees memory allocated to requested server list */
844int free_requested_server_list(void){ 839int free_requested_server_list(void){
845 requested_server *this_server; 840 requested_server *this_server;
@@ -882,8 +877,8 @@ int get_results(void){
882 /* see if the servers we wanted a response from talked to us or not */ 877 /* see if the servers we wanted a response from talked to us or not */
883 if(!memcmp(&temp_offer->server_address,&temp_server->server_address,sizeof(temp_server->server_address))){ 878 if(!memcmp(&temp_offer->server_address,&temp_server->server_address,sizeof(temp_server->server_address))){
884 if (verbose) { 879 if (verbose) {
885 printf("DHCP Server Match: Offerer=%s",inet_ntoa(temp_offer->server_address)); 880 printf(_("DHCP Server Match: Offerer=%s"),inet_ntoa(temp_offer->server_address));
886 printf(" Requested=%s\n",inet_ntoa(temp_server->server_address)); 881 printf(_(" Requested=%s\n"),inet_ntoa(temp_server->server_address));
887 } 882 }
888 requested_responses++; 883 requested_responses++;
889 } 884 }
@@ -922,21 +917,21 @@ int get_results(void){
922 917
923 /* we didn't receive any DHCPOFFERs */ 918 /* we didn't receive any DHCPOFFERs */
924 if(dhcp_offer_list==NULL){ 919 if(dhcp_offer_list==NULL){
925 printf("No DHCPOFFERs were received.\n"); 920 printf(_("No DHCPOFFERs were received.\n"));
926 return result; 921 return result;
927 } 922 }
928 923
929 printf("Received %d DHCPOFFER(s)",valid_responses); 924 printf(_("Received %d DHCPOFFER(s)"),valid_responses);
930 925
931 if(requested_servers>0) 926 if(requested_servers>0)
932 printf(", %s%d of %d requested servers responded",((requested_responses<requested_servers) && requested_responses>0)?"only ":"",requested_responses,requested_servers); 927 printf(_(", %s%d of %d requested servers responded"),((requested_responses<requested_servers) && requested_responses>0)?"only ":"",requested_responses,requested_servers);
933 928
934 if(request_specific_address==TRUE) 929 if(request_specific_address==TRUE)
935 printf(", requested address (%s) was %soffered",inet_ntoa(requested_address),(received_requested_address==TRUE)?"":"not "); 930 printf(_(", requested address (%s) was %soffered"),inet_ntoa(requested_address),(received_requested_address==TRUE)?"":"not ");
936 931
937 printf(", max lease time = "); 932 printf(_(", max lease time = "));
938 if(max_lease_time==DHCP_INFINITE_TIME) 933 if(max_lease_time==DHCP_INFINITE_TIME)
939 printf("Infinity"); 934 printf(_("Infinity"));
940 else 935 else
941 printf("%lu sec",(unsigned long)max_lease_time); 936 printf("%lu sec",(unsigned long)max_lease_time);
942 937
@@ -946,57 +941,6 @@ int get_results(void){
946 } 941 }
947 942
948 943
949
950
951
952
953/* print usage help */
954void print_help(void){
955
956 /*print_revision(progname,"$Revision$");*/
957
958 printf("Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)\n\n");
959 printf("This plugin tests the availability of DHCP servers on a network.\n\n");
960
961 print_usage();
962
963 printf
964 ("\nOptions:\n"
965 " -s, --serverip=IPADDRESS\n"
966 " IP address of DHCP server that we must hear from\n"
967 " -r, --requestedip=IPADDRESS\n"
968 " IP address that should be offered by at least one DHCP server\n"
969 " -t, --timeout=INTEGER\n"
970 " Seconds to wait for DHCPOFFER before timeout occurs\n"
971 " -i, --interface=STRING\n"
972 " Interface to to use for listening (i.e. eth0)\n"
973 " -v, --verbose\n"
974 " Print extra information (command-line use only)\n"
975 " -h, --help\n"
976 " Print detailed help screen\n"
977 " -V, --version\n"
978 " Print version information\n\n"
979 );
980
981 /*support();*/
982
983 return;
984 }
985
986
987/* prints usage information */
988void print_usage(void){
989
990 printf("Usage: %s [-s serverip] [-r requestedip] [-t timeout] [-i interface]\n",progname);
991 printf(" %s --help\n",progname);
992 printf(" %s --version\n",progname);
993
994 return;
995 }
996
997
998
999
1000/* process command-line arguments */ 944/* process command-line arguments */
1001int process_arguments(int argc, char **argv){ 945int process_arguments(int argc, char **argv){
1002 int c; 946 int c;
@@ -1174,7 +1118,7 @@ static int check_ctrl(int prim)
1174{ 1118{
1175 dl_error_ack_t *err_ack = (dl_error_ack_t *)ctl_area; 1119 dl_error_ack_t *err_ack = (dl_error_ack_t *)ctl_area;
1176 if(err_ack->dl_primitive != prim) { 1120 if(err_ack->dl_primitive != prim) {
1177 printf("Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n", strerror(errno)); 1121 printf(_("Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n"), strerror(errno));
1178 exit(STATE_UNKNOWN); 1122 exit(STATE_UNKNOWN);
1179 } 1123 }
1180 return 0; 1124 return 0;
@@ -1185,7 +1129,7 @@ static int put_ctrl(int fd, int len, int pri)
1185{ 1129{
1186 ctl.len = len; 1130 ctl.len = len;
1187 if(putmsg(fd, &ctl, 0, pri) < 0) { 1131 if(putmsg(fd, &ctl, 0, pri) < 0) {
1188 printf("Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n", strerror(errno)); 1132 printf(_("Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"), strerror(errno));
1189 exit(STATE_UNKNOWN); 1133 exit(STATE_UNKNOWN);
1190 } 1134 }
1191 return 0; 1135 return 0;
@@ -1197,7 +1141,7 @@ static int put_both(int fd, int clen, int dlen, int pri)
1197 ctl.len = clen; 1141 ctl.len = clen;
1198 dat.len = dlen; 1142 dat.len = dlen;
1199 if(putmsg(fd, &ctl, &dat, pri) < 0) { 1143 if(putmsg(fd, &ctl, &dat, pri) < 0) {
1200 printf("Error: DLPI stream API failed to get MAC in put_both/putmsg().\n", strerror(errno)); 1144 printf(_("Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"), strerror(errno));
1201 exit(STATE_UNKNOWN); 1145 exit(STATE_UNKNOWN);
1202 } 1146 }
1203 return 0; 1147 return 0;
@@ -1208,7 +1152,7 @@ static int dl_open(const char *dev, int unit, int *fd)
1208{ 1152{
1209 dl_attach_req_t *attach_req = (dl_attach_req_t *)ctl_area; 1153 dl_attach_req_t *attach_req = (dl_attach_req_t *)ctl_area;
1210 if((*fd = open(dev, O_RDWR)) == -1) { 1154 if((*fd = open(dev, O_RDWR)) == -1) {
1211 printf("Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n", dev, strerror(errno)); 1155 printf(_("Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n"), dev, strerror(errno));
1212 exit(STATE_UNKNOWN); 1156 exit(STATE_UNKNOWN);
1213 } 1157 }
1214 attach_req->dl_primitive = DL_ATTACH_REQ; 1158 attach_req->dl_primitive = DL_ATTACH_REQ;
@@ -1232,7 +1176,7 @@ static int dl_bind(int fd, int sap, u_char *addr)
1232 put_ctrl(fd, sizeof(dl_bind_req_t), 0); 1176 put_ctrl(fd, sizeof(dl_bind_req_t), 0);
1233 get_msg(fd); 1177 get_msg(fd);
1234 if (GOT_ERR == check_ctrl(DL_BIND_ACK)) { 1178 if (GOT_ERR == check_ctrl(DL_BIND_ACK)) {
1235 printf("Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n", strerror(errno)); 1179 printf(_("Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n"), strerror(errno));
1236 exit(STATE_UNKNOWN); 1180 exit(STATE_UNKNOWN);
1237 } 1181 }
1238 bcopy((u_char *)bind_ack + bind_ack->dl_addr_offset, addr, 1182 bcopy((u_char *)bind_ack + bind_ack->dl_addr_offset, addr,
@@ -1267,6 +1211,47 @@ long mac_addr_dlpi( const char *dev, int unit, u_char *addr) {
1267 return -1; 1211 return -1;
1268} 1212}
1269 1213
1270#endif
1271 /* Kompf 2000-2003 */ 1214 /* Kompf 2000-2003 */
1272 1215
1216#endif
1217
1218
1219/* print usage help */
1220void print_help(void){
1221
1222 print_revision(progname,revision);
1223
1224 printf("Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)\n\n");
1225 printf (COPYRIGHT, copyright, email);
1226
1227 printf(_("This plugin tests the availability of DHCP servers on a network.\n\n"));
1228
1229 print_usage();
1230
1231 printf(_("\
1232 -s, --serverip=IPADDRESS\n\
1233 IP address of DHCP server that we must hear from\n\
1234 -r, --requestedip=IPADDRESS\n\
1235 IP address that should be offered by at least one DHCP server\n\
1236 -t, --timeout=INTEGER\n\
1237 Seconds to wait for DHCPOFFER before timeout occurs\n\
1238 -i, --interface=STRING\n\
1239 Interface to to use for listening (i.e. eth0)\n\
1240 -v, --verbose\n\
1241 Print extra information (command-line use only)\n\
1242 -h, --help\n\
1243 Print detailed help screen\n\
1244 -V, --version\n\
1245 Print version information\n"));
1246}
1247
1248
1249void print_usage(void)
1250{
1251 printf("\
1252Usage: %s [-s serverip] [-r requestedip] [-t timeout] [-i interface]\n\
1253 [-v]",progname);
1254}
1255
1256
1257