Imported Upstream version 1.4.8
This commit is contained in:
parent
6a280f6f24
commit
6dd54dd8e2
352 changed files with 42813 additions and 27251 deletions
|
@ -6,7 +6,7 @@
|
|||
* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
|
||||
* Copyright (c) 2000-2006 nagios-plugins team
|
||||
*
|
||||
* Last Modified: $Date: 2006/10/19 23:53:28 $
|
||||
* Last Modified: $Date: 2007/02/07 14:06:11 $
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
|
@ -28,12 +28,12 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: check_swap.c,v 1.56 2006/10/19 23:53:28 opensides Exp $
|
||||
* $Id: check_swap.c,v 1.59 2007/02/07 14:06:11 hweiss Exp $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
const char *progname = "check_swap";
|
||||
const char *revision = "$Revision: 1.56 $";
|
||||
const char *revision = "$Revision: 1.59 $";
|
||||
const char *copyright = "2000-2006";
|
||||
const char *email = "nagiosplug-devel@lists.sourceforge.net";
|
||||
|
||||
|
@ -41,6 +41,22 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
|
|||
#include "popen.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef HAVE_DECL_SWAPCTL
|
||||
# ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
# endif
|
||||
# ifdef HAVE_SYS_SWAP_H
|
||||
# include <sys/swap.h>
|
||||
# endif
|
||||
# ifdef HAVE_SYS_STAT_H
|
||||
# include <sys/stat.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef SWAP_CONVERSION
|
||||
# define SWAP_CONVERSION 1
|
||||
#endif
|
||||
|
||||
int check_swap (int usp, float free_swap_mb);
|
||||
int process_arguments (int argc, char **argv);
|
||||
int validate_arguments (void);
|
||||
|
@ -236,22 +252,33 @@ main (int argc, char **argv)
|
|||
# ifdef CHECK_SWAP_SWAPCTL_SVR4
|
||||
|
||||
/* get the number of active swap devices */
|
||||
nswaps=swapctl(SC_GETNSWP, NULL);
|
||||
if((nswaps=swapctl(SC_GETNSWP, NULL))== -1)
|
||||
die(STATE_UNKNOWN, _("Error getting swap devices\n") );
|
||||
|
||||
if(nswaps == 0)
|
||||
die(STATE_OK, _("SWAP OK: No swap devices defined\n"));
|
||||
|
||||
if(verbose >= 3)
|
||||
printf("Found %d swap device(s)\n", nswaps);
|
||||
|
||||
/* initialize swap table + entries */
|
||||
tbl=(swaptbl_t*)malloc(sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps));
|
||||
|
||||
if(tbl==NULL)
|
||||
die(STATE_UNKNOWN, _("malloc() failed!\n"));
|
||||
|
||||
memset(tbl, 0, sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps));
|
||||
tbl->swt_n=nswaps;
|
||||
for(i=0;i<nswaps;i++){
|
||||
ent=&tbl->swt_ent[i];
|
||||
ent->ste_path=(char*)malloc(sizeof(char)*MAXPATHLEN);
|
||||
if((tbl->swt_ent[i].ste_path=(char*)malloc(sizeof(char)*MAXPATHLEN)) == NULL)
|
||||
die(STATE_UNKNOWN, _("malloc() failed!\n"));
|
||||
}
|
||||
|
||||
/* and now, tally 'em up */
|
||||
swapctl_res=swapctl(SC_LIST, tbl);
|
||||
if(swapctl_res < 0){
|
||||
perror(_("swapctl failed: "));
|
||||
result = STATE_WARNING;
|
||||
die(STATE_UNKNOWN, _("Error in swapctl call\n"));
|
||||
}
|
||||
|
||||
for(i=0;i<nswaps;i++){
|
||||
|
@ -293,7 +320,7 @@ main (int argc, char **argv)
|
|||
swapctl_res=swapctl(SWAP_STATS, ent, nswaps);
|
||||
if(swapctl_res < 0){
|
||||
perror(_("swapctl failed: "));
|
||||
result = STATE_WARNING;
|
||||
die(STATE_UNKNOWN, _("Error in swapctl call\n"));
|
||||
}
|
||||
|
||||
for(i=0;i<nswaps;i++){
|
||||
|
@ -441,7 +468,7 @@ process_arguments (int argc, char **argv)
|
|||
print_help ();
|
||||
exit (STATE_OK);
|
||||
case '?': /* error */
|
||||
usage2 (_("Unknown argument"), optarg);
|
||||
usage5 ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue