summaryrefslogtreecommitdiffstats
path: root/web/attachments/382256-nagios-plugins-check_disk_usage.patch
blob: 8beefc19e8947d6ba1cdea00248494ec4e92cf30 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
diff -urN nagios-plugins-1.4.15/plugins/check_disk.c nagios-plugins-1.4.15.new/plugins/check_disk.c
--- nagios-plugins-1.4.15/plugins/check_disk.c	2010-07-27 22:47:16.000000000 +0200
+++ nagios-plugins-1.4.15.new/plugins/check_disk.c	2010-08-04 13:49:46.000000000 +0200
@@ -148,6 +148,7 @@
 int path_selected = FALSE;
 char *group = NULL;
 struct stat *stat_buf;
+int output_usage = FALSE;
 
 
 int
@@ -173,7 +174,6 @@
   struct parameter_list *temp_list, *path;
   struct name_list *seen = NULL;
 
-  preamble = strdup (" - free space:");
   output = strdup ("");
   details = strdup ("");
   perf = strdup ("");
@@ -191,6 +191,12 @@
   if (process_arguments (argc, argv) == ERROR)
     usage4 (_("Could not parse arguments"));
 
+  if (output_usage) {
+    preamble = strdup (" - used space:");
+  } else {
+    preamble = strdup (" - free space:");
+  }
+
   /* If a list of paths has not been selected, find entire
      mount list and create list of paths
    */
@@ -392,9 +398,9 @@
       asprintf (&output, "%s %s %.0f %s (%.0f%%",
                 output,
                 (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir,
-                dfree_units,
+                output_usage ? dused_units : dfree_units,
                 units,
-                dfree_pct);
+                output_usage ? 100-dfree_pct : dfree_pct);
       if (dused_inodes_percent < 0) {
         asprintf(&output, "%s inode=-);", output);
       } else {
@@ -495,6 +501,7 @@
     {"verbose", no_argument, 0, 'v'},
     {"quiet", no_argument, 0, 'q'},
     {"clear", no_argument, 0, 'C'},
+    {"usage", no_argument, 0, 'U'},
     {"version", no_argument, 0, 'V'},
     {"help", no_argument, 0, 'h'},
     {0, 0, 0, 0}
@@ -510,7 +517,7 @@
       strcpy (argv[c], "-t");
 
   while (1) {
-    c = getopt_long (argc, argv, "+?VqhveCt:c:w:K:W:u:p:x:X:mklLg:R:r:i:I:MEA", longopts, &option);
+    c = getopt_long (argc, argv, "+?VqhveUCt:c:w:K:W:u:p:x:X:mklLg:R:r:i:I:MEA", longopts, &option);
 
     if (c == -1 || c == EOF)
       break;
@@ -782,6 +789,9 @@
       path_selected = FALSE;
       group = NULL;
       break;
+    case 'U': /* display used space */
+      output_usage = TRUE;
+      break;
     case 'V':                 /* version */
       print_revision (progname, NP_VERSION);
       exit (STATE_OK);
@@ -958,6 +968,8 @@
   printf (UT_VERBOSE);
   printf (" %s\n", "-X, --exclude-type=TYPE");
   printf ("    %s\n", _("Ignore all filesystems of indicated type (may be repeated)"));
+  printf (" %s\n", "-U, --usage");
+  printf ("    %s\n", _("Output used space not free space"));
 
   printf ("\n");
   printf ("%s\n", _("Examples:"));
@@ -980,7 +992,7 @@
   printf ("%s\n", _("Usage:"));
   printf (" %s -w limit -c limit [-W limit] [-K limit] {-p path | -x device}\n", progname);
   printf ("[-C] [-E] [-e] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n");
-  printf ("[-t timeout] [-u unit] [-v] [-X type]\n");
+  printf ("[-t timeout] [-u unit] [-v] [-X type] [-U]\n");
 }
 
 void