diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_swap.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index ca8442a4..f9dba38f 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c | |||
@@ -44,16 +44,14 @@ main (int argc, char **argv) | |||
44 | 44 | ||
45 | #ifdef HAVE_PROC_MEMINFO | 45 | #ifdef HAVE_PROC_MEMINFO |
46 | fp = fopen (PROC_MEMINFO, "r"); | 46 | fp = fopen (PROC_MEMINFO, "r"); |
47 | status = ssprintf (status, "%s", "Swap used:"); | 47 | asprintf (&status, "%s", "Swap used:"); |
48 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) { | 48 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) { |
49 | sscanf (input_buffer, " %s %d %d %d", str, &total_swap, &used_swap, | 49 | sscanf (input_buffer, " %s %d %d %d", str, &total_swap, &used_swap, |
50 | &free_swap); | 50 | &free_swap); |
51 | if (strstr (str, "Swap")) { | 51 | if (strstr (str, "Swap")) { |
52 | percent_used = 100 * (((float) used_swap) / ((float) total_swap)); | 52 | percent_used = 100 * (((float) used_swap) / ((float) total_swap)); |
53 | status = ssprintf | 53 | asprintf (&status, "%s %2d%% (%d bytes out of %d)", |
54 | (status, | 54 | status, percent_used, used_swap, total_swap); |
55 | "%s %2d%% (%d bytes out of %d)", | ||
56 | status, percent_used, used_swap, total_swap); | ||
57 | if (percent_used >= crit_percent || free_swap <= crit_size) | 55 | if (percent_used >= crit_percent || free_swap <= crit_size) |
58 | result = STATE_CRITICAL; | 56 | result = STATE_CRITICAL; |
59 | else if (percent_used >= warn_percent || free_swap <= warn_size) | 57 | else if (percent_used >= warn_percent || free_swap <= warn_size) |
@@ -90,15 +88,13 @@ main (int argc, char **argv) | |||
90 | } | 88 | } |
91 | } | 89 | } |
92 | 90 | ||
93 | status = ssprintf (status, "%s", "Swap used:"); | 91 | asprintf (&status, "%s", "Swap used:"); |
94 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { | 92 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { |
95 | sscanf (input_buffer, SWAP_FORMAT, &total_swap, &free_swap); | 93 | sscanf (input_buffer, SWAP_FORMAT, &total_swap, &free_swap); |
96 | used_swap = total_swap - free_swap; | 94 | used_swap = total_swap - free_swap; |
97 | percent_used = 100 * ((float) used_swap) / ((float) total_swap); | 95 | percent_used = 100 * ((float) used_swap) / ((float) total_swap); |
98 | status = ssprintf | 96 | asprintf (&status, "%s %2d%% (%d bytes out of %d)", |
99 | (status, | 97 | status, percent_used, used_swap, total_swap); |
100 | "%s %2d%% (%d bytes out of %d)", | ||
101 | status, percent_used, used_swap, total_swap); | ||
102 | if (percent_used >= crit_percent || free_swap <= crit_size) | 98 | if (percent_used >= crit_percent || free_swap <= crit_size) |
103 | result = STATE_CRITICAL; | 99 | result = STATE_CRITICAL; |
104 | else if (percent_used >= warn_percent || free_swap <= warn_size) | 100 | else if (percent_used >= warn_percent || free_swap <= warn_size) |