[Nagiosplug-checkins] CVS: nagiosplug/plugins check_by_ssh.c,1.16,1.17 check_dig.c,1.16,1.17 check_disk.c,1.35,1.36 check_dns.c,1.19,1.20 check_fping.c,1.8,1.9 check_game.c,1.6,1.7 check_hpjd.c,1.14,1.15 check_http.c,1.43,1.44 check_ldap.c,1.12,1.13 check_load.c,1.10,1.11 check_mrtg.c,1.8,1.9 check_mrtgtraf.c,1.8,1.9 check_mysql.c,1.10,1.11 check_nagios.c,1.9,1.10 check_nt.c,1.16,1.17 check_nwstat.c,1.11,1.12 check_overcr.c,1.6,1.7 check_pgsql.c,1.13,1.14 check_ping.c,1.21,1.22 check_procs.c,1.18,1.19 check_radius.c,1.7,1.8 check_real.c,1.10,1.11 check_smtp.c,1.17,1.18 check_snmp.c,1.33,1.34 check_ssh.c,1.11,1.12 check_swap.c,1.16,1.17 check_tcp.c,1.34,1.35 check_time.c,1.8,1.9 check_udp.c,1.10,1.11 check_ups.c,1.9,1.10 check_users.c,1.7,1.8 negate.c,1.11,1.12 popen.c,1.6,1.7 urlize.c,1.7,1.8

Karl DeBisschop kdebisschop at users.sourceforge.net
Sat Aug 9 23:54:03 CEST 2003


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv18807

Modified Files:
	check_by_ssh.c check_dig.c check_disk.c check_dns.c 
	check_fping.c check_game.c check_hpjd.c check_http.c 
	check_ldap.c check_load.c check_mrtg.c check_mrtgtraf.c 
	check_mysql.c check_nagios.c check_nt.c check_nwstat.c 
	check_overcr.c check_pgsql.c check_ping.c check_procs.c 
	check_radius.c check_real.c check_smtp.c check_snmp.c 
	check_ssh.c check_swap.c check_tcp.c check_time.c check_udp.c 
	check_ups.c check_users.c negate.c popen.c urlize.c 
Log Message:
the last round of pedantic compiler warnings

Index: check_by_ssh.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_by_ssh.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** check_by_ssh.c	8 Aug 2003 05:09:39 -0000	1.16
--- check_by_ssh.c	10 Aug 2003 06:53:21 -0000	1.17
***************
*** 170,175 ****
  	char *p1, *p2;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"version", no_argument, 0, 'V'},
  		{"help", no_argument, 0, 'h'},
--- 170,175 ----
  	char *p1, *p2;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"version", no_argument, 0, 'V'},
  		{"help", no_argument, 0, 'h'},
***************
*** 201,206 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "Vvh1246ft:H:O:p:i:u:l:C:n:s:", long_options,
! 									 &option_index);
  
  		if (c == -1 || c == EOF)
--- 201,206 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "Vvh1246ft:H:O:p:i:u:l:C:n:s:", longopts,
! 									 &option);
  
  		if (c == -1 || c == EOF)

Index: check_dig.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dig.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** check_dig.c	9 Aug 2003 06:01:02 -0000	1.16
--- check_dig.c	10 Aug 2003 06:53:21 -0000	1.17
***************
*** 161,166 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"query_address", required_argument, 0, 'e'},
--- 161,166 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"query_address", required_argument, 0, 'e'},
***************
*** 175,179 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVvt:l:H:", long_options, &option_index);
  
  		if (c == -1 || c == EOF)
--- 175,179 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVvt:l:H:", longopts, &option);
  
  		if (c == -1 || c == EOF)
***************
*** 301,305 ****
  	printf (_(UT_VERBOSE));
  
! 	support ();
  }
  
--- 301,305 ----
  	printf (_(UT_VERBOSE));
  
! 	printf (_(UT_SUPPORT));
  }
  

Index: check_disk.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_disk.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -r1.35 -r1.36
*** check_disk.c	9 Aug 2003 00:41:05 -0000	1.35
--- check_disk.c	10 Aug 2003 06:53:21 -0000	1.36
***************
*** 238,243 ****
  	unsigned long l;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"timeout", required_argument, 0, 't'},
  		{"warning", required_argument, 0, 'w'},
--- 238,243 ----
  	unsigned long l;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"timeout", required_argument, 0, 't'},
  		{"warning", required_argument, 0, 'w'},
***************
*** 275,279 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+?VqhveCt:c:w:u:p:x:X:mklM", long_options, &option_index);
  
  		if (c == -1 || c == EOF)
--- 275,279 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+?VqhveCt:c:w:u:p:x:X:mklM", longopts, &option);
  
  		if (c == -1 || c == EOF)
***************
*** 364,368 ****
  		case 'p':									/* select path */
  			se = (struct name_list *) malloc (sizeof (struct name_list));
! 			se->name = strdup (optarg);
  			se->name_next = NULL;
  			se->w_df = w_df;
--- 364,368 ----
  		case 'p':									/* select path */
  			se = (struct name_list *) malloc (sizeof (struct name_list));
! 			se->name = optarg;
  			se->name_next = NULL;
  			se->w_df = w_df;
***************
*** 375,379 ****
   		case 'x':									/* exclude path or partition */
  			se = (struct name_list *) malloc (sizeof (struct name_list));
! 			se->name = strdup (optarg);
  			se->name_next = NULL;
  			*dptail = se;
--- 375,379 ----
   		case 'x':									/* exclude path or partition */
  			se = (struct name_list *) malloc (sizeof (struct name_list));
! 			se->name = optarg;
  			se->name_next = NULL;
  			*dptail = se;
***************
*** 382,386 ****
  		case 'X':									/* exclude file system type */
  			se = (struct name_list *) malloc (sizeof (struct name_list));
! 			se->name = strdup (optarg);
  			se->name_next = NULL;
  			*fstail = se;
--- 382,386 ----
  		case 'X':									/* exclude file system type */
  			se = (struct name_list *) malloc (sizeof (struct name_list));
! 			se->name = optarg;
  			se->name_next = NULL;
  			*fstail = se;

Index: check_dns.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dns.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** check_dns.c	7 Aug 2003 11:51:11 -0000	1.19
--- check_dns.c	10 Aug 2003 06:53:21 -0000	1.20
***************
*** 55,99 ****
  const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
- void
- print_usage (void)
- {
- 	printf (_("\
- Usage: %s -H host [-s server] [-a expected-address] [-t timeout]\n\
-        %s --help\n\
-        %s --version\n"),
- 					progname, progname, progname);
- }
- 
- void
- print_help (void)
- {
- 	print_revision (progname, revision);
- 
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_("\
- -H, --hostname=HOST\n\
-    The name or address you want to query\n\
- -s, --server=HOST\n\
-    Optional DNS server you want to use for the lookup\n\
- -a, --expected-address=IP-ADDRESS\n\
-    Optional IP address you expect the DNS server to return\n"));
- 
- 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
- 
- 	printf (_("\n\
- This plugin uses the nslookup program to obtain the IP address\n\
- for the given host/domain query.  A optional DNS server to use may\n\
- be specified.  If no DNS server is specified, the default server(s)\n\
- specified in /etc/resolv.conf will be used.\n"));
- }
- 
  int process_arguments (int, char **);
  int validate_arguments (void);
  int error_scan (char *);
  
  #define ADDRESS_LENGTH 256
--- 55,63 ----
  const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
  int process_arguments (int, char **);
  int validate_arguments (void);
  int error_scan (char *);
+ void print_help (void);
+ void print_usage (void);
  
  #define ADDRESS_LENGTH 256
***************
*** 421,423 ****
--- 385,435 ----
  	else
  		return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_("\
+ -H, --hostname=HOST\n\
+    The name or address you want to query\n\
+ -s, --server=HOST\n\
+    Optional DNS server you want to use for the lookup\n\
+ -a, --expected-address=IP-ADDRESS\n\
+    Optional IP address you expect the DNS server to return\n"));
+ 
+ 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+ 
+ 	printf (_("\n\
+ This plugin uses the nslookup program to obtain the IP address\n\
+ for the given host/domain query.  A optional DNS server to use may\n\
+ be specified.  If no DNS server is specified, the default server(s)\n\
+ specified in /etc/resolv.conf will be used.\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("\
+ Usage: %s -H host [-s server] [-a expected-address] [-t timeout]\n\
+        %s --help\n\
+        %s --version\n"),
+ 					progname, progname, progname);
  }

Index: check_fping.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_fping.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** check_fping.c	7 Aug 2003 11:51:11 -0000	1.8
--- check_fping.c	10 Aug 2003 06:53:21 -0000	1.9
***************
*** 35,38 ****
--- 35,39 ----
  #include "common.h"
  #include "popen.h"
+ #include "netutils.h"
  #include "utils.h"
  
***************
*** 45,96 ****
  #define RTA 1
  
- void
- print_usage (void)
- {
- 	printf (_("Usage: %s <host_address>\n"), progname);
- }
- 
- void
- print_help (void)
- {
- 
- 	print_revision (progname, "$Revision$");
- 
- 	printf (_("\
- Copyright (c) 1999 Didi Rieder (adrieder at sbox.tu-graz.ac.at)\n\n\
- This plugin will use the /bin/fping command (from saint) to ping the\n\
- specified host for a fast check if the host is alive. Note that it is\n\
- necessary to set the suid flag on fping.\n\n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_("\
-  -H, --hostname=HOST\n\
-     Name or IP Address of host to ping (IP Address bypasses name lookup,\n\
-     reducing system load)\n\
-  -w, --warning=THRESHOLD\n\
-     warning threshold pair\n\
-  -c, --critical=THRESHOLD\n\
-     critical threshold pair\n\
-  -b, --bytes=INTEGER\n\
-     Size of ICMP packet (default: %d)\n\
-  -n, --number=INTEGER\n\
-     Number of ICMP packets to send (default: %d)\n"),
- 	        PACKET_SIZE, PACKET_COUNT);
- 
- 	printf (_(UT_VERBOSE));
- 
- 	printf (_("\n\
- THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel\n\
- time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the\n\
- percentage of packet loss to trigger an alarm state.\n"));
- 
- }
- 
  int textscan (char *buf);
  int process_arguments (int, char **);
  int get_threshold (char *arg, char *rv[2]);
  
  char *server_name = NULL;
--- 46,54 ----
  #define RTA 1
  
  int textscan (char *buf);
  int process_arguments (int, char **);
  int get_threshold (char *arg, char *rv[2]);
+ void print_help (void);
+ void print_usage (void);
  
  char *server_name = NULL;
***************
*** 201,209 ****
  		if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl)
  			status = STATE_CRITICAL;
! 		else if (crta != UNKNOWN_TRIP_TIME && rta > crta)
  			status = STATE_CRITICAL;
  		else if (wpl != UNKNOWN_PACKET_LOSS && loss > wpl)
  			status = STATE_WARNING;
! 		else if (wrta != UNKNOWN_TRIP_TIME && rta > wrta)
  			status = STATE_WARNING;
  		else
--- 159,167 ----
  		if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl)
  			status = STATE_CRITICAL;
! 		else if (crta <= 0 && rta > crta)
  			status = STATE_CRITICAL;
  		else if (wpl != UNKNOWN_PACKET_LOSS && loss > wpl)
  			status = STATE_WARNING;
! 		else if (wrta >= 0 && rta > wrta)
  			status = STATE_WARNING;
  		else
***************
*** 219,223 ****
  		losstr = 1 + strstr (losstr, "/");
  		loss = strtod (losstr, NULL);
! 		if (loss == 100)
  			status = STATE_CRITICAL;
  		else if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl)
--- 177,181 ----
  		losstr = 1 + strstr (losstr, "/");
  		loss = strtod (losstr, NULL);
! 		if (atoi(losstr) == 100)
  			status = STATE_CRITICAL;
  		else if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl)
***************
*** 249,254 ****
  	char *rv[2];
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"critical", required_argument, 0, 'c'},
--- 207,212 ----
  	char *rv[2];
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"critical", required_argument, 0, 'c'},
***************
*** 276,280 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVvH:c:w:b:n:", long_options, &option_index);
  
  		if (c == -1 || c == EOF || c == 1)
--- 234,238 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVvH:c:w:b:n:", longopts, &option);
  
  		if (c == -1 || c == EOF || c == 1)
***************
*** 389,391 ****
--- 347,404 ----
  
  	return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 
+ 	print_revision (progname, "$Revision$");
+ 
+ 	printf (_("\
+ Copyright (c) 1999 Didi Rieder (adrieder at sbox.tu-graz.ac.at)\n\n\
+ This plugin will use the /bin/fping command (from saint) to ping the\n\
+ specified host for a fast check if the host is alive. Note that it is\n\
+ necessary to set the suid flag on fping.\n\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_("\
+  -H, --hostname=HOST\n\
+     Name or IP Address of host to ping (IP Address bypasses name lookup,\n\
+     reducing system load)\n\
+  -w, --warning=THRESHOLD\n\
+     warning threshold pair\n\
+  -c, --critical=THRESHOLD\n\
+     critical threshold pair\n\
+  -b, --bytes=INTEGER\n\
+     Size of ICMP packet (default: %d)\n\
+  -n, --number=INTEGER\n\
+     Number of ICMP packets to send (default: %d)\n"),
+ 	        PACKET_SIZE, PACKET_COUNT);
+ 
+ 	printf (_(UT_VERBOSE));
+ 
+ 	printf (_("\n\
+ THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel\n\
+ time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the\n\
+ percentage of packet loss to trigger an alarm state.\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("Usage: %s <host_address>\n"), progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
  }

Index: check_game.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_game.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** check_game.c	7 Aug 2003 11:51:11 -0000	1.6
--- check_game.c	10 Aug 2003 06:53:21 -0000	1.7
***************
*** 26,71 ****
  #include "utils.h"
  
- void
- print_usage (void)
- {
- 	printf (_("\
- Usage: %s <game> <ip_address> [-p port] [-gf game_field] [-mf map_field]\n\
-   [-pf ping_field]\n"), progname);
- 	printf (_(UT_HLP_VRS), progname, progname);
- }
- 
- void
- print_help (void)
- {
- 	print_revision (progname, revision);
- 
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("This plugin tests %s connections with the specified host."), progname);
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_("\
- <game>        = Game type that is recognised by qstat (without the leading dash)\n\
- <ip_address>  = The IP address of the device you wish to query\n\
-  [port]        = Optional port of which to connect\n\
-  [game_field]  = Field number in raw qstat output that contains game name\n\
-  [map_field]   = Field number in raw qstat output that contains map name\n\
-  [ping_field]  = Field number in raw qstat output that contains ping time\n"),
- 	        DEFAULT_SOCKET_TIMEOUT);
- 
- 	printf (_("\n\
- Notes:\n\
- - This plugin uses the 'qstat' command, the popular game server status query tool .\n\
-   If you don't have the package installed, you will need to download it from\n\
-   http://www.activesw.com/people/steve/qstat.html before you can use this plugin.\n"));
- 
- 	printf (_(UT_SUPPORT));
- }
- 
  int process_arguments (int, char **);
  int validate_arguments (void);
  
  #define QSTAT_DATA_DELIMITER 	","
