ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/statgrab/statgrab-make-mrtg-config.in
(Generate patch)

Comparing projects/libstatgrab/src/statgrab/statgrab-make-mrtg-config.in (file contents):
Revision 1.1 by ats, Thu Aug 28 11:26:42 2003 UTC vs.
Revision 1.4 by tdb, Mon Jan 19 16:49:23 2004 UTC

# Line 1 | Line 1
1   #!/usr/bin/perl -w
2   # i-scream central monitoring system
3   # http://www.i-scream.org
4 < # Copyright (C) 2000-2003 i-scream
4 > # Copyright (C) 2000-2004 i-scream
5   #
6   # This program is free software; you can redistribute it and/or
7   # modify it under the terms of the GNU General Public License
# Line 16 | Line 16
16   # You should have received a copy of the GNU General Public License
17   # along with this program; if not, write to the Free Software
18   # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 + #
20 + # $Id$
21  
22   use strict;
23   use Getopt::Long;
# Line 27 | Line 29 | my $workdir = undef;
29   my $kib = 1024;
30   my $mib = $kib * $kib;
31  
32 + # Type 0 is plain integers.
33 + my $KIBIBYTES = 1;
34 + my $PERCENT = 2;
35 +
36   # Print an entry in the MRTG config file.
37   sub entry ($$$$$$$$$$) {
38 <        my ($title, $vali, $valo, $max, $ylegend, $yunit, $legendi, $legendo, $gauge, $in_kib) = @_;
38 >        my ($title, $vali, $valo, $max, $ylegend, $yunit, $legendi, $legendo, $gauge, $type) = @_;
39          my $name = $vali;
40          my $options = "";
41          $options .= " noo" unless defined $valo;
42          $options .= " gauge" if $gauge;
43 +        my $sgoptions = "";
44 +        $sgoptions .= " -o -p" if $type == $PERCENT;
45  
46          print "\n";
47          print "Title[$name]: $title\n";
# Line 43 | Line 51 | sub entry ($$$$$$$$$$) {
51          print "ShortLegend[$name]: $yunit\n";
52          print "LegendI[$name]: $legendi\n";
53          print "LegendO[$name]: $legendo\n" if defined $valo;
54 <        if ($in_kib) {
54 >        if ($type == $KIBIBYTES) {
55                  print "kMG[$name]: Ki,Mi,Gi,Ti\n";
56          }
57          $valo = "const.0" unless defined $valo;
58          print "Options[$name]:$options\n" if $options ne "";
59 <        print "Target[$name]: `$statgrab -p -m $vali $valo`\n";
59 >        print "Target[$name]: `$statgrab$sgoptions -m $vali $valo`\n";
60   }
61  
62   my $package_version = '@PACKAGE_VERSION@';
# Line 113 | Line 121 | sub main () {
121          }
122  
123          if (exists $toplevel{"cpu"}) {
124 <                entry("CPU idle", "cpu.idle", undef, "100", "Idle", "%", "idle", undef, 1, 0);
125 <                entry("CPU iowait", "cpu.iowait", undef, "100", "iowait", "%", "iowait", undef, 1, 0);
126 <                entry("CPU kernel", "cpu.kernel", undef, "100", "Kernel", "%", "kernel", undef, 1, 0);
127 <                entry("CPU nice", "cpu.nice", undef, "100", "Nice", "%", "nice", undef, 1, 0);
128 <                entry("CPU swap", "cpu.swap", undef, "100", "Swap", "%", "swap", undef, 1, 0);
129 <                entry("CPU user", "cpu.user", undef, "100", "User", "%", "user", undef, 1, 0);
124 >                entry("CPU idle", "cpu.idle", undef, "100", "Idle", "%", "idle", undef, 1, $PERCENT);
125 >                entry("CPU iowait", "cpu.iowait", undef, "100", "iowait", "%", "iowait", undef, 1, $PERCENT);
126 >                entry("CPU kernel", "cpu.kernel", undef, "100", "Kernel", "%", "kernel", undef, 1, $PERCENT);
127 >                entry("CPU nice", "cpu.nice", undef, "100", "Nice", "%", "nice", undef, 1, $PERCENT);
128 >                entry("CPU swap", "cpu.swap", undef, "100", "Swap", "%", "swap", undef, 1, $PERCENT);
129 >                entry("CPU user", "cpu.user", undef, "100", "User", "%", "user", undef, 1, $PERCENT);
130          }
131  
132          foreach my $disk (sort keys %disks) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines