Skip to content

Instantly share code, notes, and snippets.

@gotnix
Created October 15, 2012 16:43
Show Gist options
  • Select an option

  • Save gotnix/3893523 to your computer and use it in GitHub Desktop.

Select an option

Save gotnix/3893523 to your computer and use it in GitHub Desktop.
过滤MegaCli 输出的AWK 脚本
#!/usr/bin/awk -f
## MegaCli -LDPDInfo -aAll
## 过滤MegaCli 输出的PD/VD信息,单行模式
# awk 'BEGIN { FS=": "; ME_PD=0 } /^Media Error/ { if ( $2 != 0 ) ++ME_PD } END { print "Media_Error_PD = ",ME_PD }'
BEGIN {
FS=": "; OFF_LIN=0; MedErr_PD=0; OthErr_PD=0; PreFail_PD=0; NonOpt_VD=0
}
/^Firmware state:/ { if ( $2 != "Online" ) ++OFF_LIN }
/^Media Error Count:/ { if ( $2 != 0 ) ++MedErr_PD }
/^Other Error Count:/ { if ( $2 != 0 ) ++OthErr_PD }
/^Predictive Failure Count:/ { if ( $2 != 0 ) ++PreFail_PD }
/^State:/ { if ( $2 != "Optimal" ) ++NonOpt_VD }
END {
print "Firmware_Offline_PD =",OFF_LIN
print "Media_Error_PD =",MedErr_PD
print "Other_Error_PD =",OthErr_PD
print "Predictive_Failure_PD =",PreFail_PD
print "NonOptimal_VD =",NonOpt_VD
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment