summaryrefslogtreecommitdiffstats
path: root/web/attachments/412453-check_disk.diff
blob: 0d722722a286adb0d6bb033f8c0f3db42a89008d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
commit 81feafc3746e7e63d9dea923d56b327b7d134f3b
Author: Alex Dehnert <adehnert@mit.edu>
Date:   Mon May 23 03:50:26 2011 -0400

    check_disk: Use multiline output format

diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index f889764..f6e9e5b 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -159,6 +159,8 @@ main (int argc, char **argv)
   int result = STATE_UNKNOWN;
   int disk_result = STATE_UNKNOWN;
   char *output;
+  char *output_long;
+  char *line;
   char *details;
   char *perf;
   char *preamble;
@@ -173,6 +175,7 @@ main (int argc, char **argv)
 
   preamble = strdup (" - free space:");
   output = strdup ("");
+  output_long = strdup ("");
   details = strdup ("");
   perf = strdup ("");
   stat_buf = malloc(sizeof *stat_buf);
@@ -331,17 +334,19 @@ main (int argc, char **argv)
       if (disk_result==STATE_OK && erronly && !verbose)
         continue;
 
-      asprintf (&output, "%s %s %.0f %s (%.0f%%",
-                output,
+      line = strdup ("");
+      asprintf (&line, "%s %.0f %s (%.0f%%",
                 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
                 path->dfree_units,
                 units,
                 path->dfree_pct);
       if (path->dused_inodes_percent < 0) {
-        asprintf(&output, "%s inode=-);", output);
+        asprintf(&line, "%s inode=-)", line);
       } else {
-        asprintf(&output, "%s inode=%.0f%%);", output, path->dfree_inodes_percent );
+        asprintf(&line, "%s inode=%.0f%%)", line, path->dfree_inodes_percent );
       }
+      asprintf(&output, "%s %s:", output, line);
+      asprintf(&output_long, "%s%s\n", output_long, line);
 
       /* TODO: Need to do a similar debug line
       asprintf (&details, _("%s\n\
@@ -360,6 +365,7 @@ main (int argc, char **argv)
 
 
   printf ("DISK %s%s%s|%s\n", state_text (result), (erronly && result==STATE_OK) ? "" : preamble, output, perf);
+  printf ("%s", output_long);
   return result;
 }