New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


HTTP sensor base on device IP

Votes:

0

Your Vote:

Up

Down

Need to monitor a pool of server using an unique URL like below but with different IP :

http://app.test.local/login.html [192.168.10.10]
http://app.test.local/login.html [192.168.10.11]
http://app.test.local/login.html [192.168.10.11]

the apache server need the host : app.test.local

A feature need to be added on the http sensor to say : based the IP connection on the device and not based on a lookup of the host in the URL

http https httpsensor

Created on Mar 1, 2019 7:50:26 AM by  infranetwork (0) 1

Last change on Mar 5, 2019 11:57:20 AM by  Torsten Lindner [Paessler Support]



2 Replies

Votes:

1

Your Vote:

Up

Down

Not sure if the Paessler support will transition this request to a proper Feature request - but in any case - I like the idea you have there and since I am not aware of a solution for it that might already exist, I did a quick research.

What would work is a PowerShell script - I see if I might have time to work on it.. or you can do it on your own..

What you need is this:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-6

You will fire this command against the IP address, now, since the URL is part of the header of the web-request - specifically the HOST value in the HEADER.

You might run in to some resistance there - but I think there seems to be an interesting approach to bypass this here:

https://stackoverflow.com/questions/19937379/set-the-host-header-when-using-invoke-restmethod

There rest is just developing it out..

I doubt a DNS request wold give you all possible IPs from this round-robin configuration, especially not external DNS servers. Therefor you would need to inject all the IPs and the single target URL to the script, but that can be done via parameters...

Let me know if you need help - I generally suggest to try it on your own to learn at the same time..

PS: the Paessler Support Team might have better ideas and know about existing solutions.

Regards

Florian Rossmark

www.it-admins.com

Created on Mar 4, 2019 4:22:58 PM by  Florian Rossmark (4,315) 4 2



Votes:

0

Your Vote:

Up

Down

The following is not yet the perfect script - but it might just work for you.

param(
    [string] $DomainName = "",
    [string] $IP = "",
    [string] $KeyWord = " ",
    [int] $MinimumResponseSizeInByte = 1,
    [bool] $useHTTPS = $true
)
add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

If ($useHTTPS -eq $true) { 
    $Prefix = "https://" 
} Else { 
    $Prefix = "http://" 
}

$IWRResponse = "";
$IWRError = 0;
$IWRErrorMessage = "";

$IWRResponse = Try {
    Invoke-WebRequest -Uri "$Prefix$IP" -Headers @{Host="$DomainName"} -ErrorAction Stop
} Catch {
    $IWRError = $_.Exception.GetHashCode()        
    If ($IWRError -eq 0) {
        $IWRError = 1 
    }
    $IWRErrorMessage = $_.Exception.Message
}
Try {
    $IWRResponse = $IWRResponse.ToString()
} Catch {}

$KeyWordFound = 0
Try {
    If ($IWRResponse.Contains($KeyWord)) { 
        $KeyWordFound = 1 
    } 
} Catch {}

$ResponseSufficient = 0 
Try {
    If ($IWRResponse -gt $MinimumResponseSizeInByte) { 
        $ResponseSufficient = 1 
    }  
} Catch {}

$XML = "<prtg>
    <result>
        <channel>Check result</channel>
        <value>$IWRError</value>
        <LimitMode>1</LimitMode>
        <LimitMinError>0</LimitMinError>
        <LimitMaxError>0</LimitMaxError>
        <LimitErrorMsg>$IWRErrorMessage</LimitErrorMsg>
    </result>
    <result>
        <channel>Keyword found</channel>
        <value>$KeyWordFound</value>
        <LimitMode>1</LimitMode>
        <LimitMinError>1</LimitMinError>
        <LimitErrorMsg>Keyword was not found in response</LimitErrorMsg>
    </result>
    <result>
        <channel>Response Length</channel>
        <value>" + $IWRResponse.Length + "</value>
        <VolumeSize>Byte</VolumeSize>
        <NotifyChanged>1</NotifyChanged>
    </result>
    <result>
        <channel>Reponse Length sufficient</channel>
        <value>$ResponseSufficient</value>
        <LimitMode>1</LimitMode>
        <LimitMinError>1</LimitMinError>
        <LimitErrorMsg>Response size not sufficient</LimitErrorMsg>
    </result>
</prtg>"

Function WriteXmlToScreen ([xml]$xml) #just to make it clean XML code...
{
    $StringWriter = New-Object System.IO.StringWriter;
    $XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter;
    $XmlWriter.Formatting = "indented";
    $xml.WriteTo($XmlWriter);
    $XmlWriter.Flush();
    $StringWriter.Flush();
    Write-Output $StringWriter.ToString();
}

WriteXmlToScreen "$XML"

In you case the following parameters would possibly work

-DomainName "app.test.local" -IP "192.168.10.10/login.html" -useHTTPs 0

If you add -Keyword "abcd" you can search for a keyword in the raw HTML response.

You could also engage the -MinimumResponseSizeInByt 999 parameter - while 999 bytes is just a guess of how much you should get back...

Let me know if it worked... of course you would need a sensor per target IP in this case - I did not develop it out to the extreme and the code could easily be optimized, just thought the idea of it is nice and it might be a start.

Regards

Florian Rossmark

www.it-admins.com

Created on Mar 6, 2019 3:41:40 AM by  Florian Rossmark (4,315) 4 2



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.