--- 26,33 ----
  #include "utils.h"
  
  int process_arguments (int, char **);
  int validate_arguments (void);
+ void print_help (void);
+ void print_usage (void);
  
  #define QSTAT_DATA_DELIMITER 	","
***************
*** 153,157 ****
  	/* initialize the returned data buffer */
  	for (i = 0; i < QSTAT_MAX_RETURN_ARGS; i++)
! 		ret[i] = "";
  
  	i = 0;
--- 115,119 ----
  	/* initialize the returned data buffer */
  	for (i = 0; i < QSTAT_MAX_RETURN_ARGS; i++)
! 		ret[i] = strdup("");
  
  	i = 0;
***************
*** 254,258 ****
  			if (strlen (optarg) >= MAX_HOST_ADDRESS_LENGTH)
  				die (STATE_UNKNOWN, _("Input buffer overflow\n"));
! 			server_ip = strdup (optarg);
  			break;
  		case 'P': /* port */
--- 216,220 ----
  			if (strlen (optarg) >= MAX_HOST_ADDRESS_LENGTH)
  				die (STATE_UNKNOWN, _("Input buffer overflow\n"));
! 			server_ip = optarg;
  			break;
  		case 'P': /* port */
***************
*** 262,266 ****
  			if (strlen (optarg) >= MAX_INPUT_BUFFER)
  				die (STATE_UNKNOWN, _("Input buffer overflow\n"));
! 			game_type = strdup (optarg);
  			break;
  		case 'p': /* index of ping field */
--- 224,228 ----
  			if (strlen (optarg) >= MAX_INPUT_BUFFER)
  				die (STATE_UNKNOWN, _("Input buffer overflow\n"));
! 			game_type = optarg;
  			break;
  		case 'p': /* index of ping field */
***************
*** 308,310 ****
--- 270,321 ----
  {
  		return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("This plugin tests %s connections with the specified host."), progname);
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_("\
+ <game>        = Game type that is recognised by qstat (without the leading dash)\n\
+ <ip_address>  = The IP address of the device you wish to query\n\
+  [port]        = Optional port of which to connect\n\
+  [game_field]  = Field number in raw qstat output that contains game name\n\
+  [map_field]   = Field number in raw qstat output that contains map name\n\
+  [ping_field]  = Field number in raw qstat output that contains ping time\n"));
+ 
+ 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+ 
+ 	printf (_("\n\
+ Notes:\n\
+ - This plugin uses the 'qstat' command, the popular game server status query tool .\n\
+   If you don't have the package installed, you will need to download it from\n\
+   http://www.activesw.com/people/steve/qstat.html before you can use this plugin.\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("\
+ Usage: %s <game> <ip_address> [-p port] [-gf game_field] [-mf map_field]\n\
+   [-pf ping_field]\n"), progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
  }

Index: check_hpjd.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_hpjd.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** check_hpjd.c	2 Aug 2003 22:19:21 -0000	1.14
--- check_hpjd.c	10 Aug 2003 06:53:21 -0000	1.15
***************
*** 30,63 ****
  
  const char *option_summary = "-H host [-C community]\n";
- void
- print_usage (void)
- {
- 	printf (_("\
- Usage: %s -H host [-C community]\n"), progname);
- 	printf (_(UT_HLP_VRS), progname, progname);
- }
  
- void
- print_help (void)
- {
- 	print_revision (progname, revision);
- 
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("\
- This plugin tests the STATUS of an HP printer with a JetDirect card.\n\
- Net-snmp must be installed on the computer running the plugin.\n\n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_("\
-  -C, --community=STRING\n\
-     The SNMP community name (default=%s)\n"), DEFAULT_COMMUNITY);
- 
- 	printf (_(UT_SUPPORT));
- }
- 
  #define HPJD_LINE_STATUS		".1.3.6.1.4.1.11.2.3.9.1.1.2.1"
  #define HPJD_PAPER_STATUS		".1.3.6.1.4.1.11.2.3.9.1.1.2.2"
--- 30,34 ----
***************
*** 78,83 ****
  int process_arguments (int, char **);
  int validate_arguments (void);
  
! char *community = DEFAULT_COMMUNITY;
  char *address = NULL;
  
--- 49,56 ----
  int process_arguments (int, char **);
  int validate_arguments (void);
+ void print_help (void);
+ void print_usage (void);
  
! char *community = NULL;
  char *address = NULL;
  
***************
*** 90,94 ****
  	char input_buffer[MAX_INPUT_BUFFER];
  	char query_string[512];
! 	char error_message[MAX_INPUT_BUFFER];
  	char *temp_buffer;
  	int line_status = ONLINE;
--- 63,67 ----
  	char input_buffer[MAX_INPUT_BUFFER];
  	char query_string[512];
! 	char *errmsg;
  	char *temp_buffer;
  	int line_status = ONLINE;
***************
*** 104,108 ****
  	int paper_output = 0;
  	char display_message[MAX_INPUT_BUFFER];
! 	char *temp ;
  
  	if (process_arguments (argc, argv) != OK)
--- 77,82 ----
  	int paper_output = 0;
  	char display_message[MAX_INPUT_BUFFER];
! 
! 	errmsg = malloc(MAX_INPUT_BUFFER);
  
  	if (process_arguments (argc, argv) != OK)
***************
*** 155,270 ****
  		temp_buffer = strtok (NULL, "=");
  
! 		switch (line) {
  
- 		case 1:										/* 1st line should contain the line status */
- 			if (temp_buffer != NULL)
- 				line_status = atoi (temp_buffer);
- 			else {
  				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
! 			}
! 			break;
  
! 		case 2:										/* 2nd line should contain the paper status */
! 			if (temp_buffer != NULL)
! 				paper_status = atoi (temp_buffer);
! 			else {
! 				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
! 			}
! 			break;
  
! 		case 3:										/* 3rd line should be intervention required */
! 			if (temp_buffer != NULL)
! 				intervention_required = atoi (temp_buffer);
! 			else {
! 				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
! 			}
! 			break;
  
! 		case 4:										/* 4th line should be peripheral error */
! 			if (temp_buffer != NULL)
  				peripheral_error = atoi (temp_buffer);
! 			else {
! 				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
! 			}
! 			break;
! 
! 		case 5:										/* 5th line should contain the paper jam status */
! 			if (temp_buffer != NULL)
  				paper_jam = atoi (temp_buffer);
! 			else {
! 				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
! 			}
! 			break;
! 
! 		case 6:										/* 6th line should contain the paper out status */
! 			if (temp_buffer != NULL)
  				paper_out = atoi (temp_buffer);
! 			else {
! 				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
! 			}
! 			break;
! 
! 		case 7:										/* 7th line should contain the toner low status */
! 			if (temp_buffer != NULL)
  				toner_low = atoi (temp_buffer);
! 			else {
! 				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
! 			}
! 			break;
! 
! 		case 8:										/* did data come too slow for engine */
! 			if (temp_buffer != NULL)
  				page_punt = atoi (temp_buffer);
! 			else {
! 				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
! 			}
! 			break;
! 
! 		case 9:										/* did we run out of memory */
! 			if (temp_buffer != NULL)
  				memory_out = atoi (temp_buffer);
! 			else {
! 				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
! 			}
! 			break;
! 
! 		case 10:										/* is there a door open */
! 			if (temp_buffer != NULL)
  				door_open = atoi (temp_buffer);
! 			else {
! 				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
! 			}
! 			break;
! 
! 		case 11:										/* is output tray full */
! 			if (temp_buffer != NULL)
  				paper_output = atoi (temp_buffer);
! 			else {
! 				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
! 			}
! 			break;
! 
! 		case 12:										/* display panel message */
! 			if (temp_buffer != NULL)
  				strcpy (display_message, temp_buffer + 1);
! 			else {
! 				result = STATE_UNKNOWN;
! 				strcpy (error_message, input_buffer);
  			}
- 			break;
  
- 		default:
- 			break;
  		}
  
--- 129,181 ----
  		temp_buffer = strtok (NULL, "=");
  
! 		if (temp_buffer != NULL) {
  
  				result = STATE_UNKNOWN;
! 				strcpy (errmsg, input_buffer);
  
! 		} else {
  
! 			switch (line) {
  
! 			case 1:										/* 1st line should contain the line status */
! 				line_status = atoi (temp_buffer);
! 				break;
! 			case 2:										/* 2nd line should contain the paper status */
! 				paper_status = atoi (temp_buffer);
! 				break;
! 			case 3:										/* 3rd line should be intervention required */
! 				intervention_required = atoi (temp_buffer);
! 				break;
! 			case 4:										/* 4th line should be peripheral error */
  				peripheral_error = atoi (temp_buffer);
! 				break;
! 			case 5:										/* 5th line should contain the paper jam status */
  				paper_jam = atoi (temp_buffer);
! 				break;
! 			case 6:										/* 6th line should contain the paper out status */
  				paper_out = atoi (temp_buffer);
! 				break;
! 			case 7:										/* 7th line should contain the toner low status */
  				toner_low = atoi (temp_buffer);
! 				break;
! 			case 8:										/* did data come too slow for engine */
  				page_punt = atoi (temp_buffer);
! 				break;
! 			case 9:										/* did we run out of memory */
  				memory_out = atoi (temp_buffer);
! 				break;
! 			case 10:										/* is there a door open */
  				door_open = atoi (temp_buffer);
! 				break;
! 			case 11:										/* is output tray full */
  				paper_output = atoi (temp_buffer);
! 				break;
! 			case 12:										/* display panel message */
  				strcpy (display_message, temp_buffer + 1);
! 				break;
! 			default:
! 				break;
  			}
  
  		}
  
***************
*** 280,284 ****
  		if (input_buffer[strlen (input_buffer) - 1] == '\n')
  			input_buffer[strlen (input_buffer) - 1] = 0;
! 		sprintf (error_message, "%s", input_buffer );
  
  	}
--- 191,195 ----
  		if (input_buffer[strlen (input_buffer) - 1] == '\n')
  			input_buffer[strlen (input_buffer) - 1] = 0;
! 		sprintf (errmsg, "%s", input_buffer );
  
  	}
***************
*** 296,301 ****
  		/* might not be the problem, but most likely is. */
  		result = STATE_UNKNOWN ;
! 		asprintf (&temp, error_message);
! 		sprintf (error_message, "%s : Timeout from host %s\n", temp, address );
  		 
  	}
--- 207,211 ----
  		/* might not be the problem, but most likely is. */
  		result = STATE_UNKNOWN ;
! 		asprintf (&errmsg, "%s : Timeout from host %s\n", errmsg, address );
  		 
  	}
***************
*** 306,352 ****
  		if (paper_jam) {
  			result = STATE_WARNING;
! 			strcpy (error_message, _("Paper Jam"));
  		}
  		else if (paper_out) {
  			result = STATE_WARNING;
! 			strcpy (error_message, _("Out of Paper"));
  		}
  		else if (line_status == OFFLINE) {
! 			if (strcmp (error_message, "POWERSAVE ON") != 0) {
  				result = STATE_WARNING;
! 				strcpy (error_message, _("Printer Offline"));
  			}
  		}
  		else if (peripheral_error) {
  			result = STATE_WARNING;
! 			strcpy (error_message, _("Peripheral Error"));
  		}
  		else if (intervention_required) {
  			result = STATE_WARNING;
! 			strcpy (error_message, _("Intervention Required"));
  		}
  		else if (toner_low) {
  			result = STATE_WARNING;
! 			strcpy (error_message, _("Toner Low"));
  		}
  		else if (memory_out) {
  			result = STATE_WARNING;
! 			strcpy (error_message, _("Insufficient Memory"));
  		}
  		else if (door_open) {
  			result = STATE_WARNING;
! 			strcpy (error_message, _("A Door is Open"));
  		}
  		else if (paper_output) {
  			result = STATE_WARNING;
! 			strcpy (error_message, _("Output Tray is Full"));
  		}
  		else if (page_punt) {
  			result = STATE_WARNING;
! 			strcpy (error_message, _("Data too Slow for Engine"));
  		}
  		else if (paper_status) {
  			result = STATE_WARNING;
! 			strcpy (error_message, _("Unknown Paper Error"));
  		}
  	}
