diff options
author | Eldad Zack <eldad@gentoo.org> | 2004-11-21 11:31:07 +0000 |
---|---|---|
committer | Eldad Zack <eldad@gentoo.org> | 2004-11-21 11:31:07 +0000 |
commit | 04fecb8b6b0871c4c2146ef4afc5ed78a4c31304 (patch) | |
tree | 5e69eacceedaeebb460dd152e892571a79e7d253 /net-analyzer/nagios-plugins/files | |
parent | Added to ~amd64, bug #71921 (Manifest recommit) (diff) | |
download | gentoo-2-04fecb8b6b0871c4c2146ef4afc5ed78a4c31304.tar.gz gentoo-2-04fecb8b6b0871c4c2146ef4afc5ed78a4c31304.tar.bz2 gentoo-2-04fecb8b6b0871c4c2146ef4afc5ed78a4c31304.zip |
nagios-plugins-1.3.1-r2.ebuild
Diffstat (limited to 'net-analyzer/nagios-plugins/files')
-rw-r--r-- | net-analyzer/nagios-plugins/files/check_swap.c.patch | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/net-analyzer/nagios-plugins/files/check_swap.c.patch b/net-analyzer/nagios-plugins/files/check_swap.c.patch new file mode 100644 index 000000000000..9daceedac56e --- /dev/null +++ b/net-analyzer/nagios-plugins/files/check_swap.c.patch @@ -0,0 +1,58 @@ +--- plugins/check_swap.c.orig 2003-02-18 05:46:15.000000000 +0200 ++++ plugins/check_swap.c 2004-08-23 17:08:21.328421472 +0300 +@@ -70,30 +70,37 @@ + + #ifdef HAVE_PROC_MEMINFO + fp = fopen (PROC_MEMINFO, "r"); ++ if (!fp) { ++ printf ("Could not open meminfo proc file\n"); ++ return STATE_UNKNOWN; ++ } + asprintf (&status, "%s", "Swap used:"); + while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) { +- if (sscanf (input_buffer, " %s %lu %lu %lu", str, &total, &used, &free) == 4 && +- strstr (str, "Swap")) { +- total_swap += total; +- used_swap += used; ++ if (sscanf (input_buffer, "%s %lu", str, &total) == 2 && ++ strstr (str, "SwapTotal:")) { ++ total *= 1024; ++ total_swap += total; ++ used_swap += total_swap; ++ } else ++ if (sscanf (input_buffer, "%s %lu", str, &free) == 2 && ++ strstr (str, "SwapFree:")) { ++ free *= 1024; + free_swap += free; +- if (allswaps) { +- percent = 100 * (((double) used) / ((double) total)); +- if (percent >= crit_percent || free <= crit_size) +- result = max_state (STATE_CRITICAL, result); +- else if (percent >= warn_percent || free <= warn_size) +- result = max_state (STATE_WARNING, result); +- if (verbose) +- asprintf (&status, "%s [%lu/%lu]", status, used, total); +- } ++ used_swap -= free_swap; + } + } +- percent_used = 100 * (((double) used_swap) / ((double) total_swap)); +- if (percent_used >= crit_percent || free_swap <= crit_size) ++ ++ if (total_swap == 0) { ++ percent_used = 100; + result = max_state (STATE_CRITICAL, result); +- else if (percent_used >= warn_percent || free_swap <= warn_size) +- result = max_state (STATE_WARNING, result); +- asprintf (&status, "%s %2d%% (%lu out of %lu)", status, percent_used, ++ } else { ++ percent_used = 100 * (0.005 + ((double) used_swap) / ((double) total_swap)); ++ if (percent_used >= crit_percent || free_swap <= crit_size) ++ result = max_state (STATE_CRITICAL, result); ++ else if (percent_used >= warn_percent || free_swap <= warn_size) ++ result = max_state (STATE_WARNING, result); ++ } ++ asprintf (&status, "%s %2d%% (%lu out of %lu)", status, percent_used, + used_swap, total_swap); + fclose (fp); + #else |