summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d8de534)
raw | patch | inline | side by side (parent: d8de534)
author | Benoit Mortier <opensides@users.sourceforge.net> | |
Sat, 25 Dec 2004 12:09:20 +0000 (12:09 +0000) | ||
committer | Benoit Mortier <opensides@users.sourceforge.net> | |
Sat, 25 Dec 2004 12:09:20 +0000 (12:09 +0000) |
internationalization fixes of check_ssh
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1058 f882894a-f735-0410-b71e-b25c423dba1c
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1058 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_by_ssh.c | patch | blob | history | |
plugins/check_dhcp.c | patch | blob | history |
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index f31c9c61b6984536e7a872030cdd1f1593b6b7a4..2ceee28f85441df7259a0583f4e09e1711559ae8 100644 (file)
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
switch (c) {
case '?': /* help */
- printf (_("%s: Unknown argument: %s\n\n"), progname, optarg);
- print_usage ();
- exit (STATE_UNKNOWN);
+ usage2 (_("Unknown argument"), optarg);
case 'V': /* version */
print_revision (progname, revision);
exit (STATE_OK);
diff --git a/plugins/check_dhcp.c b/plugins/check_dhcp.c
index 623636c89f6e05b3d86f8253e27894fe8642c19f..1a16d3e708c1424a7b1eaf68dad1825f97e6e069 100644 (file)
--- a/plugins/check_dhcp.c
+++ b/plugins/check_dhcp.c
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
+* $Id$
+*
*****************************************************************************/
+const char *progname = "check_dhcp";
+const char *revision = "$Revision$";
+const char *copyright = "2001-2004";
+const char *email = "nagiosplug-devel@lists.sourceforge.net";
+
#include "common.h"
#include "netutils.h"
#include "utils.h"
#endif
-const char *progname = "check_dhcp";
-
#define HAVE_GETOPT_H
int dhcp_socket;
int result;
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+
if(process_arguments(argc,argv)!=OK){
- /*usage("Invalid command arguments supplied\n");*/
- printf("Invalid command arguments supplied\n");
- exit(STATE_UNKNOWN);
- }
-
+ usage4 (_("Could not parse arguments"));
+ }
/* create socket for DHCP communications */
dhcp_socket=create_dhcp_socket();
/* try and grab hardware address of requested interface */
if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){
- printf("Error: Could not get hardware address of interface '%s'\n",interface_name);
+ printf(_("Error: Could not get hardware address of interface '%s'\n"),interface_name);
exit(STATE_UNKNOWN);
}
mib[4] = NET_RT_IFLIST;
if ((mib[5] = if_nametoindex(interface_name)) == 0) {
- printf("Error: if_nametoindex error - %s.\n", strerror(errno));
+ printf(_("Error: if_nametoindex error - %s.\n"), strerror(errno));
exit(STATE_UNKNOWN);
}
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
- printf("Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n", interface_name, strerror(errno));
+ printf(_("Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"), interface_name, strerror(errno));
exit(STATE_UNKNOWN);
}
if ((buf = malloc(len)) == NULL) {
- printf("Error: Couldn't get hardware address from interface %s. malloc error - %s.\n", interface_name, strerror(errno));
+ printf(_("Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"), interface_name, strerror(errno));
exit(4);
}
if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
- printf("Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n", interface_name, strerror(errno));
+ printf(_("Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"), interface_name, strerror(errno));
exit(STATE_UNKNOWN);
}
*p = '\0' ;
strncat(dev, interface_name, 6) ;
} else {
- printf("Error: can't find unit number in interface_name (%s) - expecting TypeNumber eg lnc0.\n", interface_name);
+ printf(_("Error: can't find unit number in interface_name (%s) - expecting TypeNumber eg lnc0.\n"), interface_name);
exit(STATE_UNKNOWN);
}
stat = mac_addr_dlpi(dev, unit, client_hardware_address);
if (stat != 0) {
- printf("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n", dev, unit);
+ printf(_("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n"), dev, unit);
exit(STATE_UNKNOWN);
}
stat = mac_addr_dlpi(dev, unit, client_hardware_address);
if (stat != 0) {
- printf("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n", dev, unit);
+ printf(_("Error: can't read MAC address from DLPI streams interface for device %s unit %d.\n"), dev, unit);
exit(STATE_UNKNOWN);
}
/* Kompf 2000-2003 */
#else
- printf("Error: can't get MAC address for this architecture.\n");
+ printf(_("Error: can't get MAC address for this architecture.\n"));
exit(STATE_UNKNOWN);
#endif
if (verbose) {
- printf( "Hardware address: ");
+ printf(_("Hardware address: "));
for (i=0; i<6; ++i)
printf("%2.2x", client_hardware_address[i]);
printf( "\n");
if (verbose) {
- printf("DHCPDISCOVER to %s port %d\n",inet_ntoa(sockaddr_broadcast.sin_addr),ntohs(sockaddr_broadcast.sin_port));
+ printf(_("DHCPDISCOVER to %s port %d\n"),inet_ntoa(sockaddr_broadcast.sin_addr),ntohs(sockaddr_broadcast.sin_port));
printf("DHCPDISCOVER XID: %lu (0x%X)\n",ntohl(discover_packet.xid),ntohl(discover_packet.xid));
printf("DHCDISCOVER ciaddr: %s\n",inet_ntoa(discover_packet.ciaddr));
printf("DHCDISCOVER yiaddr: %s\n",inet_ntoa(discover_packet.yiaddr));
if(result!=OK){
if (verbose)
- printf("Result=ERROR\n");
+ printf(_("Result=ERROR\n"));
continue;
}
else{
if (verbose)
- printf("Result=OK\n");
+ printf(_("Result=OK\n"));
responses++;
}
if (verbose) {
- printf("DHCPOFFER from IP address %s\n",inet_ntoa(source.sin_addr));
+ printf(_("DHCPOFFER from IP address %s\n"),inet_ntoa(source.sin_addr));
printf("DHCPOFFER XID: %lu (0x%X)\n",ntohl(offer_packet.xid),ntohl(offer_packet.xid));
}
/* check packet xid to see if its the same as the one we used in the discover packet */
if(ntohl(offer_packet.xid)!=packet_xid){
if (verbose)
- printf("DHCPOFFER XID (%lu) did not match DHCPDISCOVER XID (%lu) - ignoring packet\n",ntohl(offer_packet.xid),packet_xid);
+ printf(_("DHCPOFFER XID (%lu) did not match DHCPDISCOVER XID (%lu) - ignoring packet\n"),ntohl(offer_packet.xid),packet_xid);
continue;
}
if(result==ERROR){
if (verbose)
- printf("DHCPOFFER hardware address did not match our own - ignoring packet\n");
+ printf(_("DHCPOFFER hardware address did not match our own - ignoring packet\n"));
continue;
}
}
if (verbose) {
- printf("Total responses seen on the wire: %d\n",responses);
- printf("Valid responses for this machine: %d\n",valid_responses);
+ printf(_("Total responses seen on the wire: %d\n"),responses);
+ printf(_("Valid responses for this machine: %d\n"),valid_responses);
}
return OK;
@@ -576,7 +582,7 @@ int send_dhcp_packet(void *buffer, int buffer_size, int sock, struct sockaddr_in
result=sendto(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)dest,sizeof(*dest));
if (verbose)
- printf("send_dhcp_packet result: %d\n",result);
+ printf(_("send_dhcp_packet result: %d\n"),result);
if(result<0)
return ERROR;
@@ -605,7 +611,7 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st
/* make sure some data has arrived */
if(!FD_ISSET(sock,&readfds)){
if (verbose)
- printf("No (more) data received\n");
+ printf(_("No (more) data received\n"));
return ERROR;
}
@@ -624,15 +630,15 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st
if(recv_result==-1){
if (verbose) {
- printf("recvfrom() failed, ");
+ printf(_("recvfrom() failed, "));
printf("errno: (%d) -> %s\n",errno,strerror(errno));
}
return ERROR;
}
else{
if (verbose) {
- printf("receive_dhcp_packet() result: %d\n",recv_result);
- printf("receive_dhcp_packet() source: %s\n",inet_ntoa(source_address.sin_addr));
+ printf(_("receive_dhcp_packet() result: %d\n"),recv_result);
+ printf(_("receive_dhcp_packet() source: %s\n"),inet_ntoa(source_address.sin_addr));
}
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
}
-
/* creates a socket for DHCP communication */
int create_dhcp_socket(void){
struct sockaddr_in myname;
/* create a socket for DHCP communications */
sock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
if(sock<0){
- printf("Error: Could not create socket!\n");
+ printf(_("Error: Could not create socket!\n"));
exit(STATE_UNKNOWN);
}
/* set the reuse address flag so we don't get errors when restarting */
flag=1;
if(setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(char *)&flag,sizeof(flag))<0){
- printf("Error: Could not set reuse address option on DHCP socket!\n");
+ printf(_("Error: Could not set reuse address option on DHCP socket!\n"));
exit(STATE_UNKNOWN);
}
/* set the broadcast option - we need this to listen to DHCP broadcast messages */
if(setsockopt(sock,SOL_SOCKET,SO_BROADCAST,(char *)&flag,sizeof flag)<0){
- printf("Error: Could not set broadcast option on DHCP socket!\n");
+ printf(_("Error: Could not set broadcast option on DHCP socket!\n"));
exit(STATE_UNKNOWN);
}
#if defined(__linux__)
strncpy(interface.ifr_ifrn.ifrn_name,network_interface_name,IFNAMSIZ);
if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){
- printf("Error: Could not bind socket to interface %s. Check your privileges...\n",network_interface_name);
+ printf(_("Error: Could not bind socket to interface %s. Check your privileges...\n"),network_interface_name);
exit(STATE_UNKNOWN);
}
/* bind the socket */
if(bind(sock,(struct sockaddr *)&myname,sizeof(myname))<0){
- printf("Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n",DHCP_CLIENT_PORT);
+ printf(_("Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n"),DHCP_CLIENT_PORT);
exit(STATE_UNKNOWN);
}
}
-
-
-
/* closes DHCP socket */
int close_dhcp_socket(int sock){
}
-
-
/* adds a requested server address to list in memory */
int add_requested_server(struct in_addr server_address){
requested_server *new_server;
requested_servers++;
if (verbose)
- printf("Requested server address: %s\n",inet_ntoa(new_server->server_address));
+ printf(_("Requested server address: %s\n"),inet_ntoa(new_server->server_address));
return OK;
}
if (verbose) {
if(dhcp_lease_time==DHCP_INFINITE_TIME)
- printf("Lease Time: Infinite\n");
+ printf(_("Lease Time: Infinite\n"));
else
- printf("Lease Time: %lu seconds\n",(unsigned long)dhcp_lease_time);
+ printf(_("Lease Time: %lu seconds\n"),(unsigned long)dhcp_lease_time);
if(dhcp_renewal_time==DHCP_INFINITE_TIME)
- printf("Renewal Time: Infinite\n");
+ printf(_("Renewal Time: Infinite\n"));
else
- printf("Renewal Time: %lu seconds\n",(unsigned long)dhcp_renewal_time);
+ printf(_("Renewal Time: %lu seconds\n"),(unsigned long)dhcp_renewal_time);
if(dhcp_rebinding_time==DHCP_INFINITE_TIME)
- printf("Rebinding Time: Infinite\n");
- printf("Rebinding Time: %lu seconds\n",(unsigned long)dhcp_rebinding_time);
+ printf(_("Rebinding Time: Infinite\n"));
+ printf(_("Rebinding Time: %lu seconds\n"),(unsigned long)dhcp_rebinding_time);
}
new_offer=(dhcp_offer *)malloc(sizeof(dhcp_offer));
if(new_offer==NULL)
return ERROR;
-
new_offer->server_address=source;
new_offer->offered_address=offer_packet->yiaddr;
new_offer->lease_time=dhcp_lease_time;
if (verbose) {
- printf("Added offer from server @ %s",inet_ntoa(new_offer->server_address));
- printf(" of IP address %s\n",inet_ntoa(new_offer->offered_address));
+ printf(_("Added offer from server @ %s"),inet_ntoa(new_offer->server_address));
+ printf(_(" of IP address %s\n"),inet_ntoa(new_offer->offered_address));
}
/* add new offer to head of list */
}
-
-
/* frees memory allocated to DHCP OFFER list */
int free_dhcp_offer_list(void){
dhcp_offer *this_offer;
}
-
-
/* frees memory allocated to requested server list */
int free_requested_server_list(void){
requested_server *this_server;
/* see if the servers we wanted a response from talked to us or not */
if(!memcmp(&temp_offer->server_address,&temp_server->server_address,sizeof(temp_server->server_address))){
if (verbose) {
- printf("DHCP Server Match: Offerer=%s",inet_ntoa(temp_offer->server_address));
- printf(" Requested=%s\n",inet_ntoa(temp_server->server_address));
+ printf(_("DHCP Server Match: Offerer=%s"),inet_ntoa(temp_offer->server_address));
+ printf(_(" Requested=%s\n"),inet_ntoa(temp_server->server_address));
}
requested_responses++;
}
/* we didn't receive any DHCPOFFERs */
if(dhcp_offer_list==NULL){
- printf("No DHCPOFFERs were received.\n");
+ printf(_("No DHCPOFFERs were received.\n"));
return result;
}
- printf("Received %d DHCPOFFER(s)",valid_responses);
+ printf(_("Received %d DHCPOFFER(s)"),valid_responses);
if(requested_servers>0)
- printf(", %s%d of %d requested servers responded",((requested_responses<requested_servers) && requested_responses>0)?"only ":"",requested_responses,requested_servers);
+ printf(_(", %s%d of %d requested servers responded"),((requested_responses<requested_servers) && requested_responses>0)?"only ":"",requested_responses,requested_servers);
if(request_specific_address==TRUE)
- printf(", requested address (%s) was %soffered",inet_ntoa(requested_address),(received_requested_address==TRUE)?"":"not ");
+ printf(_(", requested address (%s) was %soffered"),inet_ntoa(requested_address),(received_requested_address==TRUE)?"":"not ");
- printf(", max lease time = ");
+ printf(_(", max lease time = "));
if(max_lease_time==DHCP_INFINITE_TIME)
- printf("Infinity");
+ printf(_("Infinity"));
else
printf("%lu sec",(unsigned long)max_lease_time);
}
-
-
-
-
-/* print usage help */
-void print_help(void){
-
- /*print_revision(progname,"$Revision$");*/
-
- printf("Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)\n\n");
- printf("This plugin tests the availability of DHCP servers on a network.\n\n");
-
- print_usage();
-
- printf
- ("\nOptions:\n"
- " -s, --serverip=IPADDRESS\n"
- " IP address of DHCP server that we must hear from\n"
- " -r, --requestedip=IPADDRESS\n"
- " IP address that should be offered by at least one DHCP server\n"
- " -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\n"
- );
-
- /*support();*/
-
- return;
- }
-
-
-/* prints usage information */
-void print_usage(void){
-
- printf("Usage: %s [-s serverip] [-r requestedip] [-t timeout] [-i interface]\n",progname);
- printf(" %s --help\n",progname);
- printf(" %s --version\n",progname);
-
- return;
- }
-
-
-
-
/* process command-line arguments */
int process_arguments(int argc, char **argv){
int c;
{
dl_error_ack_t *err_ack = (dl_error_ack_t *)ctl_area;
if(err_ack->dl_primitive != prim) {
- printf("Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n", strerror(errno));
+ printf(_("Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n"), strerror(errno));
exit(STATE_UNKNOWN);
}
return 0;
{
ctl.len = len;
if(putmsg(fd, &ctl, 0, pri) < 0) {
- printf("Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n", strerror(errno));
+ printf(_("Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"), strerror(errno));
exit(STATE_UNKNOWN);
}
return 0;
ctl.len = clen;
dat.len = dlen;
if(putmsg(fd, &ctl, &dat, pri) < 0) {
- printf("Error: DLPI stream API failed to get MAC in put_both/putmsg().\n", strerror(errno));
+ printf(_("Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"), strerror(errno));
exit(STATE_UNKNOWN);
}
return 0;
{
dl_attach_req_t *attach_req = (dl_attach_req_t *)ctl_area;
if((*fd = open(dev, O_RDWR)) == -1) {
- printf("Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n", dev, strerror(errno));
+ printf(_("Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n"), dev, strerror(errno));
exit(STATE_UNKNOWN);
}
attach_req->dl_primitive = DL_ATTACH_REQ;
put_ctrl(fd, sizeof(dl_bind_req_t), 0);
get_msg(fd);
if (GOT_ERR == check_ctrl(DL_BIND_ACK)) {
- printf("Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n", strerror(errno));
+ printf(_("Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n"), strerror(errno));
exit(STATE_UNKNOWN);
}
bcopy((u_char *)bind_ack + bind_ack->dl_addr_offset, addr,
return -1;
}
-#endif
/* Kompf 2000-2003 */
+#endif
+
+
+/* print usage help */
+void print_help(void){
+
+ print_revision(progname,revision);
+
+ printf("Copyright (c) 2001-2004 Ethan Galstad (nagios@nagios.org)\n\n");
+ printf (COPYRIGHT, copyright, email);
+
+ printf(_("This plugin tests the availability of DHCP servers on a network.\n\n"));
+
+ print_usage();
+
+ printf(_("\
+ -s, --serverip=IPADDRESS\n\
+ IP address of DHCP server that we must hear from\n\
+ -r, --requestedip=IPADDRESS\n\
+ IP address that should be offered by at least one DHCP server\n\
+ -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"));
+}
+
+
+void print_usage(void)
+{
+ printf("\
+Usage: %s [-s serverip] [-r requestedip] [-t timeout] [-i interface]\n\
+ [-v]",progname);
+}
+
+
+