--- 216,262 ----
  		if (paper_jam) {
  			result = STATE_WARNING;
! 			strcpy (errmsg, _("Paper Jam"));
  		}
  		else if (paper_out) {
  			result = STATE_WARNING;
! 			strcpy (errmsg, _("Out of Paper"));
  		}
  		else if (line_status == OFFLINE) {
! 			if (strcmp (errmsg, "POWERSAVE ON") != 0) {
  				result = STATE_WARNING;
! 				strcpy (errmsg, _("Printer Offline"));
  			}
  		}
  		else if (peripheral_error) {
  			result = STATE_WARNING;
! 			strcpy (errmsg, _("Peripheral Error"));
  		}
  		else if (intervention_required) {
  			result = STATE_WARNING;
! 			strcpy (errmsg, _("Intervention Required"));
  		}
  		else if (toner_low) {
  			result = STATE_WARNING;
! 			strcpy (errmsg, _("Toner Low"));
  		}
  		else if (memory_out) {
  			result = STATE_WARNING;
! 			strcpy (errmsg, _("Insufficient Memory"));
  		}
  		else if (door_open) {
  			result = STATE_WARNING;
! 			strcpy (errmsg, _("A Door is Open"));
  		}
  		else if (paper_output) {
  			result = STATE_WARNING;
! 			strcpy (errmsg, _("Output Tray is Full"));
  		}
  		else if (page_punt) {
  			result = STATE_WARNING;
! 			strcpy (errmsg, _("Data too Slow for Engine"));
  		}
  		else if (paper_status) {
  			result = STATE_WARNING;
! 			strcpy (errmsg, _("Unknown Paper Error"));
  		}
  	}
***************
*** 357,369 ****
  	else if (result == STATE_UNKNOWN) {
  
! 		printf ("%s\n", error_message);
  
  		/* if printer could not be reached, escalate to critical */
! 		if (strstr (error_message, "Timeout"))
  			result = STATE_CRITICAL;
  	}
  
  	else if (result == STATE_WARNING)
! 		printf ("%s (%s)\n", error_message, display_message);
  
  	return result;
--- 267,279 ----
  	else if (result == STATE_UNKNOWN) {
  
! 		printf ("%s\n", errmsg);
  
  		/* if printer could not be reached, escalate to critical */
! 		if (strstr (errmsg, "Timeout"))
  			result = STATE_CRITICAL;
  	}
  
  	else if (result == STATE_WARNING)
! 		printf ("%s (%s)\n", errmsg, display_message);
  
  	return result;
***************
*** 380,385 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"community", required_argument, 0, 'C'},
--- 290,295 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"community", required_argument, 0, 'C'},
***************
*** 397,401 ****
  	
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVH:C:", long_options, &option_index);
  
  		if (c == -1 || c == EOF || c == 1)
--- 307,311 ----
  	
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVH:C:", longopts, &option);
  
  		if (c == -1 || c == EOF || c == 1)
***************
*** 435,440 ****
  	}
  	
! 	if (argv[c] != NULL ) {
! 		community = argv[c];
  	}
  
--- 345,353 ----
  	}
  	
! 	if (community == NULL) {
! 		if (argv[c] != NULL )
! 			community = argv[c];
! 		else
! 			community = strdup (DEFAULT_COMMUNITY);
  	}
  
***************
*** 450,452 ****
--- 363,403 ----
  {
  	return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("\
+ This plugin tests the STATUS of an HP printer with a JetDirect card.\n\
+ Net-snmp must be installed on the computer running the plugin.\n\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_("\
+  -C, --community=STRING\n\
+     The SNMP community name (default=%s)\n"), DEFAULT_COMMUNITY);
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("\
+ Usage: %s -H host [-C community]\n"), progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
  }

Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -r1.43 -r1.44
*** check_http.c	9 Aug 2003 06:01:02 -0000	1.43
--- check_http.c	10 Aug 2003 06:53:21 -0000	1.44
***************
*** 185,190 ****
  	int c = 1;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		STD_LONG_OPTS,
  		{"file",required_argument,0,'F'},
--- 185,190 ----
  	int c = 1;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		STD_LONG_OPTS,
  		{"file",required_argument,0,'F'},
***************
*** 225,229 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "Vvh46t:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nlLSm:", long_options, &option_index);
  		if (c == -1 || c == EOF)
  			break;
--- 225,229 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "Vvh46t:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nlLSm:", longopts, &option);
  		if (c == -1 || c == EOF)
  			break;
***************
*** 305,312 ****
  		/* Note: H, I, and u must be malloc'd or will fail on redirects */
  		case 'H': /* Host Name (virtual host) */
!  			host_name = strdup (optarg);
  			break;
  		case 'I': /* Server IP-address */
!  			server_address = strdup(optarg);
  			break;
  		case 'u': /* URL path */
--- 305,312 ----
  		/* Note: H, I, and u must be malloc'd or will fail on redirects */
  		case 'H': /* Host Name (virtual host) */
!  			host_name = optarg;
  			break;
  		case 'I': /* Server IP-address */
!  			server_address = optarg;
  			break;
  		case 'u': /* URL path */
***************
*** 329,333 ****
  			if (http_method || http_post_data) break;
  			http_method = strdup("POST");
! 			http_post_data = strdup(optarg);
  			break;
  		case 's': /* string or substring */
--- 329,333 ----
  			if (http_method || http_post_data) break;
  			http_method = strdup("POST");
! 			http_post_data = optarg;
  			break;
  		case 's': /* string or substring */

Index: check_ldap.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ldap.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** check_ldap.c	4 Aug 2003 07:42:24 -0000	1.12
--- check_ldap.c	10 Aug 2003 06:53:21 -0000	1.13
***************
*** 37,109 ****
  };
  
- void
- print_usage ()
- {
- 	printf (_("\
- Usage: %s -H <host> -b <base_dn> [-p <port>] [-a <attr>] [-D <binddn>]\n\
-   [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]%s\n\
- (Note: all times are in seconds.)\n"),
- 	        progname, (HAVE_LDAP_SET_OPTION ? "[-2|-3] [-4|-6]" : ""));
- 	printf (_(UT_HLP_VRS), progname, progname);
- }
- 
- void
- print_help ()
- {
- 	char *myport;
- 	asprintf (&myport, "%d", DEFAULT_PORT);
- 
- 	print_revision (progname, revision);
- 
- 	printf (_("Copyright (c) 1999 Didi Rieder (adrieder at sbox.tu-graz.ac.at)\n"));
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_(UT_HOST_PORT), 'p', myport);
- 
- 	printf (_(UT_IPv46));
- 
- 	printf (_("\
-  -a [--attr]\n\
-     ldap attribute to search (default: \"(objectclass=*)\"\n\
-  -b [--base]\n\
-     ldap base (eg. ou=my unit, o=my org, c=at)\n\
-  -D [--bind]\n\
-     ldap bind DN (if required)\n\
-  -P [--pass]\n\
-     ldap password (if required)\n"));
- 
- #ifdef HAVE_LDAP_SET_OPTION
- 	printf (_("\
-  -2 [--ver2]\n\
-      use ldap protocol version 2\n\
-  -3 [--ver3]\n\
-     use ldap protocol version 3\n\
-     (default protocol version: %d)\n"),
- 	        DEFAULT_PROTOCOL);
- #endif
- 
- 	printf (_(UT_WARN_CRIT));
- 
- 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
- 
- 	printf (_(UT_VERBOSE));
- 
- 	printf (_(UT_SUPPORT));
- }
- 
  int process_arguments (int, char **);
  int validate_arguments (void);
  
  char ld_defattr[] = "(objectclass=*)";
  char *ld_attr = ld_defattr;
! char *ld_host = "";
! char *ld_base = "";
  char *ld_passwd = NULL;
  char *ld_binddn = NULL;
! unsigned int ld_port = DEFAULT_PORT;
  #ifdef HAVE_LDAP_SET_OPTION
  int ld_protocol = DEFAULT_PROTOCOL;
--- 37,52 ----
  };
  
  int process_arguments (int, char **);
  int validate_arguments (void);
+ void print_help (void);
+ void print_usage (void);
  
  char ld_defattr[] = "(objectclass=*)";
  char *ld_attr = ld_defattr;
! char *ld_host = NULL;
! char *ld_base = NULL;
  char *ld_passwd = NULL;
  char *ld_binddn = NULL;
! int ld_port = DEFAULT_PORT;
  #ifdef HAVE_LDAP_SET_OPTION
  int ld_protocol = DEFAULT_PROTOCOL;
***************
*** 199,203 ****
  	int c;
  
! 	int option_index = 0;
  	/* initialize the long option struct */
  	static struct option longopts[] = {
--- 142,146 ----
  	int c;
  
! 	int option = 0;
  	/* initialize the long option struct */
  	static struct option longopts[] = {
***************
*** 231,235 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hV2346t:c:w:H:b:p:a:D:P:", longopts, &option_index);
  
  		if (c == -1 || c == EOF)
--- 174,178 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hV2346t:c:w:H:b:p:a:D:P:", longopts, &option);
  
  		if (c == -1 || c == EOF)
***************
*** 246,250 ****
  			if (!is_intnonneg (optarg))
  				usage2 (_("timeout interval must be a positive integer"), optarg);
! 			socket_timeout = atoi (optarg);
  			break;
  		case 'H':
--- 189,194 ----
  			if (!is_intnonneg (optarg))
  				usage2 (_("timeout interval must be a positive integer"), optarg);
! 			else
! 				socket_timeout = atoi (optarg);
  			break;
  		case 'H':
***************
*** 297,306 ****
  
  	c = optind;
! 	if (strlen(ld_host) == 0 && is_host(argv[c])) {
! 		asprintf (&ld_host, "%s", argv[c++]);
! 	}
! 	if (strlen(ld_base) == 0 && argv[c]) {
! 		asprintf (&ld_base, "%s", argv[c++]);
! 	}
  
  	return validate_arguments ();
--- 241,249 ----
  
  	c = optind;
! 	if (ld_host == NULL && is_host(argv[c]))
! 		ld_host = strdup (argv[c++]);
! 
! 	if (ld_base == NULL && argv[c])
! 		ld_base = strdup (argv[c++]);
  
  	return validate_arguments ();
***************
*** 318,320 ****
--- 261,330 ----
  	return OK;
  
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	char *myport;
+ 	asprintf (&myport, "%d", DEFAULT_PORT);
+ 
+ 	print_revision (progname, revision);
+ 
+ 	printf (_("Copyright (c) 1999 Didi Rieder (adrieder at sbox.tu-graz.ac.at)\n"));
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_(UT_HOST_PORT), 'p', myport);
+ 
+ 	printf (_(UT_IPv46));
+ 
+ 	printf (_("\
+  -a [--attr]\n\
+     ldap attribute to search (default: \"(objectclass=*)\"\n\
+  -b [--base]\n\
+     ldap base (eg. ou=my unit, o=my org, c=at)\n\
+  -D [--bind]\n\
+     ldap bind DN (if required)\n\
+  -P [--pass]\n\
+     ldap password (if required)\n"));
+ 
+ #ifdef HAVE_LDAP_SET_OPTION
+ 	printf (_("\
+  -2 [--ver2]\n\
+      use ldap protocol version 2\n\
+  -3 [--ver3]\n\
+     use ldap protocol version 3\n\
+     (default protocol version: %d)\n"),
+ 	        DEFAULT_PROTOCOL);
+ #endif
+ 
+ 	printf (_(UT_WARN_CRIT));
+ 
+ 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+ 
+ 	printf (_(UT_VERBOSE));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("\
+ Usage: %s -H <host> -b <base_dn> [-p <port>] [-a <attr>] [-D <binddn>]\n\
+   [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]%s\n\
+ (Note: all times are in seconds.)\n"),
+ 	        progname, (HAVE_LDAP_SET_OPTION ? "[-2|-3] [-4|-6]" : ""));
+ 	printf (_(UT_HLP_VRS), progname, progname);
  }

Index: check_load.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_load.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** check_load.c	9 Aug 2003 06:01:02 -0000	1.10
--- check_load.c	10 Aug 2003 06:53:21 -0000	1.11
***************
*** 159,164 ****
  	int c = 0;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"warning", required_argument, 0, 'w'},
  		{"critical", required_argument, 0, 'c'},
--- 159,164 ----
  	int c = 0;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"warning", required_argument, 0, 'w'},
  		{"critical", required_argument, 0, 'c'},
***************
*** 172,176 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "Vhc:w:", long_options, &option_index);
  
  		if (c == -1 || c == EOF)
--- 172,176 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "Vhc:w:", longopts, &option);
  
  		if (c == -1 || c == EOF)

Index: check_mrtg.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_mrtg.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** check_mrtg.c	9 Aug 2003 06:01:02 -0000	1.8
--- check_mrtg.c	10 Aug 2003 06:53:21 -0000	1.9
***************
*** 150,155 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"logfile", required_argument, 0, 'F'},
  		{"expires", required_argument, 0, 'e'},
--- 150,155 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"logfile", required_argument, 0, 'F'},
  		{"expires", required_argument, 0, 'e'},
***************
*** 179,184 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVF:e:a:v:c:w:l:u:", long_options,
! 									 &option_index);
  
  		if (c == -1 || c == EOF)
--- 179,184 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVF:e:a:v:c:w:l:u:", longopts,
! 									 &option);
  
  		if (c == -1 || c == EOF)

Index: check_mrtgtraf.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_mrtgtraf.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** check_mrtgtraf.c	9 Aug 2003 06:01:02 -0000	1.8
--- check_mrtgtraf.c	10 Aug 2003 06:53:21 -0000	1.9
***************
*** 202,206 ****
  	int c;
  
