*** check_swap.c.orig Fri Oct 20 00:53:28 2006 --- check_swap.c Tue Nov 7 14:54:35 2006 *************** *** 37,42 **** --- 37,48 ---- const char *copyright = "2000-2006"; const char *email = "nagiosplug-devel@lists.sourceforge.net"; + /* required to work correctly on solaris (else gets 'Bad Address' errors) */ + /* #ifdef HAVE_SYS_STAT_H - using this one doesnt work on solaris */ + #ifdef __sun__ + #include + #endif + #include "common.h" #include "popen.h" #include "utils.h" *************** *** 236,257 **** # ifdef CHECK_SWAP_SWAPCTL_SVR4 /* get the number of active swap devices */ ! nswaps=swapctl(SC_GETNSWP, NULL); /* initialize swap table + entries */ tbl=(swaptbl_t*)malloc(sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps)); memset(tbl, 0, sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps)); tbl->swt_n=nswaps; for(i=0;iswt_ent[i]; ! ent->ste_path=(char*)malloc(sizeof(char)*MAXPATHLEN); } /* and now, tally 'em up */ swapctl_res=swapctl(SC_LIST, tbl); if(swapctl_res < 0){ ! perror(_("swapctl failed: ")); ! result = STATE_WARNING; } for(i=0;i 0) + (void)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) + perror(_(argv[0])), exit(STATE_UNKNOWN); + memset(tbl, 0, sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps)); tbl->swt_n=nswaps; for(i=0;iswt_ent[i].ste_path=(char*)malloc(sizeof(char)*MAXPATHLEN)) == NULL) ! perror(_(argv[0])), exit(STATE_UNKNOWN); } /* and now, tally 'em up */ swapctl_res=swapctl(SC_LIST, tbl); if(swapctl_res < 0){ ! perror(_("swapctl failed")), exit(STATE_UNKNOWN); } for(i=0;i