Forum Discussion
ok, what i did, it seems to work and it may or may not help someone else. I have no idea if it is right or wrong, I am still not convinced this script / alarm point is implemented in the smartest or most efficient way, but I am very new to LogicMonitor and it needs to work today ? ( and yes, I will be getting me some proper LM training!)
The general process is this, a ps script runs on the Biztalkhost and generates a list of sendports. :-
Then we have an embedded PS active discovery script which looks like this ( the commented out sections I will come too later! )
$hostname = "##system.sysname##.##system.domain##"
$csvFilePath = "\\192.168.123.195\BizTalk_Monitoring$\" + $hostname + "_sendPorts.csv"
#$regex= "RB\.RIP\.|Orchestrations\.|_e6dd5c64fddc35ff|_\d\.\d\.\d\.\d"
# Get BizTalk Send Port Information
if(Test-Path -Path $csvFilePath){
$sendPorts = Import-Csv -Path $csvFilePath
}
foreach ($sendport in $sendPorts){
$name = $sendport.Name
# $alias = $sendport.Name
#if (($sendport.Name.length) -gt 130 ) {
# $alias = $sendport.Name -replace $regex
#}
write-host "$name##$name"
#write-host "$name##$alias"
#write-host "$alias##$name"
}
this produces a nice long list of datapoints in LM ( fig1.png)
Then we run a collector script :-
$hostname = "##system.sysname##.##system.domain##"
$fileDateLimit = (get-date).addMinutes(-15)
$csvFilePath = "\\192.168.123.195\BizTalk_Monitoring$\" + $hostname + "_sendPorts.csv"
if(Test-Path -Path $csvFilePath){
$fileDate = (get-item -Path $csvFilePath).lastwritetime
[ARRAY]$sendPorts = Import-Csv -Path $csvFilePath
if ($fileDate -gt $fileDateLimit){
foreach ($sendPort in $sendPorts){
#$Location = $recLocs | where-object {$_.Name -eq "##WILDVALUE##"}
$status = $sendPort.Status
$name = $sendPort.Name
$stopped = $false
# Check if manually stopped = No alert
if ($name -like "_STOP*"){
$stopped = $true
write-host $name".Status=2"
}
if (($status -eq 2 -or $status -eq 1) -and -not $stopped){
write-host $name".Status=1"
}
elseif (($status -ne 2 -or $status -ne 1) -and -not $stopped) {
write-host $name".Status=0"
}
}
}
elseif ($fileDate -lt $fileDateLimit){
write-host $name".Status=100"
}
}
and if we have a nice long name... the script fails.
So I slapped in a little regex to remove some duplicate data in the names :-
$regex= "RB\.RIP\.|Orchestrations\.|_e6dd5c64fddc35ff|_\d\.\d\.\d\.\d"
foreach ($sendport in $sendPorts){
$name = $sendport.Name
$alias = $sendport.Name
if (($sendport.Name.length) -gt 130 ) {
$alias = $sendport.Name -replace $regex
}
#write-host "$name##$name"
#This seems to be the incantation that works.
write-host "$name##$alias"
}
So I am guessing it is that second parameter "$alias" that provides the name of the script that LM runs in the collector phase.
Thanks to everyone for pointers and tips. most helpful.
Related Content
- 3 months ago
- 7 years ago