diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2004-08-19 19:05:49 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2004-08-19 19:05:49 +0000 |
commit | d5ae799b8792708cad68d57c966b562dc442dccd (patch) | |
tree | e2890c5c039f7572de2d9fae84cd67e0754ab5bc /plugins/check_swap.c | |
parent | c25c672eb2d17f8f10b8e28389a2fd9c91a9b81b (diff) | |
download | monitoring-plugins-d5ae799b8792708cad68d57c966b562dc442dccd.tar.gz |
Patch for tru64 using swapctl calls (Sean Finney)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@890 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_swap.c')
-rw-r--r-- | plugins/check_swap.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index 1155ed0e..f6bbd335 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c @@ -52,7 +52,7 @@ main (int argc, char **argv) { int percent_used, percent; unsigned long long total_swap = 0, used_swap = 0, free_swap = 0; - unsigned long long dsktotal, dskused, dskfree, tmp; + unsigned long long dsktotal = 0, dskused = 0, dskfree = 0, tmp = 0; int result = STATE_OK; char input_buffer[MAX_INPUT_BUFFER]; char *perf; @@ -64,6 +64,11 @@ main (int argc, char **argv) char *temp_buffer; char *swap_command; char *swap_format; +# else +# ifdef HAVE_DECL_SWAPCTL + int i=0, nswaps=0; + swaptbl_t tbl; +# endif /* HAVE_DECL_SWAPCTL */ # endif #endif char str[32]; @@ -230,6 +235,43 @@ main (int argc, char **argv) /* close the pipe */ if (spclose (child_process)) result = max_state (result, STATE_WARNING); +# else +# ifdef HAVE_DECL_SWAPCTL + + /* initialize swap table entries */ + memset(&tbl, 0, sizeof(swaptbl_t)); + tbl.swt_ent[0].ste_path=(char*)malloc(sizeof(char)*(MAXPATHLEN+1)); + memset(tbl.swt_ent[0].ste_path, 0, sizeof(char)*(MAXPATHLEN+1)); + tbl.swt_n=1; + + /* get the number of active swap devices */ + nswaps=swapctl(SC_GETNSWP, NULL); + + /* and now, tally 'em up */ + for(i=0;i<nswaps;i++){ + swapctl(SC_LIST, &tbl); + /* on tru64, swap is stored in 8k pages. i'd + use conv_factor or SWAP_CONVERSION, but they're + both buried under a bunch of ifdef's. ideally + all functions could call getpagesize(2)... */ + dsktotal = tbl.swt_ent[0].ste_pages / 128; + dskfree = tbl.swt_ent[0].ste_free / 128; + dskused = ( total_swap - free_swap ); + + if(allswaps && dsktotal > 0){ + percent = 100 * (((double) dskused) / ((double) dsktotal)); + result = max_state (result, check_swap (percent, dskfree)); + } + + total_swap += dsktotal; + free_swap += dskfree; + used_swap += dskused; + } + + /* and clean up after ourselves */ + free(tbl.swt_ent[0].ste_path); + +# endif /* HAVE_DECL_SWAPCTL */ # endif /* HAVE_SWAP */ #endif /* HAVE_PROC_MEMINFO */ |