Monitoring raid arrays in Windows Core

image

/ > Hello!

In recent years we've learned that can and should monitor all of the many tools ranging from simple logs, ending with Zabbix, and all can be linked. Microsoft, in turn, also gave us a great tool WinRM, by which we can monitor the operating systems and not only. But as always there is a fly in the ointment, in fact about the "bypass" this fly in the ointment will be discussed.

As was said above, we have all the necessary tools to monitor the IT structure, but it so happened that we have no "automated" tool for monitoring Intel raid arrays in Windows core. Draw Your attention to the fact that we are talking about the usual "yellow iron".

We all know that there is software from Intel matrix storage and rapid, but unfortunately the standard Windows core it does not work, also there is a utility raidcfg32, it works in command-line mode, able to serve in manual mode and show the status, also in manual mode. I think America shouldn't be opened.

Constantly in manual mode to check the status of the raid or wait for the failure of the server virtualization is not the best choice.

To implement the insidious plan of the system on Intel raid we use
main tools:

the
    the
  • Powershell
  • the
  • EventLog
  • the
  • Raidcfg32.exe
  • the
  • Auxiliary:
  • the
  • WinRM
  • the
  • Rsyslog
  • the
  • LogAnalyzer

The first thing you need to install driver for raid controller:
cmd.exe pnputil.exe -i-a [path to *.inf]

Copy raidcfg32.exe in c:\raidcfg32\

Check whether the correct driver is installed:
cmd.exe C:\raidcfg32\raidcfg32.exe /stv

If we get the raid status and disk, then everything is OK.

Create a source in the application log:

*Then everything is done in powershell

the
New-EventLog -Source "RAID" -LogName "Application"

Executes the query of the status of the raid, remove the quotes for ease of parsing plug-in file contents.

the
c:\RAIDCFG32\RAIDCFG32.exe /stv > c:\RAIDCFG32\raidcfgStatus.txt
Get-Content "c:\RAIDCFG32\raidcfgStatus.txt" | ForEach-Object {$_ -replace ('"'),' '} > c:\RAIDCFG32\raidstatus.txt
$1 = Get-Content c:\RAIDCFG32\raidstatus.txt
$2 = "$1"

Looking for key words, if one of the words below would be found in the file errorRAID.txt appears set to true, it will indicate error if no match is found, the value will be false.

the
$2 -match "failed" > c:\RAIDCFG32\errorRAID.txt
$2 -match "disabled" >> c:\RAIDCFG32\errorRAID.txt
$2 -match "degraded" >> c:\RAIDCFG32\errorRAID.txt
$2 -match "rebuild" >> c:\RAIDCFG32\errorRAID.txt
$2 -match "updating" >> c:\RAIDCFG32\errorRAID.txt
$2 -match "critical" >> c:\RAIDCFG32\errorRAID.txt

The plug-in file written true and false, looking in the file true if true is found, replace it on Error, false on model Information.

Zapisyam result in EntryType.txt

the
$3 = Get-Content c:\RAIDCFG32\errorRAID.txt
$4 = "$3"
$5 = $4 -match "true"
$6 = "$5"
$7 = $6 -replace "true", "Error" > c:\RAIDCFG32\EntryType.txt
$8 = $6 -replace "false", "Information" >> c:\RAIDCFG32\EntryType.txt

Connected the contents of the file EntryType.txt and remove the False, thus, we get correct-EntryType which in turn is the "Level" messages.

Recorded in the EventLog message, where in case if keywords are found, the message level is Error, if not found, the Information.

the
$9 = Get-Content c:\RAIDCFG32\EntryType.txt
$10 = "$9"
$11 = $10 -replace "False"
Write-EventLog-LogName Application -Source "RAID" -EventID 9999-EntryType "$11" -Message "$1"
exit

Stored code in the *.ps1

Create a scheduler task to run the script, I start the job 1 every day and at every boot.

If you are collecting logs to another Windows OS in the Eventlog, the log collection server you must create a source of "RAID", the example is above.

We transport the logs through rsyslog rsyslog Adison for Windows.

The output is this picture:

image

Script without comments
c:\RAIDCFG32\RAIDCFG32.exe /stv > c:\RAIDCFG32\raidcfgStatus.txt
Get-Content "c:\RAIDCFG32\raidcfgStatus.txt" | ForEach-Object {$_ -replace ('"'),' '} > c:\RAIDCFG32\raidstatus.txt
$1 = Get-Content c:\RAIDCFG32\raidstatus.txt
$2 = "$1"
$2 -match "failed" > c:\RAIDCFG32\errorRAID.txt
$2 -match "disabled" >> c:\RAIDCFG32\errorRAID.txt

$2 -match "rebuild" >> c:\RAIDCFG32\errorRAID.txt
$2 -match "updating" >> c:\RAIDCFG32\errorRAID.txt
$2 -match "critical" >> c:\RAIDCFG32\errorRAID.txt
$3 = Get-Content c:\RAIDCFG32\errorRAID.txt
$4 = "$3"
$5 = $4 -match "true"
$6 = "$5"
$7 = $6 -replace "true", "Error" > c:\RAIDCFG32\EntryType.txt
$8 = $6 -replace "false", "Information" >> c:\RAIDCFG32\EntryType.txt
$9 = Get-Content c:\RAIDCFG32\EntryType.txt
$10 = "$9"
$11 = $10 -replace "False"
Write-EventLog-LogName Application -Source "RAID" -EventID 9999-EntryType "$11" -Message "$1"

Article based on information from habrahabr.ru

Comments

Popular posts from this blog

Powershell and Cyrillic in the console (updated)

Active/Passive PostgreSQL Cluster, using Pacemaker, Corosync

Experience with the GPS logger Holux M-241. Working from under Windows, Mac OS X, Linux