Révision 8dc6745a
Initial version
| plugins/other/drbd | ||
|---|---|---|
| 1 |
#!/usr/bin/perl |
|
| 2 |
|
|
| 3 |
# http://www.drbd.org/users-guide/ch-admin.html#s-proc-drbd |
|
| 4 |
|
|
| 5 |
use strict; |
|
| 6 |
|
|
| 7 |
my $file="/proc/drbd"; |
|
| 8 |
my $store = {};
|
|
| 9 |
my $temp; |
|
| 10 |
|
|
| 11 |
&crunch; |
|
| 12 |
&display; |
|
| 13 |
|
|
| 14 |
sub display{
|
|
| 15 |
if ($ARGV[0] and $ARGV[0] eq "config"){
|
|
| 16 |
print "graph_title DRBD\n"; |
|
| 17 |
print "graph_category DRBD\n"; |
|
| 18 |
print "graph_info Graph DRBD\n"; |
|
| 19 |
print "graph_vlabel Bytes per \${graph_period} read (-) / written (+)\n";
|
|
| 20 |
print "graph_args --base 1024 --lower-limit 0\n"; |
|
| 21 |
|
|
| 22 |
foreach my $key ( keys %$store ){
|
|
| 23 |
my $drbdname = 'drbd'.$key; |
|
| 24 |
print $drbdname."dr.label $drbdname disk\n"; |
|
| 25 |
print $drbdname."dr.cdef ".$drbdname."dr,819,*\n"; |
|
| 26 |
print $drbdname."dr.type DERIVE\n"; |
|
| 27 |
print $drbdname."dr.min 0\n"; |
|
| 28 |
print $drbdname."dr.graph no\n"; |
|
| 29 |
print $drbdname."dw.label $drbdname disk\n"; |
|
| 30 |
print $drbdname."dw.cdef ".$drbdname."dw,819,*\n"; |
|
| 31 |
print $drbdname."dw.type DERIVE\n"; |
|
| 32 |
print $drbdname."dw.min 0\n"; |
|
| 33 |
print $drbdname."dw.negative ".$drbdname."dr\n"; |
|
| 34 |
print $drbdname."nr.label $drbdname net\n"; |
|
| 35 |
print $drbdname."nr.cdef ".$drbdname."nr,819,*\n"; |
|
| 36 |
print $drbdname."nr.type DERIVE\n"; |
|
| 37 |
print $drbdname."nr.min 0\n"; |
|
| 38 |
print $drbdname."nr.graph no\n"; |
|
| 39 |
print $drbdname."ns.label $drbdname net\n"; |
|
| 40 |
print $drbdname."ns.cdef ".$drbdname."ns,819,*\n"; |
|
| 41 |
print $drbdname."ns.type DERIVE\n"; |
|
| 42 |
print $drbdname."ns.min 0\n"; |
|
| 43 |
print $drbdname."ns.negative ".$drbdname."nr\n"; |
|
| 44 |
} |
|
| 45 |
exit 0; |
|
| 46 |
} |
|
| 47 |
|
|
| 48 |
foreach my $key ( keys %$store ){
|
|
| 49 |
my $drbdname = 'drbd'.$key; |
|
| 50 |
print $drbdname."dw.value ".$store->{$key}->{'dw'}."\n";
|
|
| 51 |
print $drbdname."dr.value ".$store->{$key}->{'dr'}."\n";
|
|
| 52 |
print $drbdname."ns.value ".$store->{$key}->{'ns'}."\n";
|
|
| 53 |
print $drbdname."nr.value ".$store->{$key}->{'nr'}."\n";
|
|
| 54 |
} |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
sub crunch{
|
|
| 58 |
open (IN, $file ) || die "Could not open $file for reading: $!"; |
|
| 59 |
while (<IN>){
|
|
| 60 |
next if /version:|GIT-hash:/; |
|
| 61 |
chomp; |
|
| 62 |
|
|
| 63 |
my ($drbd) = $_ =~ /^\s+(\d):/; |
|
| 64 |
$temp = $drbd if $drbd =~ /\d/; |
|
| 65 |
|
|
| 66 |
if (/resync/){
|
|
| 67 |
my ($hits) = $_ =~ /hits:(\d*)/; |
|
| 68 |
$store->{ $temp }->{'resync'}->{hits} = $hits if $hits ne undef;
|
|
| 69 |
|
|
| 70 |
my ($misses) = $_ =~ /misses:(\d*)/; |
|
| 71 |
$store->{ $temp }->{'resync'}->{misses} = $misses if $misses ne undef;
|
|
| 72 |
|
|
| 73 |
my ($starving) = $_ =~ /starving:(\d*)/; |
|
| 74 |
$store->{ $temp }->{'resync'}->{starving} = $starving if $starving ne undef;
|
|
| 75 |
|
|
| 76 |
my ($dirty) = $_ =~ /dirty:(\d*)/; |
|
| 77 |
$store->{ $temp }->{'resync'}->{dirty} = $dirty if $dirty ne undef;
|
|
| 78 |
|
|
| 79 |
my ($changed) = $_ =~ /changed:(\d*)/; |
|
| 80 |
$store->{ $temp }->{'resync'}->{changed} = $changed if $changed ne undef;
|
|
| 81 |
} |
|
| 82 |
|
|
| 83 |
if (/act_log/){
|
|
| 84 |
my ($hits) = $_ =~ /hits:(\d*)/; |
|
| 85 |
$store->{ $temp }->{'act_log'}->{hits} = $hits if $hits ne undef;
|
|
| 86 |
|
|
| 87 |
my ($misses) = $_ =~ /misses:(\d*)/; |
|
| 88 |
$store->{ $temp }->{'act_log'}->{misses} = $misses if $misses ne undef;
|
|
| 89 |
|
|
| 90 |
my ($starving) = $_ =~ /starving:(\d*)/; |
|
| 91 |
$store->{ $temp }->{'act_log'}->{starving} = $starving if $starving ne undef;
|
|
| 92 |
|
|
| 93 |
my ($dirty) = $_ =~ /dirty:(\d*)/; |
|
| 94 |
$store->{ $temp }->{'act_log'}->{dirty} = $dirty if $dirty ne undef;
|
|
| 95 |
|
|
| 96 |
my ($changed) = $_ =~ /changed:(\d*)/; |
|
| 97 |
$store->{ $temp }->{'act_log'}->{changed} = $changed if $changed ne undef;
|
|
| 98 |
} |
|
| 99 |
|
|
| 100 |
my ($ns) = $_ =~ /ns:(\d*)/; |
|
| 101 |
$store->{ $temp }->{'ns'} = $ns if $ns ne undef;
|
|
| 102 |
|
|
| 103 |
my ($nr) = $_ =~ /nr:(\d*)/; |
|
| 104 |
$store->{ $temp }->{'nr'} = $nr if $ns ne undef;
|
|
| 105 |
|
|
| 106 |
my ($dw) = $_ =~ /dw:(\d*)/; |
|
| 107 |
$store->{ $temp }->{'dw'} = $dw if $dw ne undef;
|
|
| 108 |
|
|
| 109 |
my ($dr) = $_ =~ /dr:(\d*)/; |
|
| 110 |
$store->{ $temp }->{'dr'} = $dr if $dr ne undef;
|
|
| 111 |
|
|
| 112 |
my ($al) = $_ =~ /al:(\d*)/; |
|
| 113 |
$store->{ $temp }->{'al'} = $al if $dr ne undef;
|
|
| 114 |
|
|
| 115 |
my ($bm) = $_ =~ /bm:(\d*)/; |
|
| 116 |
$store->{ $temp }->{'bm'} = $bm if $dr ne undef;
|
|
| 117 |
|
|
| 118 |
my ($lo) = $_ =~ /lo:(\d*)/; |
|
| 119 |
$store->{ $temp }->{'lo'} = $lo if $dr ne undef;
|
|
| 120 |
|
|
| 121 |
my ($pe) = $_ =~ /pe:(\d*)/; |
|
| 122 |
$store->{ $temp }->{'pe'} = $pe if $dr ne undef;
|
|
| 123 |
|
|
| 124 |
my ($ua) = $_ =~ /ua:(\d*)/; |
|
| 125 |
$store->{ $temp }->{'ua'} = $ua if $dr ne undef;
|
|
| 126 |
|
|
| 127 |
my ($ap) = $_ =~ /ap:(\d*)/; |
|
| 128 |
$store->{ $temp }->{'ap'} = $ap if $ap ne undef;
|
|
| 129 |
|
|
| 130 |
my ($hits) = $_ =~ /hits:(\d*)/; |
|
| 131 |
$store->{ $temp }->{'hits'} = $hits if $hits ne undef;
|
|
| 132 |
|
|
| 133 |
my ($used) = $_ =~ /used:(\d*\\\d*)\s/; |
|
| 134 |
$store->{ $temp }->{'used'} = $used if $used ne undef;
|
|
| 135 |
} |
|
| 136 |
|
|
| 137 |
close (IN); |
|
| 138 |
|
|
| 139 |
#print Dumper \$store; |
|
| 140 |
|
|
| 141 |
} |
|
| 142 |
|
|
| 143 |
exit 0; |
|
Formats disponibles : Unified diff