In this recipe, we'll build on the basic web service monitoring established in the recipe Monitoring web services in this chapter and learn how to create a command that uses the check_http
plugin to ensure that a particular string is included as part of an HTTP response.
By default, there's no Nagios Core command defined to use the plugin in this way, so the recipe will include defining a command before using it as part of a service check.
This may be necessary if we're monitoring a website on a server that may not necessarily return a 404 Not Found
or similar error that will flag a WARNING
or CRITICAL
in Nagios; rather than merely checking if a document was found, we can check whether it matches a string to see if it resembles the particular document we expected.
This kind of setup is a nice complement to a suite of code unit tests for a website or web application.