Powershell Invalid Result

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
Celay
Posts: 11
Joined: Fri Aug 15, 2014 7:22 am

Powershell Invalid Result

Post by Celay »

Hello,
Iam trying to get an RBL check through Host-Monitor working, Iam using a Powershell Script.
If I run the Script everything works fine.
[14:53:59] HostMonitor is going to execute "RBL" script ...
[14:54:00] Script started, invalid result received:
----------
127.0.0.2
----------
But I cant find the options for results, so Iam wondering how or where I can change the results.

Thanks in advance.
Celay
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

As I understand, you are tryig to use "Shell Script" test method?
Your script should return text in the following format:
ScriptRes:<Status>:<Reply text>
E.g.
ScriptRes:Ok:My reply text or value
ScriptRes:Bad:My reply text or value
ScriptRes:Host is alive:My reply text or value
ScriptRes:No answer:My reply text or value
ScriptRes:Unknown:My reply text or value
ScriptRes:Unknown host:My reply text or value
ScriptRes:Bad contents:My reply text or value

You may find script examples in Script Manager (Profiles -> Script Manager)
Celay
Posts: 11
Joined: Fri Aug 15, 2014 7:22 am

Post by Celay »

First of all thanks for the fast response.
And yes Iam using the "Shell Script" test method.

In the Hostmonitor Script Manager Box "Script" I wrote

$statusAlive = "ScriptRes:Alive:127.0.0.2"
$statusDead = "ScriptRes:127.0.0.1:"
$statusUnknown = "ScriptRes:Unknown:"
$statusNotResolved = "ScriptRes:Unknown host:"
$statusOk = "ScriptRes:Ok:"
$statusBad = "ScriptRes:Bad:"
$statusBadContents = "ScriptRes:Bad contents:"
Nothing else. (I also was wondering if the Script is supposed to be also there but I guess it shouldn't)

I also already changed the Alive variable to "Host Alive" or only "Alive" but it didn't work.
So Iam wondering if maybe the the 127.0.0.* response causes this?
[15:31:42] HostMonitor is going to execute "RBL" script ...
[15:31:43] Script started, invalid result received:
----------
127.0.0.55
ScriptRes:Host Alive
----------
Is the Script supposed to ONLY write out the Host Alive message or is it ok if it also writes the 127.0.0.*

In case it might help you to see the Script:
$statusAlive = "ScriptRes:Host Alive"
$statusDead = "ScriptRes:127.0.0.1:"
$statusUnknown = "ScriptRes:Unknown:"
$statusNotResolved = "ScriptRes:Unknown host:"
$statusOk = "ScriptRes:Ok:"
$statusBad = "ScriptRes:Bad:"
$statusBadContents = "ScriptRes:Bad contents:"
(
$IP = '127.0.0.55'
)

$reversedIP = ($IP -split '\.')[3..0] -join '.'

$blacklistServers = @(
'b.barracudacentral.org'
'spam.rbl.msrbl.net'
'zen.spamhaus.org'
'bl.spamcannibal.org'
)

$blacklistedOn = @()

foreach ($server in $blacklistServers)
{
$fqdn = "$reversedIP.$server"

try
{
$null = [System.Net.Dns]::GetHostEntry($fqdn)
$blacklistedOn += $server
}
catch { }
}

if ($blacklistedOn.Count -gt 0)
{
# The IP was blacklisted on one or more servers; send your email here. $blacklistedOn is an array of the servers that returned positive results.
Write-Host "$statusDead"
}
else
{
Write-Host "$statusAlive"
}
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

You cannot use manual test Status.
There are fixed possible test statuses (exact text values should be used):
Host is alive
No answer
Unknown
Unknown host
Ok
Bad


First two line in your script represent incorrect status text values.
You may replace first two lines in the script by the following lines:
$statusAlive = "ScriptRes:Host is alive:"
$statusDead = "ScriptRes:No answer:"
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Is the Script supposed to ONLY write out the Host Alive message or is it ok if it also writes the 127.0.0.*
if you need to set IP as Reply for "Host is alive" status, just replace line
Write-Host "$statusAlive"
with
Write-Host "$statusAlive"$IP
Celay
Posts: 11
Joined: Fri Aug 15, 2014 7:22 am

Post by Celay »

KS-Soft Europe wrote:
Is the Script supposed to ONLY write out the Host Alive message or is it ok if it also writes the 127.0.0.*
if you need to set IP as Reply for "Host is alive" status, just replace line
Write-Host "$statusAlive"
with
Write-Host "$statusAlive"$IP
It worked, thanks for this great and fast support, keep it up!

Celay
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

You are welcome!
Post Reply