! 	int option_index = 0;
  	static struct option longopts[] = {
  		{"logfile", required_argument, 0, 'F'},
--- 202,206 ----
  	int c;
  
! 	int option = 0;
  	static struct option longopts[] = {
  		{"logfile", required_argument, 0, 'F'},
***************
*** 229,233 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVF:e:a:c:w:", longopts, &option_index);
  
  		if (c == -1 || c == EOF)
--- 229,233 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVF:e:a:c:w:", longopts, &option);
  
  		if (c == -1 || c == EOF)

Index: check_mysql.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_mysql.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** check_mysql.c	2 Aug 2003 22:08:31 -0000	1.10
--- check_mysql.c	10 Aug 2003 06:53:22 -0000	1.11
***************
*** 26,81 ****
  #include <mysql/errmsg.h>
  
! void
! print_usage (void)
! {
! 	printf (_("\
! Usage: %s [-d database] [-H host] [-P port] [-u user] [-p password]\n"),
! 	        progname);
! 	printf (_(UT_HLP_VRS), progname, progname);
! }
! 
! void
! print_help (void)
! {
! 	char *myport;
! 	asprintf (&myport, "%d", MYSQL_PORT);
! 
! 	print_revision (progname, revision);
! 
! 	printf (_(COPYRIGHT), copyright, email);
! 
! 	printf (_("This program tests connections to a mysql server\n"));
! 
! 	print_usage ();
! 
! 	printf (_(UT_HELP_VRSN));
! 
! 	printf (_(UT_HOST_PORT), 'P', myport);
! 
! 	printf (_("\
!  -d, --database=STRING\n\
!    Check database with indicated name\n\
!  -u, --username=STRING\n\
!    Connect using the indicated username\n\
!  -p, --password=STRING\n\
!    Use the indicated password to authenticate the connection\n\
!    ==> IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!! <==\n\
!    Your clear-text password will be visible as a process table entry\n"));
! 
! 	printf (_("\n\
! There are no required arguments. By default, the local database with\n\
! a server listening on MySQL standard port %d will be checked\n"), MYSQL_PORT);
! 
! 	printf (_(UT_SUPPORT));
! }
! 
! char *db_user = "";
! char *db_host = "";
! char *db_pass = "";
! char *db = "";
  unsigned int db_port = MYSQL_PORT;
  
  int process_arguments (int, char **);
  int validate_arguments (void);
  
  int
--- 26,39 ----
  #include <mysql/errmsg.h>
  
! char *db_user = NULL;
! char *db_host = NULL;
! char *db_pass = NULL;
! char *db = NULL;
  unsigned int db_port = MYSQL_PORT;
  
  int process_arguments (int, char **);
  int validate_arguments (void);
+ void print_help (void);
+ void print_usage (void);
  
  int
***************
*** 84,88 ****
  
  	MYSQL mysql;
! 	char result[1024];
  
  	if (process_arguments (argc, argv) != OK)
--- 42,46 ----
  
  	MYSQL mysql;
! 	char *result = NULL;
  
  	if (process_arguments (argc, argv) != OK)
***************
*** 93,152 ****
  
  	/* establish a connection to the server and error checking */
! 	if (!mysql_real_connect
! 			(&mysql, db_host, db_user, db_pass, db, db_port, NULL, 0)) {
! 
! 		if (mysql_errno (&mysql) == CR_UNKNOWN_HOST) {
! 			printf ("%s\n", mysql_error (&mysql));
! 			return STATE_WARNING;
! 
! 		}
! 		else if (mysql_errno (&mysql) == CR_VERSION_ERROR) {
! 			printf ("%s\n", mysql_error (&mysql));
! 			return STATE_WARNING;
! 
! 		}
! 		else if (mysql_errno (&mysql) == CR_OUT_OF_MEMORY) {
! 			printf ("%s\n", mysql_error (&mysql));
! 			return STATE_WARNING;
! 
! 		}
! 		else if (mysql_errno (&mysql) == CR_IPSOCK_ERROR) {
! 			printf ("%s\n", mysql_error (&mysql));
! 			return STATE_WARNING;
! 
! 		}
! 		else if (mysql_errno (&mysql) == CR_SOCKET_CREATE_ERROR) {
! 			printf ("%s\n", mysql_error (&mysql));
! 			return STATE_WARNING;
! 
! 		}
! 		else {
! 			printf ("%s\n", mysql_error (&mysql));
! 			return STATE_CRITICAL;
! 		}
! 
  	}
  
  	/* get the server stats */
! 	sprintf (result, mysql_stat (&mysql));
  
  	/* error checking once more */
  	if (mysql_error (&mysql)) {
! 
! 		if (mysql_errno (&mysql) == CR_SERVER_GONE_ERROR) {
! 			printf ("%s\n", mysql_error (&mysql));
! 			return STATE_CRITICAL;
! 
! 		}
! 		else if (mysql_errno (&mysql) == CR_SERVER_LOST) {
! 			printf ("%s\n", mysql_error (&mysql));
! 			return STATE_CRITICAL;
! 
! 		}
! 		else if (mysql_errno (&mysql) == CR_UNKNOWN_ERROR) {
! 			printf ("%s\n", mysql_error (&mysql));
! 			return STATE_UNKNOWN;
! 		}
! 
  	}
  
--- 51,80 ----
  
  	/* establish a connection to the server and error checking */
! 	if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,NULL,0)) {
! 		if (mysql_errno (&mysql) == CR_UNKNOWN_HOST)
! 			die (STATE_WARNING, "%s\n", mysql_error (&mysql));
! 		else if (mysql_errno (&mysql) == CR_VERSION_ERROR)
! 			die (STATE_WARNING, "%s\n", mysql_error (&mysql));
! 		else if (mysql_errno (&mysql) == CR_OUT_OF_MEMORY)
! 			die (STATE_WARNING, "%s\n", mysql_error (&mysql));
! 		else if (mysql_errno (&mysql) == CR_IPSOCK_ERROR)
! 			die (STATE_WARNING, "%s\n", mysql_error (&mysql));
! 		else if (mysql_errno (&mysql) == CR_SOCKET_CREATE_ERROR)
! 			die (STATE_WARNING, "%s\n", mysql_error (&mysql));
! 		else
! 			die (STATE_CRITICAL, "%s\n", mysql_error (&mysql));
  	}
  
  	/* get the server stats */
! 	result = strdup (mysql_stat (&mysql));
  
  	/* error checking once more */
  	if (mysql_error (&mysql)) {
! 		if (mysql_errno (&mysql) == CR_SERVER_GONE_ERROR)
! 			die (STATE_CRITICAL, "%s\n", mysql_error (&mysql));
! 		else if (mysql_errno (&mysql) == CR_SERVER_LOST)
! 			die (STATE_CRITICAL, "%s\n", mysql_error (&mysql));
! 		else if (mysql_errno (&mysql) == CR_UNKNOWN_ERROR)
! 			die (STATE_CRITICAL, "%s\n", mysql_error (&mysql));
  	}
  
***************
*** 170,175 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"database", required_argument, 0, 'd'},
--- 98,103 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"database", required_argument, 0, 'd'},
***************
*** 187,191 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVP:p:u:d:H:", long_options, &option_index);
  
  		if (c == -1 || c == EOF)
--- 115,119 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVP:p:u:d:H:", longopts, &option);
  
  		if (c == -1 || c == EOF)
***************
*** 257,260 ****
--- 185,252 ----
  validate_arguments (void)
  {
+ 	if (db_user == NULL)
+ 		db_user = strdup("");
+ 
+ 	if (db_host == NULL)
+ 		db_host = strdup("");
+ 
+ 	if (db_pass == NULL)
+ 		db_pass == strdup("");
+ 
+ 	if (db == NULL)
+ 		db = strdup("");
+ 
  	return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	char *myport;
+ 	asprintf (&myport, "%d", MYSQL_PORT);
+ 
+ 	print_revision (progname, revision);
+ 
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("This program tests connections to a mysql server\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_(UT_HOST_PORT), 'P', myport);
+ 
+ 	printf (_("\
+  -d, --database=STRING\n\
+    Check database with indicated name\n\
+  -u, --username=STRING\n\
+    Connect using the indicated username\n\
+  -p, --password=STRING\n\
+    Use the indicated password to authenticate the connection\n\
+    ==> IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!! <==\n\
+    Your clear-text password will be visible as a process table entry\n"));
+ 
+ 	printf (_("\n\
+ There are no required arguments. By default, the local database with\n\
+ a server listening on MySQL standard port %d will be checked\n"), MYSQL_PORT);
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("\
+ Usage: %s [-d database] [-H host] [-P port] [-u user] [-p password]\n"),
+ 	        progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
  }

Index: check_nagios.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_nagios.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** check_nagios.c	7 Aug 2003 11:51:11 -0000	1.9
--- check_nagios.c	10 Aug 2003 06:53:22 -0000	1.10
***************
*** 26,71 ****
  #include "utils.h"
  
- void
- print_usage (void)
- {
- 	printf (_("\
- Usage: %s -F <status log file> -e <expire_minutes> -C <process_string>\n"),
- 	        progname);
- }
- 
- void
- print_help (void)
- {
- 	print_revision (progname, revision);
- 
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("\
- This plugin attempts to check the status of the Nagios process on the local\n\
- machine. The plugin will check to make sure the Nagios status log is no older\n\
- than the number of minutes specified by the <expire_minutes> option.  It also\n\
- uses the /bin/ps command to check for a process matching whatever you specify\n\
- by the <process_string> argument.\n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_("\
- -F, --filename=FILE\n\
-    Name of the log file to check\n\
- -e, --expires=INTEGER\n\
-    Seconds aging afterwhich logfile is condsidered stale\n\
- -C, --command=STRING\n\
-    Command to search for in process table\n"));
- 
- 	printf (_("\
- Example:\n\
-    ./check_nagios -e 5 \\\
-    -F /usr/local/nagios/var/status.log \\\
-    -C /usr/local/nagios/bin/nagios\n"));
- }
- 
  int process_arguments (int, char **);
  
  char *status_log = NULL;
--- 26,32 ----
  #include "utils.h"
  
  int process_arguments (int, char **);
+ void print_help (void);
+ void print_usage (void);
  
  char *status_log = NULL;
***************
*** 199,204 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"filename", required_argument, 0, 'F'},
  		{"expires", required_argument, 0, 'e'},
--- 160,165 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"filename", required_argument, 0, 'F'},
  		{"expires", required_argument, 0, 'e'},
***************
*** 226,230 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVvF:C:e:", long_options, &option_index);
  
  		if (c == -1 || c == EOF || c == 1)
--- 187,191 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVvF:C:e:", longopts, &option);
  
  		if (c == -1 || c == EOF || c == 1)
***************
*** 253,258 ****
  			else
  				die (STATE_UNKNOWN,
! 									 _("Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n"),
! 									 progname);
  			break;
  		case 'v':
--- 214,219 ----
  			else
  				die (STATE_UNKNOWN,
! 				     _("Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n"),
! 				     progname);
  			break;
  		case 'v':
***************
*** 265,270 ****
  	if (status_log == NULL)
  		die (STATE_UNKNOWN,
! 							 _("You must provide the status_log\nType '%s -h' for additional help\n"),
! 							 progname);
  	else if (process_string == NULL)
  		die (STATE_UNKNOWN,
--- 226,231 ----
  	if (status_log == NULL)
  		die (STATE_UNKNOWN,
! 		     _("You must provide the status_log\nType '%s -h' for additional help\n"),
! 		     progname);
  	else if (process_string == NULL)
  		die (STATE_UNKNOWN,
***************
*** 273,275 ****
--- 234,285 ----
  
  	return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("\
+ This plugin attempts to check the status of the Nagios process on the local\n\
+ machine. The plugin will check to make sure the Nagios status log is no older\n\
+ than the number of minutes specified by the <expire_minutes> option.  It also\n\
+ uses the /bin/ps command to check for a process matching whatever you specify\n\
+ by the <process_string> argument.\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_("\
+ -F, --filename=FILE\n\
+    Name of the log file to check\n\
+ -e, --expires=INTEGER\n\
+    Seconds aging afterwhich logfile is condsidered stale\n\
+ -C, --command=STRING\n\
+    Command to search for in process table\n"));
+ 
+ 	printf (_("\
+ Example:\n\
+    ./check_nagios -e 5 \\\
+    -F /usr/local/nagios/var/status.log \\\
+    -C /usr/local/nagios/bin/nagios\n"));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("\
+ Usage: %s -F <status log file> -e <expire_minutes> -C <process_string>\n"),
+ 	        progname);
  }

Index: check_nt.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_nt.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** check_nt.c	8 Aug 2003 16:48:26 -0000	1.16
--- check_nt.c	10 Aug 2003 06:53:22 -0000	1.17
***************
*** 29,33 ****
   *****************************************************************************/
  
- #include "config.h"
  #include "common.h"
  #include "netutils.h"
--- 29,32 ----
***************
*** 332,337 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] =
  	{ 
  		{"port",     required_argument,0,'p'},
--- 331,336 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] =
  	{ 
  		{"port",     required_argument,0,'p'},
***************
*** 367,371 ****
  
  	while (1){
! 		c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:",long_options,&option_index);
  
  		if (c==-1||c==EOF||c==1)
--- 366,370 ----
  
  	while (1){
! 		c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:",longopts,&option);
  
  		if (c==-1||c==EOF||c==1)
***************
*** 386,393 ****
  			case 'H': /* hostname */
  				if (server_address)	free(server_address);
! 				server_address = strdup(optarg);
  				break;
  			case 's': /* password */
! 				req_password = strdup (optarg);
  				break;
  			case 'p': /* port */
--- 385,392 ----
  			case 'H': /* hostname */
  				if (server_address)	free(server_address);
! 				server_address = optarg;
  				break;
  			case 's': /* password */
! 				req_password = optarg;
  				break;
  			case 'p': /* port */
***************
*** 422,426 ****
  				break;
  			case 'l': /* value list */
! 				value_list = strdup (optarg);
  				break;
  			case 'w': /* warning threshold */
--- 421,425 ----
  				break;
  			case 'l': /* value list */
! 				value_list = optarg;
  				break;
  			case 'w': /* warning threshold */

Index: check_nwstat.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_nwstat.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** check_nwstat.c	9 Aug 2003 06:01:02 -0000	1.11
--- check_nwstat.c	10 Aug 2003 06:53:22 -0000	1.12
***************
*** 706,711 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] =
  		{ 
  			{"port",     required_argument,0,'p'},
--- 706,711 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] =
  		{ 
  			{"port",     required_argument,0,'p'},
***************
*** 742,746 ****
  
  	while (1) {
! 		c = getopt_long(argc,argv,"+hoVH:t:c:w:p:v:",long_options,&option_index);
  
  		if (c==-1||c==EOF||c==1)
--- 742,746 ----
  
  	while (1) {
! 		c = getopt_long(argc,argv,"+hoVH:t:c:w:p:v:",longopts,&option);
  
  		if (c==-1||c==EOF||c==1)

Index: check_overcr.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_overcr.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** check_overcr.c	9 Aug 2003 06:01:02 -0000	1.6
--- check_overcr.c	10 Aug 2003 06:53:22 -0000	1.7
***************
*** 286,291 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"port", required_argument, 0, 'p'},
  		{"timeout", required_argument, 0, 't'},
--- 286,291 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"port", required_argument, 0, 'p'},
  		{"timeout", required_argument, 0, 't'},
***************
*** 321,326 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVH:t:c:w:p:v:", long_options,
! 									 &option_index);
  
  		if (c == -1 || c == EOF || c == 1)
--- 321,326 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVH:t:c:w:p:v:", longopts,
! 									 &option);
  
  		if (c == -1 || c == EOF || c == 1)

Index: check_pgsql.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_pgsql.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** check_pgsql.c	2 Aug 2003 16:42:57 -0000	1.13
--- check_pgsql.c	10 Aug 2003 06:53:22 -0000	1.14
***************
*** 1,25 ****
  /******************************************************************************
!  *
!  * Program: PostgreSQL plugin for Nagios
!  * License: GPL
!  *
!  * License Information:
!  *
!  * 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.
!  *
!  * $Id$
!  *
   *****************************************************************************/
  
--- 1,18 ----
  /******************************************************************************
! 
!  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.
! 
   *****************************************************************************/
  
***************
*** 33,39 ****
  };
  
