Book now with code EOY2025
undomiel wrote: » check_http -S -H $HOSTNAME$
Forsaken_GA wrote: » Generally, speaking, yes, you just do an active check instead of a passive one. And it also depends on your requirements. I personally don't like checking for just the port being open, I prefer to check for a unique string that should always be served up on the page, and if that doesn't come through, time to pop the critical.
ChooseLife wrote: » The nice thing about Nagios is the ability to build dependencies. For web servers, I often chain a few checks of increasing complexity, e.g. ping the server -> check the port is open -> check the / or /health is served with the right content -> check the web application works properly (user authentication, advanced app functions, etc). That way when a warning state is raised, the failed check readily provides indication of where in the application stack the problem is happening.
RobertKaucher wrote: » So what I am looking for is an example of how to make sure it is serving the content that is expected and I cannot seem to find an example of how to do that properly. Sorry I was not very specific. The issue is my search terms seem far too generic... Everyone, don't make me come over there!
RobertKaucher wrote: » Ok, but what is meant by a unique string? Could I use the entire text of the index page? It's only about 14 lines. Or do I have to use a smaller amount of text. If I can use the entire HTML content, how do I escape quotes? I would really like to see an example of this. The documentation for that command switch is non-existent and just try searching for -s.
#!/usr/bin/env bash if [ "`curl $1 2>/dev/null | md5sum | awk '{print $1}'`" = "$2" ]; then exit 0; else exit 2; fi
ChooseLife wrote: » E.g. this will do:#!/usr/bin/env bash if [ "`curl $1 2>/dev/null | md5sum | awk '{print $1}'`" = "$2" ]; then exit 0; else exit 2; fi You then run it as ./script_name https://www.example.com 91ced8078ac428e28b8b93ae066320a2
RobertKaucher wrote: » The documentation for that command switch is non-existent and just try searching for -s.
rhaegar:/usr/lib/nagios/plugins# ./check_http -H www.google.com HTTP OK: HTTP/1.1 200 OK - 13009 bytes in 0.059 second response time |time=0.059006s;;;0.000000 size=13009B;;;0 rhaegar:/usr/lib/nagios/plugins# ./check_http -H www.google.com -s "About Google" HTTP OK: HTTP/1.1 200 OK - 13009 bytes in 0.058 second response time |time=0.057803s;;;0.000000 size=13009B;;;0 rhaegar:/usr/lib/nagios/plugins# ./check_http -H www.google.com -s "Forsaken is a putz" HTTP CRITICAL: HTTP/1.1 200 OK - string 'Forsaken is a putz' not found on 'http://www.google.com:80/' - 13045 bytes in 0.062 second response time |time=0.062015s;;;0.000000 size=13045B;;;0
Forsaken_GA wrote: » Great example of the versatility, however, this is only useful for static content which rarely, if ever, changes, as any change to the page changes the md5sum, necessitating a change to what you call your script with. It's also entirely useless as a solution on a page with any dynamic content. (I'm not panning your idea, just pointing out that different problems require different solutions)
If the content is dynamically generated and needs to be verified in its entirety (OP's requirement), that will certainly require custom scripting to generate the page against which returned content should be verified. Even in that case, I recommend comparing hashes of two pages rather than the pages as blocks of text.
Use code EOY2025 to receive $250 off your 2025 certification boot camp!