search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell, Windows Server | No Comment | 2,489 views | 23/09/2014 04:25

This is an example script to show how you can monitor Supermicro servers via PowerShell:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Test Supermicro CLI Path
$TestSupermicroCLIPath = Test-Path -Path "C:\Program Files\Supermicro\SuperDoctor5\sdc.bat"
 
if ($TestSupermicroCLIPath -eq $True)
{				
	# Test Supermicro CLI Output
	$SensorInfo = Invoke-Command -ScriptBlock {
		&'C:\Program Files\Supermicro\SuperDoctor5\sdc.bat' "-d"
	}
}
 
# Create Supermicro Sensors Function
function Get-SupermicroSensor
{
	param ($SensorSource)
 
	if ($SensorSource)
	{
		# Get Supermicro Sensors
		$SupermicroSensors = $SensorSource | Select-String "2.1.1.1.1.2."
 
		# Parse Supermicro Output
		foreach ($SupermicroSensor in $SupermicroSensors)
		{
			# Clear Values
			$SupermicroSensorCurrentReading = $Null;
			$SupermicroSensorHighLimit = $Null;
			$SupermicroSensorLowLimit = $Null;
			$SupermicroSensorMetric = $Null;
 
			# Get Sensor Information
			$SupermicroSensorValues = $SupermicroSensor.ToString().Split(",")
			$SupermicroSensorID = ($SupermicroSensorValues[0]).Split(".")[-1]
			$SupermicroSensorName = $SupermicroSensorValues[-1]
 
			# Get Sensor Results
			$SupermicroSensorCurrentReading = $SensorSource | Select-String "2.1.1.1.1.4.$SupermicroSensorID\b"
			$SupermicroSensorHighLimit = $SensorSource | Select-String "2.1.1.1.1.5.$SupermicroSensorID\b"
			$SupermicroSensorLowLimit = $SensorSource | Select-String "2.1.1.1.1.6.$SupermicroSensorID\b"
			$SupermicroSensorMetric = $SensorSource | Select-String "2.1.1.1.1.11.$SupermicroSensorID\b"
 
			# Parameter Validation
			if (!$SupermicroSensorCurrentReading) { [string]$SupermicroSensorCurrentReading = "Unknown" } else { [string]$SupermicroSensorCurrentReading = $SupermicroSensorCurrentReading.ToString().Split(",")[-1] }
			if (!$SupermicroSensorHighLimit) { [string]$SupermicroSensorHighLimit = "Unknown" } else { [string]$SupermicroSensorHighLimit = $SupermicroSensorHighLimit.ToString().Split(",")[-1] }
			if (!$SupermicroSensorLowLimit) { [string]$SupermicroSensorLowLimit = "Unknown" } else { [string]$SupermicroSensorLowLimit = $SupermicroSensorLowLimit.ToString().Split(",")[-1] }
			if (!$SupermicroSensorMetric) { [string]$SupermicroSensorMetric = "Unknown" } else { [string]$SupermicroSensorMetric = $SupermicroSensorMetric.ToString().Split(",")[-1] }
 
			$Properties = New-Object Psobject
			$Properties | Add-Member Noteproperty ID $SupermicroSensorID
			$Properties | Add-Member Noteproperty Name $SupermicroSensorName
			$Properties | Add-Member Noteproperty CurrentReading $SupermicroSensorCurrentReading
			$Properties | Add-Member Noteproperty Metric $SupermicroSensorMetric
			$Properties | Add-Member Noteproperty HighLimit $SupermicroSensorHighLimit
			$Properties | Add-Member Noteproperty LowLimit $SupermicroSensorLowLimit
			Write-Output $Properties
		}
	}
}
 
# Get Supermicro Sensor Results
$SupermicroSensorResults = Get-SupermicroSensor -SensorSource $SensorInfo

You need to install Super Doctor 5 on your Supermicro server before using this script.