- #include "config.h"
  #include "common.h"
  #include "utils.h"
  #include <libpq-fe.h>
  
--- 26,32 ----
  };
  
  #include "common.h"
  #include "utils.h"
+ #include "netutils.h"
  #include <libpq-fe.h>
  
***************
*** 122,191 ****
  
  
- void
- print_help (void)
- {
- 	char *myport;
- 
- 	asprintf (&myport, "%d", DEFAULT_PORT);
- 
- 	print_revision (progname, revision);
- 
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("Test whether a PostgreSQL DBMS is accepting connections.\n\n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_(UT_HOST_PORT), 'P', myport);
- 
- 	printf (_(UT_IPv46));
- 
- 	printf (S_("\
-   -d, --database=STRING\n\
-     Database to check (default: %s)\n\
-   -l, --logname = STRING\n\
-     Login name of user\n\
-   -p, --password = STRING\n\
-     Password (BIG SECURITY ISSUE)\n"), DEFAULT_DB);
- 
- 	printf (_(UT_WARN_CRIT));
- 
- 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
- 
- 	printf (_(UT_VERBOSE));
- 
- 	printf (S_("\nAll parameters are optional.\n\
- \n\
- This plugin tests a PostgreSQL DBMS to determine whether it is active and\n\
- accepting queries. In its current operation, it simply connects to the\n\
- specified database, and then disconnects. If no database is specified, it\n\
- connects to the template1 database, which is present in every functioning \n\
- PostgreSQL DBMS.\n"));
- 	printf (S_("\n\
- The plugin will connect to a local postmaster if no host is specified. To\n\
- connect to a remote host, be sure that the remote postmaster accepts TCP/IP\n\
- connections (start the postmaster with the -i option).\n"));
- 	printf (S_("\n\
- Typically, the nagios user (unless the --logname option is used) should be\n\
- able to connect to the database without a password. The plugin can also send\n\
- a password, but no effort is made to obsure or encrypt the password.\n"));
- 
- 	support ();
- }
- 
- void
- print_usage (void)
- {
- 	printf (S_("\
- Usage:\n %s [-H <host>] [-P <port>] [-c <critical time>] [-w <warning time>]\n\
-             [-t <timeout>]"), progname);
- 	printf (S_("[-d <database>] [-l <logname>] [-p <password>]\n"));
- 	printf (S_("\
-          %s (-h | --help) for detailed help\n\
-          %s (-V | --version) for version information\n"),
- 					progname, progname);
- }
  
  int
--- 115,118 ----
***************
*** 252,257 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"help", no_argument, 0, 'h'},
  		{"version", no_argument, 0, 'V'},
--- 179,184 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"help", no_argument, 0, 'h'},
  		{"version", no_argument, 0, 'V'},
***************
*** 270,274 ****
  	while (1) {
  		c = getopt_long (argc, argv, "hVt:c:w:H:P:d:l:p:a:",
! 		                 long_options, &option_index);
  
  		if (c == EOF)
--- 197,201 ----
  	while (1) {
  		c = getopt_long (argc, argv, "hVt:c:w:H:P:d:l:p:a:",
! 		                 longopts, &option);
  
  		if (c == EOF)
***************
*** 278,281 ****
--- 205,209 ----
  		case '?':     /* usage */
  			usage3 (_("Unknown argument"), optopt);
+ 			break;
  		case 'h':     /* help */
  			print_help ();
***************
*** 287,322 ****
  			if (!is_integer (optarg))
  				usage2 (_("Timeout Interval must be an integer"), optarg);
! 			timeout_interval = atoi (optarg);
  			break;
  		case 'c':     /* critical time threshold */
  			if (!is_integer (optarg))
  				usage2 (_("Invalid critical threshold"), optarg);
! 			tcrit = atoi (optarg);
  			break;
  		case 'w':     /* warning time threshold */
  			if (!is_integer (optarg))
  				usage2 (_("Invalid critical threshold"), optarg);
! 			twarn = atoi (optarg);
  			break;
  		case 'H':     /* host */
  			if (!is_host (optarg))
  				usage2 (_("You gave an invalid host name"), optarg);
! 			pghost = optarg;
  			break;
  		case 'P':     /* port */
  			if (!is_integer (optarg))
  				usage2 (_("Port must be an integer"), optarg);
! 			pgport = optarg;
  			break;
  		case 'd':     /* database name */
! 			if (!is_pg_dbname (optarg))
  				usage2 (_("Database name is not valid"), optarg);
! 			strncpy (dbName, optarg, NAMEDATALEN - 1);
! 			dbName[NAMEDATALEN - 1] = 0;
  			break;
  		case 'l':     /* login name */
  			if (!is_pg_logname (optarg))
  				usage2 (_("user name is not valid"), optarg);
! 			pguser = optarg;
  			break;
  		case 'p':     /* authentication password */
--- 215,256 ----
  			if (!is_integer (optarg))
  				usage2 (_("Timeout Interval must be an integer"), optarg);
! 			else
! 				timeout_interval = atoi (optarg);
  			break;
  		case 'c':     /* critical time threshold */
  			if (!is_integer (optarg))
  				usage2 (_("Invalid critical threshold"), optarg);
! 			else
! 				tcrit = atoi (optarg);
  			break;
  		case 'w':     /* warning time threshold */
  			if (!is_integer (optarg))
  				usage2 (_("Invalid critical threshold"), optarg);
! 			else
! 				twarn = atoi (optarg);
  			break;
  		case 'H':     /* host */
  			if (!is_host (optarg))
  				usage2 (_("You gave an invalid host name"), optarg);
! 			else
! 				pghost = optarg;
  			break;
  		case 'P':     /* port */
  			if (!is_integer (optarg))
  				usage2 (_("Port must be an integer"), optarg);
! 			else
! 				pgport = optarg;
  			break;
  		case 'd':     /* database name */
! 			if (!is_pg_dbname (optarg)) /* checks length and valid chars */
  				usage2 (_("Database name is not valid"), optarg);
! 			else /* we know length, and know optarg is terminated, so us strcpy */
! 				strcpy (dbName, optarg);
  			break;
  		case 'l':     /* login name */
  			if (!is_pg_logname (optarg))
  				usage2 (_("user name is not valid"), optarg);
! 			else
! 				pguser = optarg;
  			break;
  		case 'p':     /* authentication password */
***************
*** 434,435 ****
--- 368,444 ----
  -@@
  ******************************************************************************/
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	char *myport;
+ 
+ 	asprintf (&myport, "%d", DEFAULT_PORT);
+ 
+ 	print_revision (progname, revision);
+ 
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("Test whether a PostgreSQL DBMS is accepting connections.\n\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_(UT_HOST_PORT), 'P', myport);
+ 
+ 	printf (_(UT_IPv46));
+ 
+ 	printf (S_("\
+   -d, --database=STRING\n\
+     Database to check (default: %s)\n\
+   -l, --logname = STRING\n\
+     Login name of user\n\
+   -p, --password = STRING\n\
+     Password (BIG SECURITY ISSUE)\n"), DEFAULT_DB);
+ 
+ 	printf (_(UT_WARN_CRIT));
+ 
+ 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+ 
+ 	printf (_(UT_VERBOSE));
+ 
+ 	printf (S_("\nAll parameters are optional.\n\
+ \n\
+ This plugin tests a PostgreSQL DBMS to determine whether it is active and\n\
+ accepting queries. In its current operation, it simply connects to the\n\
+ specified database, and then disconnects. If no database is specified, it\n\
+ connects to the template1 database, which is present in every functioning \n\
+ PostgreSQL DBMS.\n"));
+ 	printf (S_("\n\
+ The plugin will connect to a local postmaster if no host is specified. To\n\
+ connect to a remote host, be sure that the remote postmaster accepts TCP/IP\n\
+ connections (start the postmaster with the -i option).\n"));
+ 	printf (S_("\n\
+ Typically, the nagios user (unless the --logname option is used) should be\n\
+ able to connect to the database without a password. The plugin can also send\n\
+ a password, but no effort is made to obsure or encrypt the password.\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (S_("\
+ Usage:\n %s [-H <host>] [-P <port>] [-c <critical time>] [-w <warning time>]\n\
+             [-t <timeout>]"), progname);
+ 	printf (S_("[-d <database>] [-l <logname>] [-p <password>]\n"));
+ 	printf (S_("\
+          %s (-h | --help) for detailed help\n\
+          %s (-V | --version) for version information\n"),
+ 					progname, progname);
+ }
+ 

Index: check_ping.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ping.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** check_ping.c	9 Aug 2003 06:01:03 -0000	1.21
--- check_ping.c	10 Aug 2003 06:53:22 -0000	1.22
***************
*** 163,168 ****
  	char *ptr;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		STD_LONG_OPTS,
  		{"packets", required_argument, 0, 'p'},
--- 163,168 ----
  	char *ptr;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		STD_LONG_OPTS,
  		{"packets", required_argument, 0, 'p'},
***************
*** 185,189 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "VvhnL46t:c:w:H:p:", long_options, &option_index);
  
  		if (c == -1 || c == EOF)
--- 185,189 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "VvhnL46t:c:w:H:p:", longopts, &option);
  
  		if (c == -1 || c == EOF)

Index: check_procs.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_procs.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** check_procs.c	9 Aug 2003 06:01:03 -0000	1.18
--- check_procs.c	10 Aug 2003 06:53:22 -0000	1.19
***************
*** 279,284 ****
  	char *user;
  	struct passwd *pw;
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"warning", required_argument, 0, 'w'},
  		{"critical", required_argument, 0, 'c'},
--- 279,284 ----
  	char *user;
  	struct passwd *pw;
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"warning", required_argument, 0, 'w'},
  		{"critical", required_argument, 0, 'c'},
