summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 02b043e..fe792e8 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -52,7 +52,7 @@ main (int argc, char **argv)
52{ 52{
53 int percent_used, percent; 53 int percent_used, percent;
54 unsigned long long total_swap = 0, used_swap = 0, free_swap = 0; 54 unsigned long long total_swap = 0, used_swap = 0, free_swap = 0;
55 unsigned long long dsktotal, dskused, dskfree; 55 unsigned long long dsktotal, dskused, dskfree, tmp;
56 int result = STATE_OK; 56 int result = STATE_OK;
57 char input_buffer[MAX_INPUT_BUFFER]; 57 char input_buffer[MAX_INPUT_BUFFER];
58 char *perf; 58 char *perf;
@@ -82,8 +82,7 @@ main (int argc, char **argv)
82#ifdef HAVE_PROC_MEMINFO 82#ifdef HAVE_PROC_MEMINFO
83 fp = fopen (PROC_MEMINFO, "r"); 83 fp = fopen (PROC_MEMINFO, "r");
84 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) { 84 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
85 if (sscanf (input_buffer, " %s %llu %llu %llu", str, &dsktotal, &dskused, &dskfree) == 4 && 85 if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%*[:] %llu %llu %llu", &dsktotal, &dskused, &dskfree) == 3) {
86 strstr (str, "Swap")) {
87 dsktotal = dsktotal / 1048576; 86 dsktotal = dsktotal / 1048576;
88 dskused = dskused / 1048576; 87 dskused = dskused / 1048576;
89 dskfree = dskfree / 1048576; 88 dskfree = dskfree / 1048576;
@@ -97,8 +96,20 @@ main (int argc, char **argv)
97 asprintf (&status, "%s [%llu (%d%%)]", status, dskfree, 100 - percent); 96 asprintf (&status, "%s [%llu (%d%%)]", status, dskfree, 100 - percent);
98 } 97 }
99 } 98 }
99 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %llu %*[k]%*[B]", str, &tmp)) {
100 if (strcmp ("Total", str) == 0) {
101 dsktotal = tmp / 1024;
102 }
103 else if (strcmp ("Free", str) == 0) {
104 dskfree = tmp / 1024;
105 }
106 }
100 } 107 }
101 fclose(fp); 108 fclose(fp);
109 dskused = dsktotal - dskfree;
110 total_swap = dsktotal;
111 used_swap = dskused;
112 free_swap = dskfree;
102#else 113#else
103# ifdef HAVE_SWAP 114# ifdef HAVE_SWAP
104 asprintf(&swap_command, "%s", SWAP_COMMAND); 115 asprintf(&swap_command, "%s", SWAP_COMMAND);