Hello

is there a sensor in PRTG, which can be added to each device to lookup for the DNS-Entry and / or the IP-address of this device?

Like it is possible with "nslookup".

I will monitor, if there is valid DNS-Entry for several devices.


Article Comments

Dear Uwe,

Thank you very much for your knowledge base post.

I'm sorry but PRTG does not offer such a sensor out-of-the-box. However, you might be able to retrieve the information by writing your own Custom Sensor.

Kind regards,
Sebastian


Feb, 2017 - Permalink

Hello!

I found this question and we ended up writing our own custom sensor, which is just a simple PowerShell script. I'll share with the community. I'm not PowerShell expert, but this got the job done - just place it in the special EXE directory outlined in Sebastian's link above and modify as needed.

$DNSName = "www.website.com"
$AllowedIPArray = @("x.x.x.x","y.y.y.y")

Try {
    # NOTE: I use this method vs. the Resolve-DnsName since the output of the cmdlet mixes different object types 
    # (see link below), so it's more work to handle that.
    # https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/14452845-default-resolve-dnsname-object-output-results-in-a
    $DNSResultArray = [System.Net.Dns]::Resolve($DNSName).AddressList
}
# we need to catch the error thrown if DNS lookup fails
Catch {
    write-host "1:DNS Lookup Error"
    exit 1
}

# something is wrong, if more or less than one A record is returned.
if ($DNSResultArray.Count -ne 1) {
    write-host "2:DNS Lookup Error"
    exit 1 # warning
}

if ($AllowedIPArray -notcontains $DNSResultArray) {
    write-host "3:New IP Found " + $DNSResultArray[0].IPAddressToString
    exit 2 # error
}

write-host "0:OK"
exit 0

Apr, 2017 - Permalink