***************
*** 304,308 ****
  	while (1) {
  		c = getopt_long (argc, argv, "Vvht:c:w:p:s:u:C:a:z:r:m:P:", 
! 			long_options, &option_index);
  
  		if (c == -1 || c == EOF)
--- 304,308 ----
  	while (1) {
  		c = getopt_long (argc, argv, "Vvht:c:w:p:s:u:C:a:z:r:m:P:", 
! 			longopts, &option);
  
  		if (c == -1 || c == EOF)
***************
*** 363,367 ****
  				break;
  			else
! 				statopts = strdup(optarg);
  			asprintf (&fmt, _("%s%sSTATE = %s"), fmt, (options ? ", " : ""), statopts);
  			options |= STAT;
--- 363,367 ----
  				break;
  			else
! 				statopts = optarg;
  			asprintf (&fmt, _("%s%sSTATE = %s"), fmt, (options ? ", " : ""), statopts);
  			options |= STAT;
***************
*** 398,402 ****
  				break;
  			else
! 				prog = strdup(optarg);
  			asprintf (&fmt, _("%s%scommand name '%s'"), fmt, (options ? ", " : ""),
  			          prog);
--- 398,402 ----
  				break;
  			else
! 				prog = optarg;
  			asprintf (&fmt, _("%s%scommand name '%s'"), fmt, (options ? ", " : ""),
  			          prog);
***************
*** 407,411 ****
  				break;
  			else
! 				args = strdup(optarg);
  			asprintf (&fmt, _("%s%sargs '%s'"), fmt, (options ? ", " : ""), args);
  			options |= ARGS;
--- 407,411 ----
  				break;
  			else
! 				args = optarg;
  			asprintf (&fmt, _("%s%sargs '%s'"), fmt, (options ? ", " : ""), args);
  			options |= ARGS;

Index: check_radius.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_radius.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** check_radius.c	7 Aug 2003 11:51:12 -0000	1.7
--- check_radius.c	10 Aug 2003 06:53:22 -0000	1.8
***************
*** 22,91 ****
  const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
- #include "config.h"
  #include "common.h"
  #include "utils.h"
  #include <radiusclient.h>
  
- void
- print_usage (void)
- {
- 	printf ("\
- Usage: %s -H host -F config_file -u username -p password [-P port]\n\
-   [-t timeout] [-r retries] [-e expect]\n", progname);
- 	printf (_(UT_HLP_VRS), progname, progname);
- }
- 
- void
- print_help (void)
- {
- 	char *myport;
- 	asprintf (&myport, "%d", PW_AUTH_UDP_PORT);
- 
- 	print_revision (progname, revision);
- 
- 	printf (_("Copyright (c) 1999 Robert August Vincent II\n"));
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf(_("Tests to see if a radius server is accepting connections.\n\n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_(UT_HOST_PORT), 'P', myport);
- 
- 	printf (_("\
-  -u, --username=STRING\n\
-     The user to authenticate\n\
-  -p, --password=STRING\n\
-     Password for autentication (SECURITY RISK)\n\
-  -F, --filename=STRING\n\
-     Configuration file\n\
-  -e, --expect=STRING\n\
-     Response string to expect from the server\n\
-  -r, --retries=INTEGER\n\
-     Number of times to retry a failed connection\n"));
- 
- 	printf (_(UT_TIMEOUT), timeout_interval);
- 
- 	printf (_("\n\
- This plugin tests a radius server to see if it is accepting connections.\n\
- \n\
- The server to test must be specified in the invocation, as well as a user\n\
- name and password. A configuration file may also be present. The format of\n\
- the configuration file is described in the radiusclient library sources.\n\n"));
- 
- 	printf (_("\
- The password option presents a substantial security issue because the\n\
- password can be determined by careful watching of the command line in\n\
- a process listing.  This risk is exacerbated because nagios will\n\
- run the plugin at regular prdictable intervals.  Please be sure that\n\
- the password used does not allow access to sensitive system resources,\n\
- otherwise compormise could occur.\n"));
- 
- 	printf (_(UT_SUPPORT));
- }
- 
  int process_arguments (int, char **);
  
  char *server = NULL;
--- 22,33 ----
  const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
  #include "common.h"
  #include "utils.h"
+ #include "netutils.h"
  #include <radiusclient.h>
  
  int process_arguments (int, char **);
+ void print_help (void);
+ void print_usage (void);
  
  char *server = NULL;
***************
*** 94,98 ****
  char *expect = NULL;
  char *config_file = NULL;
! int port = PW_AUTH_UDP_PORT;
  int retries = 1;
  int verbose = FALSE;
--- 36,40 ----
  char *expect = NULL;
  char *config_file = NULL;
! unsigned short port = PW_AUTH_UDP_PORT;
  int retries = 1;
  int verbose = FALSE;
***************
*** 160,169 ****
  	int result;
  	UINT4 client_id;
  
  	if (process_arguments (argc, argv) == ERROR)
  		usage (_("Could not parse arguments\n"));
  
  	if ((config_file && rc_read_config (config_file)) ||
! 			rc_read_dictionary (rc_conf_str ("dictionary")))
  		die (STATE_UNKNOWN, _("Config file error"));
  
--- 102,113 ----
  	int result;
  	UINT4 client_id;
+ 	char *str;
  
  	if (process_arguments (argc, argv) == ERROR)
  		usage (_("Could not parse arguments\n"));
  
+ 	str = strdup ("dictionary");
  	if ((config_file && rc_read_config (config_file)) ||
! 			rc_read_dictionary (rc_conf_str (str)))
  		die (STATE_UNKNOWN, _("Config file error"));
  
***************
*** 185,190 ****
  			NULL) return (ERROR_RC);
  
! 	rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, timeout_interval,
! 							 retries);
  
  	result = rc_send_server (&data, msg);
--- 129,134 ----
  			NULL) return (ERROR_RC);
  
! 	rc_buildreq (&data, PW_ACCESS_REQUEST, server, port, (int)timeout_interval,
! 	             retries);
  
  	result = rc_send_server (&data, msg);
***************
*** 200,204 ****
  		die (STATE_WARNING, _("Auth Failed"));
  	if (expect && !strstr (msg, expect))
! 		die (STATE_WARNING, msg);
  	if (result == OK_RC)
  		die (STATE_OK, _("Auth OK"));
--- 144,148 ----
  		die (STATE_WARNING, _("Auth Failed"));
  	if (expect && !strstr (msg, expect))
! 		die (STATE_WARNING, "%s", msg);
  	if (result == OK_RC)
  		die (STATE_OK, _("Auth OK"));
***************
*** 214,219 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"port", required_argument, 0, 'P'},
--- 158,163 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"port", required_argument, 0, 'P'},
***************
*** 255,260 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVvH:P:F:u:p:t:r:e:", long_options,
! 									 &option_index);
  
  		if (c == -1 || c == EOF || c == 1)
--- 199,204 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVvH:P:F:u:p:t:r:e:", longopts,
! 									 &option);
  
  		if (c == -1 || c == EOF || c == 1)
***************
*** 316,318 ****
--- 260,330 ----
  	}
  	return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	char *myport;
+ 	asprintf (&myport, "%d", PW_AUTH_UDP_PORT);
+ 
+ 	print_revision (progname, revision);
+ 
+ 	printf (_("Copyright (c) 1999 Robert August Vincent II\n"));
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf(_("Tests to see if a radius server is accepting connections.\n\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_(UT_HOST_PORT), 'P', myport);
+ 
+ 	printf (_("\
+  -u, --username=STRING\n\
+     The user to authenticate\n\
+  -p, --password=STRING\n\
+     Password for autentication (SECURITY RISK)\n\
+  -F, --filename=STRING\n\
+     Configuration file\n\
+  -e, --expect=STRING\n\
+     Response string to expect from the server\n\
+  -r, --retries=INTEGER\n\
+     Number of times to retry a failed connection\n"));
+ 
+ 	printf (_(UT_TIMEOUT), timeout_interval);
+ 
+ 	printf (_("\n\
+ This plugin tests a radius server to see if it is accepting connections.\n\
+ \n\
+ The server to test must be specified in the invocation, as well as a user\n\
+ name and password. A configuration file may also be present. The format of\n\
+ the configuration file is described in the radiusclient library sources.\n\n"));
+ 
+ 	printf (_("\
+ The password option presents a substantial security issue because the\n\
+ password can be determined by careful watching of the command line in\n\
+ a process listing.  This risk is exacerbated because nagios will\n\
+ run the plugin at regular prdictable intervals.  Please be sure that\n\
+ the password used does not allow access to sensitive system resources,\n\
+ otherwise compormise could occur.\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf ("\
+ Usage: %s -H host -F config_file -u username -p password [-P port]\n\
+   [-t timeout] [-r retries] [-e expect]\n", progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
  }

Index: check_real.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_real.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** check_real.c	9 Aug 2003 06:01:03 -0000	1.10
--- check_real.c	10 Aug 2003 06:53:22 -0000	1.11
***************
*** 257,262 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"IPaddress", required_argument, 0, 'I'},
--- 257,262 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"IPaddress", required_argument, 0, 'I'},
***************
*** 286,291 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVI:H:e:u:p:w:c:t:", long_options,
! 									 &option_index);
  
  		if (c == -1 || c == EOF)
--- 286,291 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVI:H:e:u:p:w:c:t:", longopts,
! 									 &option);
  
  		if (c == -1 || c == EOF)
***************
*** 298,310 ****
  				break;
  			else if (is_host (optarg))
! 				server_address = strdup(optarg);
  			else
  				usage (_("Invalid host name\n"));
  			break;
  		case 'e':									/* string to expect in response header */
! 			server_expect = strdup(optarg);
  			break;
  		case 'u':									/* server URL */
! 			server_url = strdup(optarg);
  			break;
  		case 'p':									/* port */
--- 298,310 ----
  				break;
  			else if (is_host (optarg))
! 				server_address = optarg;
  			else
  				usage (_("Invalid host name\n"));
  			break;
  		case 'e':									/* string to expect in response header */
! 			server_expect = optarg;
  			break;
  		case 'u':									/* server URL */
! 			server_url = optarg;
  			break;
  		case 'p':									/* port */

Index: check_smtp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_smtp.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** check_smtp.c	9 Aug 2003 13:36:49 -0000	1.17
--- check_smtp.c	10 Aug 2003 06:53:22 -0000	1.18
***************
*** 184,189 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"expect", required_argument, 0, 'e'},
--- 184,189 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"expect", required_argument, 0, 'e'},
***************
*** 217,221 ****
  	while (1) {
  		c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:",
! 		                 long_options, &option_index);
  
  		if (c == -1 || c == EOF)
--- 217,221 ----
  	while (1) {
  		c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:",
! 		                 longopts, &option);
  
  		if (c == -1 || c == EOF)

Index: check_snmp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_snmp.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -r1.33 -r1.34
*** check_snmp.c	8 Aug 2003 05:09:40 -0000	1.33
--- check_snmp.c	10 Aug 2003 06:53:22 -0000	1.34
***************
*** 85,89 ****
  
  char *server_address = NULL;
! char *community = DEFAULT_COMMUNITY;
  char *authpriv = NULL;
  char *proto = NULL;
--- 85,89 ----
  
  char *server_address = NULL;
! char *community = NULL;
  char *authpriv = NULL;
  char *proto = NULL;
***************
*** 93,107 ****
  char *authpasswd = NULL;
  char *privpasswd = NULL;
! char *oid = "";
! char *label = "SNMP";
! char *units = "";
! char *port = DEFAULT_PORT;
  char string_value[MAX_INPUT_BUFFER] = "";
  char **labels = NULL;
  char **unitv = NULL;
! int nlabels = 0;
! int labels_size = 8;
! int nunits = 0;
! int unitv_size = 8;
  int verbose = FALSE;
  unsigned long lower_warn_lim[MAX_OIDS];
--- 93,107 ----
  char *authpasswd = NULL;
  char *privpasswd = NULL;
! char *oid;
! char *label;
! char *units;
! char *port;
  char string_value[MAX_INPUT_BUFFER] = "";
  char **labels = NULL;
  char **unitv = NULL;
! size_t nlabels = 0;
! size_t labels_size = 8;
! size_t nunits = 0;
! size_t unitv_size = 8;
  int verbose = FALSE;
  unsigned long lower_warn_lim[MAX_OIDS];
***************
*** 113,119 ****
  int check_critical_value = FALSE;
  int eval_method[MAX_OIDS];
! char *delimiter = DEFAULT_DELIMITER;
! char *output_delim = DEFAULT_OUTPUT_DELIMITER;
! char *miblist = DEFAULT_MIBLIST;
  
  
--- 113,119 ----
  int check_critical_value = FALSE;
  int eval_method[MAX_OIDS];
! char *delimiter;
! char *output_delim;
! char *miblist;
  
  
***************
*** 132,137 ****
  	char *command_line = NULL;
  	char *response = NULL;
! 	char *outbuff = "";
! 	char *output = "";
  	char *ptr = NULL;
  	char *p2 = NULL;
--- 132,137 ----
  	char *command_line = NULL;
  	char *response = NULL;
! 	char *outbuff;
! 	char *output;
  	char *ptr = NULL;
  	char *p2 = NULL;
***************
*** 144,147 ****
--- 144,157 ----
  	i = 0;
  
+ 	oid = strdup ("");
+ 	label = strdup ("SNMP");
+ 	units = strdup ("");
+ 	port = strdup (DEFAULT_PORT);
+ 	outbuff = strdup ("");
+ 	output = strdup ("");
+ 	delimiter = strdup (DEFAULT_DELIMITER);
+ 	output_delim = strdup (DEFAULT_OUTPUT_DELIMITER);
+ 	miblist = strdup (DEFAULT_MIBLIST);
+ 
  	if (process_arguments (argc, argv) == ERROR)
  		usage (_("Incorrect arguments supplied\n"));
***************
*** 288,292 ****
  
  		/* Prepend a label for this OID if there is one */
