我正在尝试使用 Munin 插件进行软件突袭。这是插件的代码:https ://github.com/munin-monitoring/contrib/blob/master/plugins/disk/raid
目前我的团队正在重建,这是当前的输出:
# cat /proc/mdstat
Personalities : [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md2 : active raid1 sda3[0] sdb3[1]
2925544767 blocks super 1.2 [2/2] [UU]
[==>..................] resync = 14.4% (422554560/2925544767) finish=5246.6min speed=7950K/sec
md1 : active raid1 sda2[0] sdb2[1]
524276 blocks super 1.2 [2/2] [UU]
resync=DELAYED
md0 : active raid1 sda1[0] sdb1[1]
4193268 blocks super 1.2 [2/2] [UU]
resync=DELAYED
unused devices: <none>
但是当我运行插件时,我得到以下输出(说明所有磁盘都已同步):
# munin-run raid
md2.value 100
md2_rebuild.value 100
md1.value 100
md1_rebuild.value 100
md0.value 100
md0_rebuild.value 100
在以下几行中,我了解(我不是程序员)在代码运行期间,$pct
>= 100,因此$rpct
设置为 100(这是我对所有 raid 数组的输出)。那么哪些值在我的输出中起作用$nact
并代表?这将帮助我找出为什么 $pct >= 100。$nmem
cat /proc/mdstat
my $pct = 100 * $nact / $nmem;
my $rpct = 100;
if ( $pct < 100 ) {
my @output = `/sbin/mdadm -D /dev/$dev | grep Rebuild`;
if( $output[0] =~ /([0-9]+)% complete/ ) {
$rpct = $1;
} else {
$rpct = 0;
}
我认为这个正则表达式拥有答案,但正如我所说,我不是程序员:P
while ($text =~ /(md\d+)\s+:\s+active\s+(\(auto-read-only\)\s+|)(\w+)\s+(.*)\n.*\[(\d+)\/(\d+)]\s+\[(\w+)]/ ) {
my($dev,$dummy,$type,$members,$nmem,$nact,$status) = ($1,$2,$3,$4,$5,$6,$7);
提前致谢 :-)