summaryrefslogtreecommitdiffstats
path: root/web/attachments/202053-check_swap.c.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/202053-check_swap.c.patch')
-rw-r--r--web/attachments/202053-check_swap.c.patch92
1 files changed, 92 insertions, 0 deletions
diff --git a/web/attachments/202053-check_swap.c.patch b/web/attachments/202053-check_swap.c.patch
new file mode 100644
index 0000000..34e6a5d
--- /dev/null
+++ b/web/attachments/202053-check_swap.c.patch
@@ -0,0 +1,92 @@
1*** check_swap.c.orig Fri Oct 20 00:53:28 2006
2--- check_swap.c Tue Nov 7 14:54:35 2006
3***************
4*** 37,42 ****
5--- 37,48 ----
6 const char *copyright = "2000-2006";
7 const char *email = "nagiosplug-devel@lists.sourceforge.net";
8
9+ /* required to work correctly on solaris (else gets 'Bad Address' errors) */
10+ /* #ifdef HAVE_SYS_STAT_H - using this one doesnt work on solaris */
11+ #ifdef __sun__
12+ #include <sys/stat.h>
13+ #endif
14+
15 #include "common.h"
16 #include "popen.h"
17 #include "utils.h"
18***************
19*** 236,257 ****
20 # ifdef CHECK_SWAP_SWAPCTL_SVR4
21
22 /* get the number of active swap devices */
23! nswaps=swapctl(SC_GETNSWP, NULL);
24
25 /* initialize swap table + entries */
26 tbl=(swaptbl_t*)malloc(sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps));
27 memset(tbl, 0, sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps));
28 tbl->swt_n=nswaps;
29 for(i=0;i<nswaps;i++){
30! ent=&tbl->swt_ent[i];
31! ent->ste_path=(char*)malloc(sizeof(char)*MAXPATHLEN);
32 }
33
34 /* and now, tally 'em up */
35 swapctl_res=swapctl(SC_LIST, tbl);
36 if(swapctl_res < 0){
37! perror(_("swapctl failed: "));
38! result = STATE_WARNING;
39 }
40
41 for(i=0;i<nswaps;i++){
42--- 242,273 ----
43 # ifdef CHECK_SWAP_SWAPCTL_SVR4
44
45 /* get the number of active swap devices */
46! if((nswaps=swapctl(SC_GETNSWP, NULL))== -1)
47! perror(_(argv[0])), exit(STATE_UNKNOWN);
48
49+ if(nswaps == 0)
50+ (void)printf("No swap devices defined\n"), exit(STATE_OK);
51+
52+ if(verbose > 0)
53+ (void)printf("Found %d swap device(s)\n",nswaps);
54+
55 /* initialize swap table + entries */
56 tbl=(swaptbl_t*)malloc(sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps));
57+
58+ if(tbl==NULL)
59+ perror(_(argv[0])), exit(STATE_UNKNOWN);
60+
61 memset(tbl, 0, sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps));
62 tbl->swt_n=nswaps;
63 for(i=0;i<nswaps;i++){
64! if((tbl->swt_ent[i].ste_path=(char*)malloc(sizeof(char)*MAXPATHLEN)) == NULL)
65! perror(_(argv[0])), exit(STATE_UNKNOWN);
66 }
67
68 /* and now, tally 'em up */
69 swapctl_res=swapctl(SC_LIST, tbl);
70 if(swapctl_res < 0){
71! perror(_("swapctl failed")), exit(STATE_UNKNOWN);
72 }
73
74 for(i=0;i<nswaps;i++){
75***************
76*** 292,299 ****
77 /* and now, tally 'em up */
78 swapctl_res=swapctl(SWAP_STATS, ent, nswaps);
79 if(swapctl_res < 0){
80! perror(_("swapctl failed: "));
81! result = STATE_WARNING;
82 }
83
84 for(i=0;i<nswaps;i++){
85--- 308,314 ----
86 /* and now, tally 'em up */
87 swapctl_res=swapctl(SWAP_STATS, ent, nswaps);
88 if(swapctl_res < 0){
89! perror(_("swapctl failed")), exit(STATE_UNKNOWN);
90 }
91
92 for(i=0;i<nswaps;i++){