diff options
author | M. Sean Finney <seanius@users.sourceforge.net> | 2005-06-26 01:23:47 +0000 |
---|---|---|
committer | M. Sean Finney <seanius@users.sourceforge.net> | 2005-06-26 01:23:47 +0000 |
commit | d92fac77cc0fa23d04128d587b562c26732c4149 (patch) | |
tree | dc0894ea3e371327807687c0f993422f32f3cc91 /plugins | |
parent | 45b373ebdad0c82296342f4ad774db2ff643e511 (diff) | |
download | monitoring-plugins-d92fac77cc0fa23d04128d587b562c26732c4149.tar.gz |
"asprintf madness" fix from andreas' patch to np-d, minus the comments.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1190 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_swap.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/plugins/check_swap.c b/plugins/check_swap.c index ef1b9500..fe9254d2 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c @@ -79,14 +79,13 @@ main (int argc, char **argv) # endif #endif char str[32]; - char *status, *tmp_status; + char *status; setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); status = strdup (""); - tmp_status = strdup (""); perf = strdup (""); if (process_arguments (argc, argv) == ERROR) @@ -313,17 +312,16 @@ main (int argc, char **argv) percent_used = 100 * ((double) used_swap) / ((double) total_swap); result = max_state (result, check_swap (percent_used, free_swap)); - /* broken into two steps because of funkiness with builtin asprintf */ - asprintf (&tmp_status, _(" %d%% free (%.0f MB out of %.0f MB)"), - (100 - percent_used), free_swap, total_swap); - asprintf (&status, "%s%s", tmp_status, status); - - asprintf (&perf, "%s", perfdata ("swap", (long) free_swap, "MB", - TRUE, (long) max (warn_size/1024, warn_percent/100.0*total_swap), - TRUE, (long) max (crit_size/1024, crit_percent/100.0*total_swap), - TRUE, 0, - TRUE, (long) total_swap)); - printf ("SWAP %s:%s |%s\n", state_text (result), status, perf); + printf (_("SWAP %s - %d%% free (%.0f MB out of %.0f MB) %s|"), + state_text (result), + (100 - percent_used), free_swap, total_swap, status); + + puts (perfdata ("swap", (long) free_swap, "MB", + TRUE, (long) max (warn_size/1024, warn_percent/100.0*total_swap), + TRUE, (long) max (crit_size/1024, crit_percent/100.0*total_swap), + TRUE, 0, + TRUE, (long) total_swap)); + return result; } |