mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
refactoring - replace TAB with 8 spaces, use lexical variable for file handle
* reduce indentation of local($/)
This commit is contained in:
parent
c4eb877198
commit
2e0acaca2b
1 changed files with 46 additions and 46 deletions
|
@ -29,16 +29,17 @@ if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
|||
print "graph_scale no\n";
|
||||
}
|
||||
|
||||
open(my $mdstat, "/proc/mdstat");
|
||||
my $text;
|
||||
{
|
||||
local( $/, *MDSTAT ) ;
|
||||
open (MDSTAT, "/proc/mdstat") or exit 1;
|
||||
#open (MDSTAT, "/etc/munin/plugins/sample.failed") or exit 1;
|
||||
my $text = <MDSTAT>;
|
||||
close MDSTAT;
|
||||
local($/);
|
||||
$text = <$mdstat>;
|
||||
}
|
||||
close($mdstat);
|
||||
|
||||
# Should look like "active raid1 sda1[0] sdc1[2] sdb1[1]"
|
||||
# Interestingly, swap is presented as "active (auto-read-only)"
|
||||
while ($text =~ /(md\d+)\s+:\s+active\s+(\(auto-read-only\)\s+|)(\w+)\s+(.*)\n.*\[(\d+)\/(\d+)]\s+\[(\w+)]\n(.*(check|resync)\s=\s+(\d+\.\d+)%|.*\n)/ ) {
|
||||
# Should look like "active raid1 sda1[0] sdc1[2] sdb1[1]"
|
||||
# Interestingly, swap is presented as "active (auto-read-only)"
|
||||
while ($text =~ /(md\d+)\s+:\s+active\s+(\(auto-read-only\)\s+|)(\w+)\s+(.*)\n.*\[(\d+)\/(\d+)]\s+\[(\w+)]\n(.*(check|resync)\s=\s+(\d+\.\d+)%|.*\n)/ ) {
|
||||
my($dev,$dummy,$type,$members,$nmem,$nact,$status,$dummy2,$dummy3,$proc) = ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10);
|
||||
# print "$text\nitem: $dev $type ($members) status=$status $proc\n";
|
||||
if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
||||
|
@ -74,7 +75,6 @@ if ( $ARGV[0] and $ARGV[0] eq "config" ) {
|
|||
print $dev, "_check.value $cpct\n";
|
||||
}
|
||||
$text = $';
|
||||
}
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
|
Loading…
Reference in a new issue