Checking if host can reach external site

Hello, we are using the raw edition and I am looking to have a check on specific hosts (windows) that require connectivity to external sources.
I would to be able to check if they can reach these sources on port 443 & to alert if not successful, as well as have the history of the check showing.

I have done a local check which will change to crit if the check fails, but I have no historical data…
Also not sure if I am doing it the best way. Any help would be appreciated!

You can use MRPE to use Nagios Checks on the Host, like Check_http or Check_tcp. Then you will have not only Performance Data and History, but also auto discovery.

Just deploy the Plugin to the Host, then in /etc/check_mk/mrpe.cfg set:
A_NAME /path/to_plugin -Params

Details here: Monitoring Linux - The new agent for Linux in detail

1 Like

The hosts are windows host, is the setup still the same?

That you will find https://docs.checkmk.com/latest/en/agent_windows.html#mrpe. If possible, I would use the Agent Bakery for that.

Also, you can’t use the Nagios plugins in Checkmk for that, you need to look to find windows versions of check_http for example

I was reading along, was interested in having something similar.

Nagios Exchange has a bat file you can download: Check connect from windows host. - Nagios Exchange

It needs a free to download file called PortQry.exe from Microsoft: https://www.microsoft.com/en-us/download/details.aspx?id=17148
Documentation of PortQry.exe, so you know what bat file does: Using the PortQry command-line tool - Windows Server | Microsoft Learn

You need to change the line in check_connect.bat where PortQry.exe is stored.

Output of bat will be something like:

C:\portqry> .\check_connect.bat google.com tcp 80
OK: tcp port 80 on google.com LISTENING.

C:\portqry> .\check_connect.bat google.com tcp 555
CRITICAL: tcp port 555 on google.com NOT LISTENING!

I haven’t implemented it as mrpe in checkmk yet.
Weekend soon, and need to finish some other stuff first. (-;

EDIT: implemented above as mrpe, but don’t get it to work yet.

change of the check_mk.user.yml

mrpe:
    enabled: yes
    timeout: 60
    config:
        - check = google.com 'C:\ProgramData\checkmk\agent\mrpe\check_connect.bat google.com tcp 80'

I don’t get a new undecided service in service configuration. Not sure what is missing to make it work. Running bat from powershell prompt works fine.

PS C:\ProgramData\checkmk\agent\mrpe> .\check_connect.bat google.com tcp 80
OK: tcp port 80 on google.com LISTENING.

The only thing I can think of are the missing warning & critical options, but bat doesn’t produce a metric, just a state.

EDIT2: Was checking agent log filled with errors, which seem unrelated. But still, need dig deeper, but not now. Commented out config changes. Something to look at for another time …

I would recommend doing this in powershell - writing a local check (or reuse one already created this have been asked several times)

With powershell you would not have any dependencies, and writing an active check will not allow for any unsafe parameters to be passed

2 Likes

There is no bakery in the RAW edition. Comments like this don’t help new users like
@Grog093 .

Yes, I oversaw RAW Edition in my second post, which was an answer to the question about Windows, but both my answers point to the documentation, where you can see how to configure it manually in the RAW Edition.

I would also use a local check in powershell that uses invoke-webrequest.
A simple example is in this post :

1 Like

Thanks, I will have a look into the nagios plugins.

Thanks, I will take a look at this. I do have a simple check similar to this but just wasn’t getting anything historic…

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.