summaryrefslogtreecommitdiffstats
path: root/plugins/check_swap.d
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_swap.d')
-rw-r--r--plugins/check_swap.d/check_swap.h3
-rw-r--r--plugins/check_swap.d/swap.c18
2 files changed, 14 insertions, 7 deletions
diff --git a/plugins/check_swap.d/check_swap.h b/plugins/check_swap.d/check_swap.h
index da08d65a..8d3c7fcf 100644
--- a/plugins/check_swap.d/check_swap.h
+++ b/plugins/check_swap.d/check_swap.h
@@ -43,6 +43,7 @@ swap_config swap_config_init(void);
43 43
44swap_result get_swap_data(swap_config config); 44swap_result get_swap_data(swap_config config);
45swap_result getSwapFromProcMeminfo(char path_to_proc_meminfo[]); 45swap_result getSwapFromProcMeminfo(char path_to_proc_meminfo[]);
46swap_result getSwapFromSwapCommand(swap_config config, const char swap_command[], const char swap_format[]); 46swap_result getSwapFromSwapCommand(swap_config config, const char swap_command[],
47 const char swap_format[]);
47swap_result getSwapFromSwapctl_BSD(swap_config config); 48swap_result getSwapFromSwapctl_BSD(swap_config config);
48swap_result getSwapFromSwap_SRV4(swap_config config); 49swap_result getSwapFromSwap_SRV4(swap_config config);
diff --git a/plugins/check_swap.d/swap.c b/plugins/check_swap.d/swap.c
index 634f80d9..5b654197 100644
--- a/plugins/check_swap.d/swap.c
+++ b/plugins/check_swap.d/swap.c
@@ -95,12 +95,14 @@ swap_result getSwapFromProcMeminfo(char proc_meminfo[]) {
95 * 123 123" which exists on NetBSD (at least), 95 * 123 123" which exists on NetBSD (at least),
96 * The unit should be Bytes 96 * The unit should be Bytes
97 */ 97 */
98 if (sscanf(input_buffer, "%*[S]%*[w]%*[a]%*[p]%*[:] %lu %lu %lu", &swap_total, &swap_used, &swap_free) == 3) { 98 if (sscanf(input_buffer, "%*[S]%*[w]%*[a]%*[p]%*[:] %lu %lu %lu", &swap_total, &swap_used,
99 &swap_free) == 3) {
99 found_total = true; 100 found_total = true;
100 found_free = true; 101 found_free = true;
101 // Set error 102 // Set error
102 result.errorcode = STATE_OK; 103 result.errorcode = STATE_OK;
103 // Break out of fgets here, since both scanf expressions might match (NetBSD for example) 104 // Break out of fgets here, since both scanf expressions might match (NetBSD for
105 // example)
104 break; 106 break;
105 } 107 }
106 108
@@ -149,7 +151,8 @@ swap_result getSwapFromProcMeminfo(char proc_meminfo[]) {
149 return result; 151 return result;
150} 152}
151 153
152swap_result getSwapFromSwapCommand(swap_config config, const char swap_command[], const char swap_format[]) { 154swap_result getSwapFromSwapCommand(swap_config config, const char swap_command[],
155 const char swap_format[]) {
153 swap_result result = {0}; 156 swap_result result = {0};
154 157
155 char *temp_buffer; 158 char *temp_buffer;
@@ -212,7 +215,8 @@ swap_result getSwapFromSwapCommand(swap_config config, const char swap_command[]
212 used_swap_mb = total_swap_mb - free_swap_mb; 215 used_swap_mb = total_swap_mb - free_swap_mb;
213 216
214 if (verbose >= 3) { 217 if (verbose >= 3) {
215 printf(_("total=%.0f, used=%.0f, free=%.0f\n"), total_swap_mb, used_swap_mb, free_swap_mb); 218 printf(_("total=%.0f, used=%.0f, free=%.0f\n"), total_swap_mb, used_swap_mb,
219 free_swap_mb);
216 } 220 }
217 } else { 221 } else {
218 while (fgets(input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { 222 while (fgets(input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
@@ -398,7 +402,8 @@ swap_result getSwapFromSwap_SRV4(swap_config config) {
398 } 402 }
399 403
400 /* initialize swap table + entries */ 404 /* initialize swap table + entries */
401 swaptbl_t *tbl = (swaptbl_t *)malloc(sizeof(swaptbl_t) + (sizeof(swapent_t) * (unsigned long)nswaps)); 405 swaptbl_t *tbl =
406 (swaptbl_t *)malloc(sizeof(swaptbl_t) + (sizeof(swapent_t) * (unsigned long)nswaps));
402 407
403 if (tbl == NULL) { 408 if (tbl == NULL) {
404 die(STATE_UNKNOWN, _("malloc() failed!\n")); 409 die(STATE_UNKNOWN, _("malloc() failed!\n"));
@@ -433,7 +438,8 @@ swap_result getSwapFromSwap_SRV4(swap_config config) {
433 dskused_mb = (dsktotal_mb - dskfree_mb); 438 dskused_mb = (dsktotal_mb - dskfree_mb);
434 439
435 if (verbose >= 3) { 440 if (verbose >= 3) {
436 printf("dsktotal_mb=%.0f dskfree_mb=%.0f dskused_mb=%.0f\n", dsktotal_mb, dskfree_mb, dskused_mb); 441 printf("dsktotal_mb=%.0f dskfree_mb=%.0f dskused_mb=%.0f\n", dsktotal_mb, dskfree_mb,
442 dskused_mb);
437 } 443 }
438 444
439 if (config.allswaps && dsktotal_mb > 0) { 445 if (config.allswaps && dsktotal_mb > 0) {