diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_disk.c | 3 | ||||
-rw-r--r-- | plugins/check_swap.c | 37 | ||||
-rw-r--r-- | plugins/common.h | 27 | ||||
-rw-r--r-- | plugins/netutils.h | 1 |
4 files changed, 41 insertions, 27 deletions
diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 8f980a49..51e8e850 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c | |||
@@ -39,6 +39,9 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; | |||
39 | 39 | ||
40 | 40 | ||
41 | #include "common.h" | 41 | #include "common.h" |
42 | #ifdef HAVE_SYS_STAT_H | ||
43 | # include <sys/stat.h> | ||
44 | #endif | ||
42 | #if HAVE_INTTYPES_H | 45 | #if HAVE_INTTYPES_H |
43 | # include <inttypes.h> | 46 | # include <inttypes.h> |
44 | #endif | 47 | #endif |
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index db8ebf95..59c1ecf6 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c | |||
@@ -41,6 +41,22 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; | |||
41 | #include "popen.h" | 41 | #include "popen.h" |
42 | #include "utils.h" | 42 | #include "utils.h" |
43 | 43 | ||
44 | #ifdef HAVE_DECL_SWAPCTL | ||
45 | # ifdef HAVE_SYS_SWAP_H | ||
46 | # include <sys/swap.h> | ||
47 | # endif | ||
48 | # ifdef HAVE_SYS_STAT_H | ||
49 | # include <sys/stat.h> | ||
50 | # endif | ||
51 | # ifdef HAVE_SYS_PARAM_H | ||
52 | # include <sys/param.h> | ||
53 | # endif | ||
54 | #endif | ||
55 | |||
56 | #ifndef SWAP_CONVERSION | ||
57 | # define SWAP_CONVERSION 1 | ||
58 | #endif | ||
59 | |||
44 | int check_swap (int usp, float free_swap_mb); | 60 | int check_swap (int usp, float free_swap_mb); |
45 | int process_arguments (int argc, char **argv); | 61 | int process_arguments (int argc, char **argv); |
46 | int validate_arguments (void); | 62 | int validate_arguments (void); |
@@ -236,22 +252,33 @@ main (int argc, char **argv) | |||
236 | # ifdef CHECK_SWAP_SWAPCTL_SVR4 | 252 | # ifdef CHECK_SWAP_SWAPCTL_SVR4 |
237 | 253 | ||
238 | /* get the number of active swap devices */ | 254 | /* get the number of active swap devices */ |
239 | nswaps=swapctl(SC_GETNSWP, NULL); | 255 | if((nswaps=swapctl(SC_GETNSWP, NULL))== -1) |
256 | die(STATE_UNKNOWN, _("Error getting swap devices\n") ); | ||
257 | |||
258 | if(nswaps == 0) | ||
259 | die(STATE_OK, _("SWAP OK: No swap devices defined\n")); | ||
260 | |||
261 | if(verbose >= 3) | ||
262 | printf("Found %d swap device(s)\n", nswaps); | ||
240 | 263 | ||
241 | /* initialize swap table + entries */ | 264 | /* initialize swap table + entries */ |
242 | tbl=(swaptbl_t*)malloc(sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps)); | 265 | tbl=(swaptbl_t*)malloc(sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps)); |
266 | |||
267 | if(tbl==NULL) | ||
268 | die(STATE_UNKNOWN, _("malloc() failed!\n")); | ||
269 | |||
243 | memset(tbl, 0, sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps)); | 270 | memset(tbl, 0, sizeof(swaptbl_t)+(sizeof(swapent_t)*nswaps)); |
244 | tbl->swt_n=nswaps; | 271 | tbl->swt_n=nswaps; |
245 | for(i=0;i<nswaps;i++){ | 272 | for(i=0;i<nswaps;i++){ |
246 | ent=&tbl->swt_ent[i]; | 273 | if((tbl->swt_ent[i].ste_path=(char*)malloc(sizeof(char)*MAXPATHLEN)) == NULL) |
247 | ent->ste_path=(char*)malloc(sizeof(char)*MAXPATHLEN); | 274 | die(STATE_UNKNOWN, _("malloc() failed!\n")); |
248 | } | 275 | } |
249 | 276 | ||
250 | /* and now, tally 'em up */ | 277 | /* and now, tally 'em up */ |
251 | swapctl_res=swapctl(SC_LIST, tbl); | 278 | swapctl_res=swapctl(SC_LIST, tbl); |
252 | if(swapctl_res < 0){ | 279 | if(swapctl_res < 0){ |
253 | perror(_("swapctl failed: ")); | 280 | perror(_("swapctl failed: ")); |
254 | result = STATE_WARNING; | 281 | die(STATE_UNKNOWN, _("Error in swapctl call\n")); |
255 | } | 282 | } |
256 | 283 | ||
257 | for(i=0;i<nswaps;i++){ | 284 | for(i=0;i<nswaps;i++){ |
@@ -293,7 +320,7 @@ main (int argc, char **argv) | |||
293 | swapctl_res=swapctl(SWAP_STATS, ent, nswaps); | 320 | swapctl_res=swapctl(SWAP_STATS, ent, nswaps); |
294 | if(swapctl_res < 0){ | 321 | if(swapctl_res < 0){ |
295 | perror(_("swapctl failed: ")); | 322 | perror(_("swapctl failed: ")); |
296 | result = STATE_WARNING; | 323 | die(STATE_UNKNOWN, _("Error in swapctl call\n")); |
297 | } | 324 | } |
298 | 325 | ||
299 | for(i=0;i<nswaps;i++){ | 326 | for(i=0;i<nswaps;i++){ |
diff --git a/plugins/common.h b/plugins/common.h index ac3b8339..b3357431 100644 --- a/plugins/common.h +++ b/plugins/common.h | |||
@@ -36,6 +36,12 @@ | |||
36 | #define _COMMON_H_ | 36 | #define _COMMON_H_ |
37 | 37 | ||
38 | #include "config.h" | 38 | #include "config.h" |
39 | /* This needs to be removed for Solaris servers, where 64 bit files, but 32 bit architecture | ||
40 | This needs to be done early on because subsequent system includes use _FILE_OFFSET_BITS | ||
41 | Cannot remove from config.h because is included by regex.c from lib/ */ | ||
42 | #if __sun__ && !defined(_LP64) && _FILE_OFFSET_BITS == 64 | ||
43 | #undef _FILE_OFFSET_BITS | ||
44 | #endif | ||
39 | 45 | ||
40 | #ifdef HAVE_FEATURES_H | 46 | #ifdef HAVE_FEATURES_H |
41 | #include <features.h> | 47 | #include <features.h> |
@@ -114,27 +120,6 @@ | |||
114 | #include <locale.h> | 120 | #include <locale.h> |
115 | #endif | 121 | #endif |
116 | 122 | ||
117 | /* Fixes "Cannot use swapctl in the large files compilation environment" error on Solaris */ | ||
118 | #ifdef _FILE_OFFSET_BITS | ||
119 | #undef _FILE_OFFSET_BITS | ||
120 | #endif | ||
121 | |||
122 | #ifdef HAVE_DECL_SWAPCTL | ||
123 | # ifdef HAVE_SYS_SWAP_H | ||
124 | # include <sys/swap.h> | ||
125 | # endif | ||
126 | # ifdef HAVE_SYS_STAT_H | ||
127 | # include <sys/stat.h> | ||
128 | # endif | ||
129 | # ifdef HAVE_SYS_PARAM_H | ||
130 | # include <sys/param.h> | ||
131 | # endif | ||
132 | #endif | ||
133 | |||
134 | #ifndef SWAP_CONVERSION | ||
135 | # define SWAP_CONVERSION 1 | ||
136 | #endif | ||
137 | |||
138 | #ifdef HAVE_SYS_POLL_H | 123 | #ifdef HAVE_SYS_POLL_H |
139 | # include "sys/poll.h" | 124 | # include "sys/poll.h" |
140 | #endif | 125 | #endif |
diff --git a/plugins/netutils.h b/plugins/netutils.h index 1168f9f8..3fc4ef80 100644 --- a/plugins/netutils.h +++ b/plugins/netutils.h | |||
@@ -35,7 +35,6 @@ | |||
35 | #ifndef _NETUTILS_H_ | 35 | #ifndef _NETUTILS_H_ |
36 | #define _NETUTILS_H_ | 36 | #define _NETUTILS_H_ |
37 | 37 | ||
38 | #include "config.h" | ||
39 | #include "common.h" | 38 | #include "common.h" |
40 | #include "utils.h" | 39 | #include "utils.h" |
41 | #include <netinet/in.h> | 40 | #include <netinet/in.h> |