summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (from parent 1: 96c9d82)
raw | patch | inline | side by side (from parent 1: 96c9d82)
author | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 13 Jan 2005 18:24:52 +0000 (18:24 +0000) | ||
committer | Ton Voon <tonvoon@users.sourceforge.net> | |
Thu, 13 Jan 2005 18:24:52 +0000 (18:24 +0000) |
OSes. Seems to have a problem with the perf data for check_swap on Sol 2.6,
but not critical
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1080 f882894a-f735-0410-b71e-b25c423dba1c
but not critical
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1080 f882894a-f735-0410-b71e-b25c423dba1c
configure.in | patch | blob | history | |
plugins/check_swap.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index 64f06bf38fd51f6e11ae1150de6d864fc2ba5954..030b1de38db3e2c9fbcd899c594ede92839a3790 100644 (file)
--- a/configure.in
+++ b/configure.in
egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
>/dev/null]
then
- ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %d %d"]
+ ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
ac_cv_swap_conv=2048
AC_MSG_RESULT([using IRIX format swap])
elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null]
then
- ac_cv_swap_format=["%*s %*[0-9,-] %*d %d %d"]
+ ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
ac_cv_swap_conv=2048
AC_MSG_RESULT([using Unixware format swap])
else
if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null]
then
- ac_cv_swap_format=["%*s %d %*d %d"]
+ ac_cv_swap_format=["%*s %f %*d %f"]
ac_cv_swap_conv=1024
AC_MSG_RESULT([using FreeBSD format swapinfo])
fi
@@ -1296,7 +1296,7 @@ elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >
then
ac_cv_have_swap=yes
ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM",
- ac_cv_swap_format=["%*s %d %*d %d"]
+ ac_cv_swap_format=["%*s %f %*d %f"]
ac_cv_swap_conv=1024
AC_MSG_RESULT([using HP-UX format swapinfo])
fi
then
ac_cv_have_swap=yes
ac_cv_swap_command="$PATH_TO_LSPS -a"
- ac_cv_swap_format=["%*s %*s %*s %d%*s %d %*s"]
+ ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
ac_cv_swap_conv=1
AC_MSG_RESULT([using AIX lsps])
fi
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index bcc6b170c6d4e554682d8c2c5fa94032828c696b..339657527342af432fd28ac5a06efcd9774624e8 100644 (file)
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
#include "popen.h"
#include "utils.h"
-int check_swap (int usp, long unsigned int free_swap);
+int check_swap (int usp, float free_swap);
int process_arguments (int argc, char **argv);
int validate_arguments (void);
void print_usage (void);
int warn_percent = 0;
int crit_percent = 0;
-unsigned long long warn_size = 0;
-unsigned long long crit_size = 0;
+float warn_size = 0;
+float crit_size = 0;
int verbose;
int allswaps;
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 = 0, dskused = 0, dskfree = 0, tmp = 0;
+ float total_swap = 0, used_swap = 0, free_swap = 0;
+ float dsktotal = 0, dskused = 0, dskfree = 0, tmp = 0;
int result = STATE_UNKNOWN;
char input_buffer[MAX_INPUT_BUFFER];
char *perf;
#ifdef HAVE_PROC_MEMINFO
fp = fopen (PROC_MEMINFO, "r");
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
- if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%*[:] %llu %llu %llu", &dsktotal, &dskused, &dskfree) == 3) {
+ if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%*[:] %f %f %f", &dsktotal, &dskused, &dskfree) == 3) {
dsktotal = dsktotal / 1048576;
dskused = dskused / 1048576;
dskfree = dskfree / 1048576;
percent = 100 * (((double) dskused) / ((double) dsktotal));
result = max_state (result, check_swap (percent, dskfree));
if (verbose)
- asprintf (&status, "%s [%llu (%d%%)]", status, dskfree, 100 - percent);
+ asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree, 100 - percent);
}
}
- else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %llu %*[k]%*[B]", str, &tmp)) {
+ else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %f %*[k]%*[B]", str, &tmp)) {
if (strcmp ("Total", str) == 0) {
dsktotal = tmp / 1024;
}
free_swap = total_swap * (100 - used_swap) /100;
used_swap = total_swap - free_swap;
if (verbose >= 3)
- printf (_("total=%d, used=%d, free=%d\n"), total_swap, used_swap, free_swap);
+ printf (_("total=%.0f, used=%.0f, free=%.0f\n"), total_swap, used_swap, free_swap);
} else {
# endif
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
dskfree = dskfree / conv_factor;
# endif
if (verbose >= 3)
- printf (_("total=%llu, free=%llu\n"), dsktotal, dskfree);
+ printf (_("total=%.0f, free=%.0f\n"), dsktotal, dskfree);
dskused = dsktotal - dskfree;
total_swap += dsktotal;
percent = 100 * (((double) dskused) / ((double) dsktotal));
result = max_state (result, check_swap (percent, dskfree));
if (verbose)
- asprintf (&status, "%s [%llu (%d%%)]", status, dskfree, 100 - percent);
+ asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree, 100 - percent);
}
}
# ifdef _AIX
}
for(i=0;i<nswaps;i++){
- dsktotal = tbl->swt_ent[i].ste_pages / SWAP_CONVERSION;
- dskfree = tbl->swt_ent[i].ste_free / SWAP_CONVERSION;
+ dsktotal = (float) tbl->swt_ent[i].ste_pages / SWAP_CONVERSION;
+ dskfree = (float) tbl->swt_ent[i].ste_free / SWAP_CONVERSION;
dskused = ( dsktotal - dskfree );
+ if (verbose >= 3)
+ printf ("dsktotal=%.0f dskfree=%.0f dskused=%.0f\n", dsktotal, dskfree, dskused);
+
if(allswaps && dsktotal > 0){
percent = 100 * (((double) dskused) / ((double) dsktotal));
result = max_state (result, check_swap (percent, dskfree));
if (verbose) {
- asprintf (&status, "%s [%d (%d%%)]", status, (int)dskfree, 100 - percent);
+ asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree, 100 - percent);
}
}
}
for(i=0;i<nswaps;i++){
- dsktotal = ent->se_nblks / conv_factor;
- dskused = ent->se_inuse / conv_factor;
+ dsktotal = (float) ent->se_nblks / conv_factor;
+ dskused = (float) ent->se_inuse / conv_factor;
dskfree = ( dsktotal - dskused );
if(allswaps && dsktotal > 0){
percent = 100 * (((double) dskused) / ((double) dsktotal));
result = max_state (result, check_swap (percent, dskfree));
if (verbose) {
- asprintf (&status, "%s [%d (%d%%)]", status, (int)dskfree, 100 - percent);
+ asprintf (&status, "%s [%.0f (%d%%)]", status, dskfree, 100 - percent);
}
}
percent_used = 100 * ((double) used_swap) / ((double) total_swap);
result = max_state (result, check_swap (percent_used, free_swap));
/* broken into two steps because of funkiness with builtin asprintf */
- asprintf (&tmp_status, _(" %d%% free (%llu MB out of %llu MB)"),
+ asprintf (&tmp_status, _(" %d%% free (%.0f MB out of %.0f MB)"),
(100 - percent_used), free_swap, total_swap);
asprintf (&status, "%s%s", tmp_status, status);
int
-check_swap (int usp, long unsigned int free_swap)
+check_swap (int usp, float free_swap)
{
int result = STATE_UNKNOWN;
free_swap = free_swap * 1024; /* Convert back to bytes as warn and crit specified in bytes */
switch (c) {
case 'w': /* warning size threshold */
if (is_intnonneg (optarg)) {
- warn_size = atoi (optarg);
+ warn_size = (float) atoi (optarg);
break;
}
else if (strstr (optarg, ",") &&
strstr (optarg, "%") &&
- sscanf (optarg, "%llu,%d%%", &warn_size, &warn_percent) == 2) {
+ sscanf (optarg, "%.0f,%d%%", &warn_size, &warn_percent) == 2) {
break;
}
else if (strstr (optarg, "%") &&
}
case 'c': /* critical size threshold */
if (is_intnonneg (optarg)) {
- crit_size = atoi (optarg);
+ crit_size = (float) atoi (optarg);
break;
}
else if (strstr (optarg, ",") &&
strstr (optarg, "%") &&
- sscanf (optarg, "%llu,%d%%", &crit_size, &crit_percent) == 2) {
+ sscanf (optarg, "%.0f,%d%%", &crit_size, &crit_percent) == 2) {
break;
}
else if (strstr (optarg, "%") &&
if (c == argc)
return validate_arguments ();
if (warn_size == 0 && is_intnonneg (argv[c]))
- warn_size = atoi (argv[c++]);
+ warn_size = (float) atoi (argv[c++]);
if (c == argc)
return validate_arguments ();