I really have no experience setting up SAM monItors or powershell scripts but I have managed to create a powershell monitor component and application to store the temperature readings from a CAI WebControl 8 device. This device does not support SNMP but can be polled with PS ver3 using
[xml]$xml = 'Invoke-WebRequest -uri ${IP}/getall.cgi'.
I can get the script to connect and run correctly from the powershell screen on the Orion SAM server but cannot get any data to populate the xml variable from the Component. I have tested the script by forcing data into the variables and see the correct Statistic and Messages in the application. Eventually we will have 60+ of these devices to monitor.
It appears that the INVOKE-WebRequest is not getting any data back no matter what type of variable is used? Is there any other way to get data from an HTML page that works in the PowerShell Monitor?
I have attached my script.
-------------------------------------------------------------------------------------------------------------------------------
#NO Arguments - CAI WebControl 8 device can support 8 DS18b20 one-wire temperature sensors
# get current readings from WebControl appliance -login has been disabled for testing.
[xml]$xml = Invoke-WebRequest -uri ${IP}/getall.cgi
for($sensor=1; $sensor -le 8; $sensor++)
{
$romcode_element = "boundromcode$sensor"
$stat_element = "tstat$sensor"
$temp_element = "ts$sensor"
#get requested sensor# status (OK, FAILED, UNKNOWN)
$status = $xml.response.$stat_element
#get requested sensor# temp and remove F from string then convert to [INT]
$temperature = $xml.response.$temp_element
$temperature = $temperature.replace("F","")
$temperature = [int]$temperature
#get requested sensor# DS18B20 temp sensor ROM number
$romcode = $xml.response.$romcode_element
# Setup message:
$msg = "Sensor # $sensor serial #: $romcode - Status is: $status"
if ($sensor -eq "1")
{$TS1 = $temperature
$MSG1 = $msg}
elseif ($sensor -eq "2")
{$TS2 = $temperature
$MSG2 = $msg}
elseif ($sensor -eq "3")
{$TS3 = $temperature
$MSG3 = $msg}
elseif ($sensor-eq "4")
{$TS4 = $temperature
$MSG4 = $msg}
elseif ($sensor-eq "5")
{$TS5 = $temperature
$MSG5 = $msg}
elseif ($sensor-eq "6")
{$TS6 = $temperature
$MSG6 = $msg}
elseif ($sensor-eq "7")
{$TS7 = $temperature
$MSG7 = $msg}
elseif ($sensor-eq "8")
{$TS8 = $temperature
$MSG8 = $msg}
}
write-host "Statistic.1: $TS1"
write-host "Message.1: $MSG1"
write-host "Statistic.2: $TS2"
write-host "Message.2: $MSG2"
write-host "Statistic.3: $TS3"
write-host "Message.3: $MSG3"
write-host "Statistic.4: $TS4"
write-host "Message.4: $MSG4"
write-host "Statistic.5: $TS5"
write-host "Message.5: $MSG5"
write-host "Statistic.6: $TS6"
write-host "Message.6: $MSG6"
write-host "Statistic.7: $TS7"
write-host "Message.7: $MSG7"
write-host "Statistic.8: $TS8"
write-host "Message.8: $MSG8"
exit 0
NPM 12.0.1 / SAM 6.3.0