0

I would like to check that a defined port on a host is closed, for example the 8080 port on host www.example.com. I tried something like:

check host www.example.com with address www.example.com
    if not failed 8080 protocol http then alert

but I think I cannot use that syntax because the not keyword is not allowed there:

/etc/monit/conf.d/myhost:29: Error: syntax error 'failed'

Is there any way to do that without writing an external script?

unlink
  • 690
  • 7
  • 12

1 Answers1

-1

The following Monit check will attempt connect to server www.example.com on port 8080 using TCP.

if failed host www.example.com port 8080 then alert

If the connection operation fails Monit generates an error and performs an action, it sends an alert in this case.

This is how the above looks in the monit log:

error : socket_create: Could not create socket -- Operation now in progress error : 'portCheckTest' failed, cannot open a connection to INET[www.example.com:8080] via TCP

zlemini
  • 1
  • 1