[Nagiosplug-checkins] CVS: nagiosplug/plugins common.h,NONE,1.1 netutils.h,NONE,1.1 popen.h,NONE,1.1 utils.h,NONE,1.1 .cvsignore,1.5,1.6 Makefile.am,1.22,1.23 utils.c,1.18,1.19 common.h.in,1.6,NONE netutils.h.in,1.3,NONE popen.h.in,1.2,NONE utils.h.in,1.10,NONE version.h.in,1.2,NONE

Jeremy T. Bouse undrgrid at users.sourceforge.net
Wed Mar 12 22:52:22 CET 2003


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

Modified Files:
	.cvsignore Makefile.am utils.c 
Added Files:
	common.h netutils.h popen.h utils.h 
Removed Files:
	common.h.in netutils.h.in popen.h.in utils.h.in version.h.in 
Log Message:
Updated cvs ignore files to reflect changes
Moved header files from being ran through configure to standard
Removed auto-tools scripts that get added by automake


--- NEW FILE ---
/******************************************************************************
 *
 * Nagios plugins common include file
 *
 * License: GPL
 * Copyright (c) 1999 Ethan Galstad (nagios at nagios.org)
 *
 * Last Modified: 11-05-1999
 *
 * Description:
 *
 * This file contains common include files and defines used in many of
 * the plugins.
 *
 * 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.
 *
 *****************************************************************************/

#include <stdio.h>							/* obligatory includes */
#include <stdlib.h>
#include <errno.h>

#include "config.h"

#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif
#endif

#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif

#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif

#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif

/* TODO: define can be removed when all ifdef in each plugin has been removed */
#define HAVE_GETOPT_H
#include <getopt.h>

#include <ctype.h>

#if HAVE_LWRES_NETDB_H
#include <lwres/netdb.h>
#elif !HAVE_GETADDRINFO
#include "getaddrinfo.h"
#else
#include <netdb.h>
#endif

/*
 *
 * Missing Functions
 *
 */

#ifndef HAVE_STRTOL
# define strtol(a,b,c) atol((a))
#endif

#ifndef HAVE_STRTOUL
# define strtoul(a,b,c) (unsigned long)atol((a))
#endif

#ifndef HAVE_ASPRINTF
int asprintf(char **strp, const char *fmt, ...);
#endif

#ifndef HAVE_VASPRINTF
/* int vasprintf(char **strp, const char *fmt, va_list ap); */
#endif

#ifndef HAVE_SNPRINTF
int snprintf(char *str, size_t size, const  char  *format, ...);
#endif

#ifndef HAVE_VSNPRINTF
int vsnprintf(char *str, size_t size, const char  *format, va_list ap);
#endif

/*
 *
 * Standard Values
 *
 */

#define OK		0
#define ERROR		-1

#define TRUE		1
#define FALSE		0

#define	STATE_CRITICAL 	2				/* service state return codes */
#define STATE_WARNING 	1
#define STATE_OK       	0
#define STATE_UNKNOWN  	3
#define STATE_DEPENDENT	4

#define DEFAULT_SOCKET_TIMEOUT	10	/* timeout after 10 seconds */

#define MAX_INPUT_BUFFER	1024	/* max size of most buffers we use */

#define MAX_HOST_ADDRESS_LENGTH	256	/* max size of a host address */


#ifndef HAVE_SNPRINTF
/*
int snprintf (char *str, size_t n, const char *fmt, ...);
int snprintf (char *str, size_t n, const char *fmt, ...)
{
	char *buf;
	int i;
	int j=0;
	va_list ap;
	int d;
	char c, *p, *s;
	
	if((buf=malloc(n))==NULL){ 
		puts("could not malloc snprintf buffer\n");
		exit(-1);
	}
	va_start(ap,fmt);
	i=strlen(fmt);
	while((jj=index(&fmt[j],'%'))){
		j+=jj+1;
		switch fmt[j]
			{
			case 's':
				s = va_arg(ap, char *);
				i+=strlen(s);
				break;
			case 'd':
				d = va_arg(ap, int);
				i++;
				if (d<0) i++;
				while((d=d/10)>0) i++;
				break;
			case 'c':
				c = va_arg(ap, char);
				i++;
				break;
			}
	}
	va_end(ap);
	vsprintf(buf,fmt,ap);
	strcpy(str,buf[1:n-1]);
	exit(result);
}
*/
#endif

--- NEW FILE ---
/******************************************************************************
*
* Nagios plugins net utilities include file
*
* License: GPL
* Copyright (c) 1999 Ethan Galstad (nagios at nagios.org)
*
* Last Modified: $Date: 2003/03/13 06:51:18 $
*
* Description:
*
* This file contains common include files and function definitions
* used in many of the plugins.
*
* 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.
*
******************************************************************************/

#include "config.h"
#include "common.h"
#include <netinet/in.h>
#include <arpa/inet.h>

RETSIGTYPE socket_timeout_alarm_handler (int);

int process_tcp_request2 (char *address, int port, char *sbuffer,
	char *rbuffer, int rsize);
int process_tcp_request (char *address, int port, char *sbuffer,
	char *rbuffer, int rsize);
int process_udp_request (char *address, int port, char *sbuffer,
	char *rbuffer, int rsize);
