diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-10 00:19:03 +0100 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-10 00:19:03 +0100 |
commit | 14342ac87a26e3593b00dcb8482a280544b1667e (patch) | |
tree | dc0dfa29bf32dbe91f32c8470118daa0660753bc | |
parent | 21c39515903c34bc6428a544c88cf1c100786847 (diff) | |
download | monitoring-plugins-14342ac87a26e3593b00dcb8482a280544b1667e.tar.gz |
check_swap: Small improvements
-rw-r--r-- | plugins/check_swap.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index c3199ab7..ef60ce1b 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c | |||
@@ -27,11 +27,6 @@ | |||
27 | * | 27 | * |
28 | *****************************************************************************/ | 28 | *****************************************************************************/ |
29 | 29 | ||
30 | #include <stdint.h> | ||
31 | const char *progname = "check_swap"; | ||
32 | const char *copyright = "2000-2024"; | ||
33 | const char *email = "devel@monitoring-plugins.org"; | ||
34 | |||
35 | #ifdef HAVE_DECL_SWAPCTL | 30 | #ifdef HAVE_DECL_SWAPCTL |
36 | # ifdef HAVE_SYS_PARAM_H | 31 | # ifdef HAVE_SYS_PARAM_H |
37 | # include <sys/param.h> | 32 | # include <sys/param.h> |
@@ -44,6 +39,7 @@ const char *email = "devel@monitoring-plugins.org"; | |||
44 | # endif | 39 | # endif |
45 | #endif | 40 | #endif |
46 | 41 | ||
42 | #include <stdint.h> | ||
47 | #include "./check_swap.d/check_swap.h" | 43 | #include "./check_swap.d/check_swap.h" |
48 | #include "./utils.h" | 44 | #include "./utils.h" |
49 | 45 | ||
@@ -63,13 +59,16 @@ int verbose; | |||
63 | #define BYTES_TO_KiB(number) (number / 1024) | 59 | #define BYTES_TO_KiB(number) (number / 1024) |
64 | #define BYTES_TO_MiB(number) (BYTES_TO_KiB(number) / 1024) | 60 | #define BYTES_TO_MiB(number) (BYTES_TO_KiB(number) / 1024) |
65 | 61 | ||
62 | const char *progname = "check_swap"; | ||
63 | const char *copyright = "2000-2024"; | ||
64 | const char *email = "devel@monitoring-plugins.org"; | ||
65 | |||
66 | int main(int argc, char **argv) { | 66 | int main(int argc, char **argv) { |
67 | setlocale(LC_ALL, ""); | 67 | setlocale(LC_ALL, ""); |
68 | bindtextdomain(PACKAGE, LOCALEDIR); | 68 | bindtextdomain(PACKAGE, LOCALEDIR); |
69 | textdomain(PACKAGE); | 69 | textdomain(PACKAGE); |
70 | 70 | ||
71 | char *status; | 71 | char *status = strdup(""); |
72 | status = strdup(""); | ||
73 | 72 | ||
74 | /* Parse extra opts if any */ | 73 | /* Parse extra opts if any */ |
75 | argv = np_extra_opts(&argc, argv, progname); | 74 | argv = np_extra_opts(&argc, argv, progname); |
@@ -85,7 +84,6 @@ int main(int argc, char **argv) { | |||
85 | swap_result data = get_swap_data(config); | 84 | swap_result data = get_swap_data(config); |
86 | 85 | ||
87 | double percent_used; | 86 | double percent_used; |
88 | |||
89 | /* if total_swap_mb == 0, let's not divide by 0 */ | 87 | /* if total_swap_mb == 0, let's not divide by 0 */ |
90 | if (data.metrics.total != 0) { | 88 | if (data.metrics.total != 0) { |
91 | percent_used = HUNDRED_PERCENT * ((double)data.metrics.used) / ((double)data.metrics.total); | 89 | percent_used = HUNDRED_PERCENT * ((double)data.metrics.used) / ((double)data.metrics.total); |