How could I monitor a service port from a bash shell?
I want to monitor a Java service (once per minute on port 9090) and then call "/etc/init.d/myservice -restart" if the service isn't responding with a simple HTML message.
How would you do something like this?
My idea was to use something similar to this:
wget -O - --no-check-certificate --progress=dot https://localhost:9090
Or
curl --insecure https://localhost:9090
Use monit, it's more secure than writing a shell script for that.
If you are really want to write a script, use curl to get the content, grep it and restart the service in case of fail.
Thanks "coredump" . You gave me the hint I needed to solve the issue. I'll use a combination of CURL and also the answer on this page .
Here is what I came up with, which seems to work for me. If you can improve this answer, I might award the points to you.