int process_request (char *address, int port, char *proto, char *sbuffer,
	char *rbuffer, int rsize);

int my_tcp_connect (char *address, int port, int *sd);
int my_udp_connect (char *address, int port, int *sd);
int my_connect (char *address, int port, int *sd, int proto);

int socket_timeout = DEFAULT_SOCKET_TIMEOUT;

--- NEW FILE ---
FILE *spopen (const char *);
int spclose (FILE *);
RETSIGTYPE popen_timeout_alarm_handler (int);

extern int timeout_interval;
pid_t *childpid;
int *child_stderr_array;
FILE *child_process;
FILE *child_stderr;

--- NEW FILE ---
/* header file for nagios plugins utils.c */

/* this file should be included in all plugins */

/* The purpose of this package is to provide safer alternantives to C
functions that might otherwise be vulnerable to hacking. This
currently includes a standard suite of validation routines to be sure
that an string argument acually converts to its intended type and a
suite of string handling routine that do their own memory management
in order to resist overflow attacks. In addition, a few functions are
provided to standardize version and error reporting accross the entire
suite of plugins. */

/* Standardize version information, termination */

char *my_basename (char *);
void support (void);
char *clean_revstring (const char *revstring);
void print_revision (const char *, const char *);
void terminate (int result, char *msg, ...);
extern RETSIGTYPE timeout_alarm_handler (int);

/* Handle timeouts */

time_t start_time, end_time;
int timeout_interval = DEFAULT_SOCKET_TIMEOUT;

/* Test input types */

int is_host (char *);
int is_addr (char *);
int is_inet_addr (char *);
#ifdef USE_IPV6
int is_inet6_addr (char *);
#endif
int is_hostname (char *);

int is_integer (char *);
int is_intpos (char *);
int is_intneg (char *);
int is_intnonneg (char *);
int is_intpercent (char *);

int is_numeric (char *);
int is_positive (char *);
int is_negative (char *);
int is_nonnegative (char *);
int is_percentage (char *);

int is_option (char *);

/* generalized timer that will do milliseconds if available */
#ifndef HAVE_STRUCT_TIMEVAL
struct timeval {
	long tv_sec;        /* seconds */
	long tv_usec;  /* microseconds */
};
#endif

#ifndef HAVE_GETTIMEOFDAY
int gettimeofday(struct timeval *tv, struct timezone *tz);
#endif

double delta_time (struct timeval tv);

/* Handle strings safely */

void strip (char *buffer);
char *strscpy (char *dest, char *src);
char *strscat (char *dest, char *src);
char *strnl (char *str);
char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */
char *strpcpy (char *dest, const char *src, const char *str);
char *strpcat (char *dest, const char *src, const char *str);

int max_state (int a, int b);

void usage (char *msg);
void usage2(char *msg, char *arg);
void usage3(char *msg, char arg);


#define max(a,b) (((a)>(b))?(a):(b))

#define state_text(a) \
(a)==0?"OK":\
(a)==1?"WARNING":\
(a)==2?"CRITICAL":\
(a)==3?"UNKNOWN":\
(a)==4?"DEPENDENT":\
"UNKNOWN"

/* The idea here is that, although not every plugin will use all of these, 
   most will or should.  Therefore, for consistency, these very common 
   options should have only these meanings throughout the overall suite */

#define STD_LONG_OPTS \
{"version",no_argument,0,'V'},\
{"verbose",no_argument,0,'v'},\
{"help",no_argument,0,'h'},\
{"timeout",required_argument,0,'t'},\
{"critical",required_argument,0,'c'},\
{"warning",required_argument,0,'w'},\
{"hostname",required_argument,0,'H'}


Index: .cvsignore
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/.cvsignore,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** .cvsignore	12 Mar 2003 02:47:56 -0000	1.5
--- .cvsignore	13 Mar 2003 06:51:17 -0000	1.6
***************
*** 41,45 ****
  negate
  stamp-h*
! *.h
  Makefile
  Makefile.in
--- 41,45 ----
  negate
  stamp-h*
! config.h
  Makefile
  Makefile.in

Index: Makefile.am
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/Makefile.am,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** Makefile.am	8 Mar 2003 01:59:31 -0000	1.22
--- Makefile.am	13 Mar 2003 06:51:17 -0000	1.23
***************
*** 17,21 ****
  check_tcp_programs = check_ftp check_imap check_nntp check_pop
  
! EXTRA_DIST = t utils.c netutils.c popen.c
  
  PLUGINHDRS = common.h config.h
--- 17,21 ----
  check_tcp_programs = check_ftp check_imap check_nntp check_pop
  
! EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h 
  
  PLUGINHDRS = common.h config.h

Index: utils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** utils.c	12 Mar 2003 17:11:20 -0000	1.18
--- utils.c	13 Mar 2003 06:51:18 -0000	1.19
***************
*** 14,18 ****
  #include "config.h"
  #include "common.h"
- #include "version.h"
  #include <stdarg.h>
  #include <limits.h>
--- 14,17 ----

--- common.h.in DELETED ---

--- netutils.h.in DELETED ---

--- popen.h.in DELETED ---

--- utils.h.in DELETED ---

--- version.h.in DELETED ---





More information about the Commits mailing list