! 		if (nlabels > 1 && i < nlabels && labels[i] != NULL)
  			asprintf (&outbuff, "%s%s%s %s%s%s", outbuff,
  			          (i == 0) ? " " : output_delim,
--- 298,302 ----
  
  		/* Prepend a label for this OID if there is one */
! 		if (nlabels > (size_t)1 && (size_t)i < nlabels && labels[i] != NULL)
  			asprintf (&outbuff, "%s%s%s %s%s%s", outbuff,
  			          (i == 0) ? " " : output_delim,
***************
*** 297,301 ****
  
  		/* Append a unit string for this OID if there is one */
! 		if (nunits > 0 && i < nunits && unitv[i] != NULL)
  			asprintf (&outbuff, "%s %s", outbuff, unitv[i]);
  
--- 307,311 ----
  
  		/* Append a unit string for this OID if there is one */
! 		if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL)
  			asprintf (&outbuff, "%s %s", outbuff, unitv[i]);
  
***************
*** 342,347 ****
  	int j = 0, jj = 0, ii = 0;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		STD_LONG_OPTS,
  		{"community", required_argument, 0, 'C'},
--- 352,357 ----
  	int j = 0, jj = 0, ii = 0;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		STD_LONG_OPTS,
  		{"community", required_argument, 0, 'C'},
***************
*** 382,386 ****
  	while (1) {
  		c = getopt_long (argc, argv, "hvVt:c:w:H:C:o:e:E:d:D:s:R:r:l:u:p:m:P:L:U:a:A:X:",
! 									 long_options, &option_index);
  
  		if (c == -1 || c == EOF)
--- 392,396 ----
  	while (1) {
  		c = getopt_long (argc, argv, "hvVt:c:w:H:C:o:e:E:d:D:s:R:r:l:u:p:m:P:L:U:a:A:X:",
! 									 longopts, &option);
  
  		if (c == -1 || c == EOF)
***************
*** 402,433 ****
  	/* Connection info */
  		case 'C':									/* group or community */
! 			community = strscpy (community, optarg);
  			break;
  		case 'H':									/* Host or server */
! 			server_address = strscpy (server_address, optarg);
  			break;
  		case 'p':       /* TCP port number */
! 			port = strscpy(port, optarg);
  			break;
  		case 'm':      /* List of MIBS  */
! 			miblist = strscpy(miblist, optarg);
  			break;
  		case 'P':     /* SNMP protocol version */
! 			proto = strscpy(proto, optarg);
  			break;
  		case 'L':     /* security level */
! 			seclevel = strscpy(seclevel,optarg);
  			break;
  		case 'U':     /* security username */
! 			secname = strscpy(secname, optarg);
  			break;
  		case 'a':     /* auth protocol */
! 			asprintf (&authproto, optarg);
  			break;
  		case 'A':     /* auth passwd */
! 			authpasswd = strscpy(authpasswd, optarg);
  			break;
  		case 'X':     /* priv passwd */
! 			privpasswd = strscpy(privpasswd, optarg);
  			break;
  		case 't':	/* timeout period */
--- 412,443 ----
  	/* Connection info */
  		case 'C':									/* group or community */
! 			community = optarg;
  			break;
  		case 'H':									/* Host or server */
! 			server_address = optarg;
  			break;
  		case 'p':       /* TCP port number */
! 			port = optarg;
  			break;
  		case 'm':      /* List of MIBS  */
! 			miblist = optarg;
  			break;
  		case 'P':     /* SNMP protocol version */
! 			proto = optarg;
  			break;
  		case 'L':     /* security level */
! 			seclevel = optarg;
  			break;
  		case 'U':     /* security username */
! 			secname = optarg;
  			break;
  		case 'a':     /* auth protocol */
! 			authproto = optarg;
  			break;
  		case 'A':     /* auth passwd */
! 			authpasswd = optarg;
  			break;
  		case 'X':     /* priv passwd */
! 			privpasswd = optarg;
  			break;
  		case 't':	/* timeout period */
***************
*** 586,590 ****
  
  	if (server_address == NULL)
! 		asprintf (&server_address, argv[optind]);
  
  	return validate_arguments ();
--- 596,603 ----
  
  	if (server_address == NULL)
! 		server_address = argv[optind];
! 
! 	if (community == NULL)
! 		community = strdup (DEFAULT_COMMUNITY);
  
  	return validate_arguments ();

Index: check_ssh.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ssh.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** check_ssh.c	9 Aug 2003 13:36:49 -0000	1.11
--- check_ssh.c	10 Aug 2003 06:53:22 -0000	1.12
***************
*** 71,76 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"help", no_argument, 0, 'h'},
  		{"version", no_argument, 0, 'V'},
--- 71,76 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"help", no_argument, 0, 'h'},
  		{"version", no_argument, 0, 'V'},
***************
*** 92,96 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+Vhv46t:H:p:", long_options, &option_index);
  
  		if (c == -1 || c == EOF)
--- 92,96 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+Vhv46t:H:p:", longopts, &option);
  
  		if (c == -1 || c == EOF)

Index: check_swap.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_swap.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** check_swap.c	7 Aug 2003 11:51:12 -0000	1.16
--- check_swap.c	10 Aug 2003 06:53:22 -0000	1.17
***************
*** 35,39 ****
  const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
! int check_swap (int usp, int free_swap);
  int process_arguments (int argc, char **argv);
  int validate_arguments (void);
--- 35,39 ----
  const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
! int check_swap (int usp, long unsigned int free_swap);
  int process_arguments (int argc, char **argv);
  int validate_arguments (void);
***************
*** 52,107 ****
  #endif
  
- void
- print_usage (void)
- {
- 	printf (_("Usage:\n\
-  %s [-a] -w <used_percentage>%% -c <used_percentage>%%\n\
-  %s [-a] -w <bytes_free> -c <bytes_free>\n\
-  %s (-h | --help) for detailed help\n\
-  %s (-V | --version) for version information\n"),
- 	        progname, progname, progname, progname);
- }
- 
- 
- 
- 
- 
- void
- print_help (void)
- {
- 	print_revision (progname, revision);
- 
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("Check swap space on local server.\n\n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_("\n\
-  -w, --warning=INTEGER\n\
-    Exit with WARNING status if less than INTEGER bytes of swap space are free\n\
-  -w, --warning=PERCENT%%\n\
-    Exit with WARNING status if less than PERCENT of swap space has been used\n\
-  -c, --critical=INTEGER\n\
-    Exit with CRITICAL status if less than INTEGER bytes of swap space are free\n\
-  -c, --critical=PERCENT%%\n\
-    Exit with CRITCAL status if less than PERCENT of swap space has been used\n\
-  -a, --allswaps\n\
-     Conduct comparisons for all swap partitions, one by one\n"));
- 
- #ifdef sun
- 	printf (_("\n\
- On Solaris, if -a specified, uses swap -l, otherwise uses swap -s.\n\
- Will be discrepencies because swap -s counts allocated swap and includes\n\
- real memory\n"));
- #endif
- 
- 	support ();
- }
- 
- 
- 
  int
  main (int argc, char **argv)
--- 52,55 ----
***************
*** 122,126 ****
  #endif
  	char str[32];
! 	char *status = "";
  
  	if (process_arguments (argc, argv) != OK)
--- 70,76 ----
  #endif
  	char str[32];
! 	char *status;
! 
! 	status = strdup("");
  
  	if (process_arguments (argc, argv) != OK)
***************
*** 234,247 ****
  
  int
! check_swap (int usp, int free_swap)
  {
  	int result = STATE_UNKNOWN;
  	if (usp >= 0 && usp >= (100.0 - crit_percent))
  		result = STATE_CRITICAL;
! 	else if (crit_size > 0 && (unsigned)free_swap <= crit_size)
  		result = STATE_CRITICAL;
  	else if (usp >= 0 && usp >= (100.0 - warn_percent))
  		result = STATE_WARNING;
! 	else if (warn_size > 0 && (unsigned)free_swap <= warn_size)
  		result = STATE_WARNING;
  	else if (usp >= 0.0)
--- 184,197 ----
  
  int
! check_swap (int usp, long unsigned int free_swap)
  {
  	int result = STATE_UNKNOWN;
  	if (usp >= 0 && usp >= (100.0 - crit_percent))
  		result = STATE_CRITICAL;
! 	else if (crit_size > 0 && free_swap <= crit_size)
  		result = STATE_CRITICAL;
  	else if (usp >= 0 && usp >= (100.0 - warn_percent))
  		result = STATE_WARNING;
! 	else if (warn_size > 0 && free_swap <= warn_size)
  		result = STATE_WARNING;
  	else if (usp >= 0.0)
***************
*** 259,264 ****
  	int cc = 0; /* critical counter */
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"warning", required_argument, 0, 'w'},
  		{"critical", required_argument, 0, 'c'},
--- 209,214 ----
  	int cc = 0; /* critical counter */
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"warning", required_argument, 0, 'w'},
  		{"critical", required_argument, 0, 'c'},
***************
*** 274,278 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+?Vvhac:w:", long_options, &option_index);
  
  		if (c == -1 || c == EOF)
--- 224,228 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+?Vvhac:w:", longopts, &option);
  
  		if (c == -1 || c == EOF)
***************
*** 297,301 ****
  				usage (_("Warning threshold must be integer or percentage!\n"));
  			}
- 			wc++;
  		case 'c':									/* critical time threshold */
  			if (is_intnonneg (optarg)) {
--- 247,250 ----
***************
*** 315,319 ****
  				usage (_("Critical threshold must be integer or percentage!\n"));
  			}
- 			cc++;
  		case 'a':									/* all swap */
  			allswaps = TRUE;
--- 264,267 ----
***************
*** 377,379 ****
--- 325,381 ----
  	}
  	return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("Check swap space on local server.\n\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_("\n\
+  -w, --warning=INTEGER\n\
+    Exit with WARNING status if less than INTEGER bytes of swap space are free\n\
+  -w, --warning=PERCENT%%\n\
+    Exit with WARNING status if less than PERCENT of swap space has been used\n\
+  -c, --critical=INTEGER\n\
+    Exit with CRITICAL status if less than INTEGER bytes of swap space are free\n\
+  -c, --critical=PERCENT%%\n\
+    Exit with CRITCAL status if less than PERCENT of swap space has been used\n\
+  -a, --allswaps\n\
+     Conduct comparisons for all swap partitions, one by one\n"));
+ 
+ #ifdef sun
+ 	printf (_("\n\
+ On Solaris, if -a specified, uses swap -l, otherwise uses swap -s.\n\
+ Will be discrepencies because swap -s counts allocated swap and includes\n\
+ real memory\n"));
+ #endif
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("Usage:\n\
+  %s [-a] -w <used_percentage>%% -c <used_percentage>%%\n\
+  %s [-a] -w <bytes_free> -c <bytes_free>\n\
+  %s (-h | --help) for detailed help\n\
+  %s (-V | --version) for version information\n"),
+ 	        progname, progname, progname, progname);
  }

Index: check_tcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_tcp.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** check_tcp.c	9 Aug 2003 13:36:49 -0000	1.34
--- check_tcp.c	10 Aug 2003 06:53:22 -0000	1.35
***************
*** 346,351 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"critical-time", required_argument, 0, 'c'},
--- 346,351 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"critical-time", required_argument, 0, 'c'},
***************
*** 392,396 ****
  	while (1) {
  		c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:",
! 		                 long_options, &option_index);
  
  		if (c == -1 || c == EOF || c == 1)
--- 392,396 ----
  	while (1) {
  		c = getopt_long (argc, argv, "+hVv46H:s:e:q:m:c:w:t:p:C:W:d:Sr:",
! 		                 longopts, &option);
  
  		if (c == -1 || c == EOF || c == 1)

Index: check_time.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_time.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** check_time.c	9 Aug 2003 13:36:49 -0000	1.8
--- check_time.c	10 Aug 2003 06:53:22 -0000	1.9
***************
*** 139,144 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"warning-variance", required_argument, 0, 'w'},
--- 139,144 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"warning-variance", required_argument, 0, 'w'},
***************
*** 170,175 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVH:w:c:W:C:p:t:", long_options,
! 									 &option_index);
  
  		if (c == -1 || c == EOF)
--- 170,175 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVH:w:c:W:C:p:t:", longopts,
! 									 &option);
  
  		if (c == -1 || c == EOF)
***************
*** 308,312 ****
  	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
  
! 	support ();
  }
  
--- 308,312 ----
  	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
  
! 	printf (_(UT_SUPPORT));
  }
  

Index: check_udp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_udp.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** check_udp.c	9 Aug 2003 13:36:49 -0000	1.10
--- check_udp.c	10 Aug 2003 06:53:22 -0000	1.11
***************
*** 106,111 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"critical", required_argument, 0, 'c'},
--- 106,111 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"critical", required_argument, 0, 'c'},
***************
*** 134,138 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVvH:e:s:c:w:t:p:", long_options, &option_index);
  
  		if (c == -1 || c == EOF || c == 1)
--- 134,138 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVvH:e:s:c:w:t:p:", longopts, &option);
  
  		if (c == -1 || c == EOF || c == 1)

Index: check_ups.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ups.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** check_ups.c	9 Aug 2003 13:36:49 -0000	1.9
--- check_ups.c	10 Aug 2003 06:53:22 -0000	1.10
***************
*** 401,406 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"ups", required_argument, 0, 'u'},
--- 401,406 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"hostname", required_argument, 0, 'H'},
  		{"ups", required_argument, 0, 'u'},
***************
*** 428,433 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVH:u:p:v:c:w:t:", long_options,
! 									 &option_index);
  
  		if (c == -1 || c == EOF)
--- 428,433 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "hVH:u:p:v:c:w:t:", longopts,
! 									 &option);
  
  		if (c == -1 || c == EOF)

Index: check_users.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_users.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** check_users.c	9 Aug 2003 13:36:49 -0000	1.7
--- check_users.c	10 Aug 2003 06:53:22 -0000	1.8
***************
*** 108,113 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"critical", required_argument, 0, 'c'},
  		{"warning", required_argument, 0, 'w'},
--- 108,113 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"critical", required_argument, 0, 'c'},
  		{"warning", required_argument, 0, 'w'},
***************
*** 121,125 ****
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVvc:w:", long_options, &option_index);
  
  		if (c == -1 || c == EOF || c == 1)
