2
0
Fork 0
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:
Ken-ichi Mito 2015-05-04 14:56:30 +09:00
parent c4eb877198
commit 2e0acaca2b

View file

@ -29,16 +29,17 @@ if ( $ARGV[0] and $ARGV[0] eq "config" ) {
print "graph_scale no\n"; print "graph_scale no\n";
} }
open(my $mdstat, "/proc/mdstat");
my $text;
{ {
local( $/, *MDSTAT ) ; local($/);
open (MDSTAT, "/proc/mdstat") or exit 1; $text = <$mdstat>;
#open (MDSTAT, "/etc/munin/plugins/sample.failed") or exit 1; }
my $text = <MDSTAT>; close($mdstat);
close MDSTAT;
# Should look like "active raid1 sda1[0] sdc1[2] sdb1[1]" # Should look like "active raid1 sda1[0] sdc1[2] sdb1[1]"
# Interestingly, swap is presented as "active (auto-read-only)" # 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)/ ) { 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); 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"; # print "$text\nitem: $dev $type ($members) status=$status $proc\n";
if ( $ARGV[0] and $ARGV[0] eq "config" ) { 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"; print $dev, "_check.value $cpct\n";
} }
$text = $'; $text = $';
}
} }
exit 0; exit 0;