--- 121,125 ----
  
  	while (1) {
! 		c = getopt_long (argc, argv, "+hVvc:w:", longopts, &option);
  
  		if (c == -1 || c == EOF || c == 1)

Index: negate.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/negate.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** negate.c	7 Aug 2003 11:51:12 -0000	1.11
--- negate.c	10 Aug 2003 06:53:22 -0000	1.12
***************
*** 15,96 ****
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  
- ******************************************************************************/
- 
- const char *progname = "negate";
- const char *revision = "$Revision$";
- const char *copyright = "2002-2003";
- const char *email = "nagiosplug-devel at lists.sourceforge.net";
- 
- #define DEFAULT_TIMEOUT 9
- 
- #include "common.h"
- #include "utils.h"
- #include "popen.h"
- 
- void
- print_usage (void)
- {
- 	printf (_("Usage: %s [-t timeout] <definition of wrapped plugin>\n"),
- 	        progname);
- 	printf (_(UT_HLP_VRS), progname, progname);
- }
- 
- void
- print_help (void)
- {
- 	print_revision (progname, revision);
- 
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("\
- Negates the status of a plugin (returns OK for CRITICAL, and vice-versa).\n\
- \n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_(UT_TIMEOUT), DEFAULT_TIMEOUT);
- 
- 	printf (_("\
-      [keep timeout than the plugin timeout to retain CRITICAL status]\n"));
- 
- 	printf (_("\
-   negate \"/usr/local/nagios/libexec/check_ping -H host\"\n\
-     Run check_ping and invert result. Must use full path to plugin\n\
-   negate \"/usr/local/nagios/libexec/check_procs -a 'vi negate.c'\"\n\
-     Use single quotes if you need to retain spaces\n"));
- 
- 	printf (_("\
- This plugin is a wrapper to take the output of another plugin and invert it.\n\
- If the wrapped plugin returns STATE_OK, the wrapper will return STATE_CRITICAL.\n\
- If the wrapped plugin returns STATE_CRITICAL, the wrapper will return STATE_OK.\n\
- Otherwise, the output state of the wrapped plugin is unchanged.\n"));
- 
- 	printf (_(UT_SUPPORT));
- }
- 
- char *command_line;
- 
- int process_arguments (int, char **);
- int validate_arguments (void);
- /******************************************************************************
- 
- The (psuedo?)literate programming XML is contained within \@\@\- <XML> \-\@\@
- tags in the comments. With in the tags, the XML is assembled sequentially.
- You can define entities in tags. You also have all the #defines available as
- entities.
- 
- Please note that all tags must be lowercase to use the DocBook XML DTD.
- 
  @@-<article>
  
  <sect1>
  <title>Quick Reference</title>
- <!-- The refentry forms a manpage -->
  <refentry>
! <refmeta>
! <manvolnum>5<manvolnum>
! </refmeta>
  <refnamdiv>
  <refname>&progname;</refname>
--- 15,24 ----
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  
  @@-<article>
  
  <sect1>
  <title>Quick Reference</title>
  <refentry>
! <refmeta><manvolnum>5<manvolnum></refmeta>
  <refnamdiv>
  <refname>&progname;</refname>
***************
*** 120,136 ****
  <listitem>Add option to do regex substitution in output text</listitem>
  </itemizedlist>
! </sect2>
! 
  
- <sect2>
- <title>Functions</title>
- -@@
  ******************************************************************************/
  
  int
  main (int argc, char **argv)
  {
  	int found = 0, result = STATE_UNKNOWN;
! 	char input_buffer[MAX_INPUT_BUFFER];
  
  	if (process_arguments (argc, argv) == ERROR)
--- 48,78 ----
  <listitem>Add option to do regex substitution in output text</listitem>
  </itemizedlist>
! </sect2>-@@
  
  ******************************************************************************/
  
+ const char *progname = "negate";
+ const char *revision = "$Revision$";
+ const char *copyright = "2002-2003";
+ const char *email = "nagiosplug-devel at lists.sourceforge.net";
+ 
+ #define DEFAULT_TIMEOUT 9
+ 
+ #include "common.h"
+ #include "utils.h"
+ #include "popen.h"
+ 
+ char *command_line;
+ 
+ int process_arguments (int, char **);
+ int validate_arguments (void);
+ void print_help (void);
+ void print_usage (void);
+ 
  int
  main (int argc, char **argv)
  {
  	int found = 0, result = STATE_UNKNOWN;
! 	char *buf;
  
  	if (process_arguments (argc, argv) == ERROR)
***************
*** 152,170 ****
  	}
  
! 	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
  		found++;
! 		if (strchr (input_buffer, '\n')) {
! 			input_buffer[strcspn (input_buffer, "\n")] = 0;
! 			printf ("%s\n", input_buffer);
! 		}
! 		else {
! 			printf ("%s\n", input_buffer);
! 		}
  	}
  
  	if (!found)
! 		die (STATE_UNKNOWN,\
! 		           _("%s problem - No data recieved from host\nCMD: %s\n"),\
! 		           argv[0],	command_line);
  
  	/* close the pipe */
--- 94,107 ----
  	}
  
! 	buf = malloc(MAX_INPUT_BUFFER);
! 	while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) {
  		found++;
! 		printf ("%s", buf);
  	}
  
  	if (!found)
! 		die (STATE_UNKNOWN,
! 		     _("%s problem - No data recieved from host\nCMD: %s\n"),\
! 		     argv[0], command_line);
  
  	/* close the pipe */
***************
*** 172,176 ****
  
  	/* WARNING if output found on stderr */
! 	if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
  		result = max_state (result, STATE_WARNING);
  
--- 109,113 ----
  
  	/* WARNING if output found on stderr */
! 	if (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr))
  		result = max_state (result, STATE_WARNING);
  
***************
*** 190,193 ****
--- 127,133 ----
  /******************************************************************************
  @@-
+ <sect2>
+ <title>Functions</title>
+ 
  <sect3>
  <title>process_arguments</title>
***************
*** 197,201 ****
  
  <para>Aside from the standard 'help' and 'version' options, there
! is a only a 'timeout' option.No validation is currently done.</para>
  
  </sect3>
--- 137,141 ----
  
  <para>Aside from the standard 'help' and 'version' options, there
! is a only a 'timeout' option.</para>
  
  </sect3>
***************
*** 209,214 ****
  	int c;
  
! 	int option_index = 0;
! 	static struct option long_options[] = {
  		{"help", no_argument, 0, 'h'},
  		{"version", no_argument, 0, 'V'},
--- 149,154 ----
  	int c;
  
! 	int option = 0;
! 	static struct option longopts[] = {
  		{"help", no_argument, 0, 'h'},
  		{"version", no_argument, 0, 'V'},
***************
*** 219,223 ****
  	while (1) {
  		c = getopt_long (argc, argv, "+hVt:",
! 		                 long_options, &option_index);
  
  		if (c == -1 || c == EOF)
--- 159,163 ----
  	while (1) {
  		c = getopt_long (argc, argv, "+hVt:",
! 		                 longopts, &option);
  
  		if (c == -1 || c == EOF)
***************
*** 227,233 ****
--- 167,175 ----
  		case '?':     /* help */
  			usage3 (_("Unknown argument"), optopt);
+ 			break;
  		case 'h':     /* help */
  			print_help ();
  			exit (EXIT_SUCCESS);
+ 			break;
  		case 'V':     /* version */
  			print_revision (progname, revision);
***************
*** 236,240 ****
  			if (!is_integer (optarg))
  				usage2 (_("Timeout Interval must be an integer"), optarg);
! 			timeout_interval = atoi (optarg);
  			break;
  		}
--- 178,183 ----
  			if (!is_integer (optarg))
  				usage2 (_("Timeout Interval must be an integer"), optarg);
! 			else
! 				timeout_interval = atoi (optarg);
  			break;
  		}
***************
*** 268,272 ****
  	return STATE_OK;
  }
- 
  
  /******************************************************************************
--- 211,214 ----
***************
*** 277,278 ****
--- 219,272 ----
  -@@
  ******************************************************************************/
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("\
+ Negates the status of a plugin (returns OK for CRITICAL, and vice-versa).\n\
+ \n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_(UT_TIMEOUT), DEFAULT_TIMEOUT);
+ 
+ 	printf (_("\
+      [keep timeout than the plugin timeout to retain CRITICAL status]\n"));
+ 
+ 	printf (_("\
+   negate \"/usr/local/nagios/libexec/check_ping -H host\"\n\
+     Run check_ping and invert result. Must use full path to plugin\n\
+   negate \"/usr/local/nagios/libexec/check_procs -a 'vi negate.c'\"\n\
+     Use single quotes if you need to retain spaces\n"));
+ 
+ 	printf (_("\
+ This plugin is a wrapper to take the output of another plugin and invert it.\n\
+ If the wrapped plugin returns STATE_OK, the wrapper will return STATE_CRITICAL.\n\
+ If the wrapped plugin returns STATE_CRITICAL, the wrapper will return STATE_OK.\n\
+ Otherwise, the output state of the wrapped plugin is unchanged.\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("Usage: %s [-t timeout] <definition of wrapped plugin>\n"),
+ 	        progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
+ }

Index: popen.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/popen.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** popen.c	9 Aug 2003 00:41:06 -0000	1.6
--- popen.c	10 Aug 2003 06:53:22 -0000	1.7
***************
*** 19,24 ****
   ******************************************************************************/
  
! #include <config.h>
! #include <common.h>
  
  /* extern so plugin has pid to kill exec'd process on timeouts */
--- 19,23 ----
   ******************************************************************************/
  
! #include "common.h"
  
  /* extern so plugin has pid to kill exec'd process on timeouts */

Index: urlize.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/urlize.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** urlize.c	4 Aug 2003 11:38:27 -0000	1.7
--- urlize.c	10 Aug 2003 06:53:22 -0000	1.8
***************
*** 1,40 ****
  /******************************************************************************
!  *
!  * urlize.c
!  *
!  * Program: plugin wrapper for Nagios
!  * License: GPL
!  * Copyright (c) 2000 Karl DeBisschop (kdebiss at alum.mit.edu)
!  *
!  * Last Modified: $Date$
!  * 2000-06-01 Karl DeBisschop <karl at debisschop.net>
!  *  Written based of concept in urlize.pl
!  *
!  * Usage: urlize <url> <plugin> <arg1> ... <argN>
!  *
!  * Description:
!  *
!  * This plugin wraps the text output of another command (plugin) in HTML
!  * <A> tags, thus displaying the plugin output in as a clickable link in
!  * the Nagios status screen.  The return status is the same as the plugin
!  * invoked by urlize
!  *
!  * License Information:
!  *
!  * 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 = "urlize";
--- 1,19 ----
  /******************************************************************************
! 
!  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 = "urlize";
***************
*** 47,56 ****
  #include "popen.h"
  
! void
! print_usage (void)
  {
! 	printf (_("Usage:\n %s <url> <plugin> <arg1> ... <argN>\n"), progname);
  }
  
  void
  print_help (void)
--- 26,124 ----
  #include "popen.h"
  
! void print_help (void);
! void print_usage (void);
! 
! int
! main (int argc, char **argv)
  {
! 	int found = 0, result = STATE_UNKNOWN;
! 	char *url = NULL;
! 	char *cmd;
! 	char *buf;
! 
! 	int c;
! 	int option = 0;
! 	static struct option longopts[] = {
! 		{"help", no_argument, 0, 'h'},
! 		{"version", no_argument, 0, 'V'},
! 		{"url", required_argument, 0, 'u'},
! 		{0, 0, 0, 0}
! 	};
! 
! 	while (1) {
! 		c = getopt_long (argc, argv, "+hVu:", longopts, &option);
! 
! 		if (c == -1 || c == EOF)
! 			break;
! 
! 		switch (c) {
! 		case 'h':     /* help */
! 			print_help ();
! 			exit (EXIT_SUCCESS);
! 			break;
! 		case 'V':     /* version */
! 			print_revision (progname, revision);
! 			exit (EXIT_SUCCESS);
! 			break;
! 		case 'u':
! 			url = strdup (argv[optind]);
! 			break;
! 		case '?':
! 		default:
! 			usage3 (_("Unknown argument"), optopt);
! 			break;
! 		}
! 	}
! 
! 	if (url == NULL)
! 		url = strdup (argv[optind++]);
! 
! 	cmd = strdup (argv[optind++]);
! 	for (c = optind; c < argc; c++) {
! 		asprintf (&cmd, "%s %s", cmd, argv[c]);
! 	}
! 
! 	child_process = spopen (cmd);
! 	if (child_process == NULL) {
! 		printf (_("Could not open pipe: %s\n"), cmd);
! 		exit (STATE_UNKNOWN);
! 	}
! 
! 	child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
! 	if (child_stderr == NULL) {
! 		printf (_("Could not open stderr for %s\n"), cmd);
! 	}
! 
! 	buf = malloc(MAX_INPUT_BUFFER);
! 	printf ("<A href=\"%s\">", argv[1]);
! 	while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) {
! 		found++;
! 		printf ("%s", buf);
! 	}
! 
! 	if (!found)
! 		die (STATE_UNKNOWN,
! 		     _("%s problem - No data recieved from host\nCMD: %s</A>\n"),
! 		     argv[0], cmd);
! 
! 	/* close the pipe */
! 	result = spclose (child_process);
! 
! 	/* WARNING if output found on stderr */
! 	if (fgets (buf, MAX_INPUT_BUFFER - 1, child_stderr))
! 		result = max_state (result, STATE_WARNING);
! 
! 	/* close stderr */
! 	(void) fclose (child_stderr);
! 
! 	printf ("</A>\n");
! 	return result;
  }
  
+ 
+ 
+ 
+ 
+ 
  void
  print_help (void)
***************
*** 82,160 ****
  \n\
      urlize http://example.com/ \"check_http -H example.com -r 'two words'\"\n"));
- 	exit (STATE_OK);
- }
- 
- int
- main (int argc, char **argv)
- {
- 	int i = 0, found = 0, result = STATE_UNKNOWN;
- 	char *cmd = NULL;
- 	char input_buffer[MAX_INPUT_BUFFER];
- 
- 	if (argc < 2) {
- 		print_usage ();
- 		exit (STATE_UNKNOWN);
- 	}
- 
- 	if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) {
- 		print_help ();
- 		exit (STATE_OK);
- 	}
- 
- 	if (!strcmp (argv[1], "-V") || !strcmp (argv[1], "--version")) {
- 		print_revision (progname, revision);
- 		exit (STATE_OK);
- 	}
- 
- 	if (argc < 2) {
- 		print_usage ();
- 		exit (STATE_UNKNOWN);
- 	}
- 
- 	asprintf (&cmd, "%s", argv[2]);
- 	for (i = 3; i < argc; i++) {
- 		asprintf (&cmd, "%s %s", cmd, argv[i]);
- 	}
- 
- 	child_process = spopen (cmd);
- 	if (child_process == NULL) {
- 		printf (_("Could not open pipe: %s\n"), cmd);
- 		exit (STATE_UNKNOWN);
- 	}
  
! 	child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
! 	if (child_stderr == NULL) {
! 		printf (_("Could not open stderr for %s\n"), cmd);
! 	}
  
- 	printf ("<A href=\"%s\">", argv[1]);
- 	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
- 		found++;
- 		if (index (input_buffer, '\n')) {
- 			input_buffer[strcspn (input_buffer, "\n")] = 0;
- 			printf ("%s", input_buffer);
- 		}
- 		else {
- 			printf ("%s", input_buffer);
- 		}
- 	}
  
- 	if (!found) {
- 		printf (_("%s problem - No data recieved from host\nCMD: %s</A>\n"), argv[0],
- 						cmd);
- 		exit (STATE_UNKNOWN);
- 	}
  
- 	/* close the pipe */
- 	result = spclose (child_process);
  
! 	/* WARNING if output found on stderr */
! 	if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
! 		result = max_state (result, STATE_WARNING);
! 
! 	/* close stderr */
! 	(void) fclose (child_stderr);
! 
! 	printf ("</A>\n");
! 	return result;
  }
--- 150,163 ----
  \n\
      urlize http://example.com/ \"check_http -H example.com -r 'two words'\"\n"));
  
! 	printf (_(UT_SUPPORT));
! }
  
  
  
  
! void
! print_usage (void)
! {
! 	printf (_("Usage:\n %s <url> <plugin> <arg1> ... <argN>\n"), progname);
  }





More information about the Commits mailing list