0

We have several server racks that are monitored by nagios. Now we want to monitor temperature inside the racks by a Nagios installation outside the racks. The temperature inside the server racks ist measured by servers running in the rack which deliver temperature over http. A request http://serverinrack12/temp delivers one of the four "Nagios compatible" command messages:

OK - temp 25 °C
WARNING - temp 45 °C
CRITICAL - temp 65 °C
UNKNOWN - cannot read temp

The HTTP response code is always HTTP/1.1 200 OK.

How can this http response be parsed by Nagios if nothing can be changed on the server?

Is there a Nagios command to read service states by http? How can this Nagios command be integrated in a command definition, e.g. as

define command {
    command_name    check_http_temp
    command_line    .... -H $HOSTADDRESS$
}

Ideally there is a command to call this temp-checks by adding an id to support several thermometers attached to this server:

http://serverinrack12/temp?id=1

Last question: How can we get temperature performance data with Nagios over http?

3

You need to either write a plugin, or find one that will parse the content of a webpage. Nagios doesn't care at all what the string returned is (as that is for human consumption). Nagios only cares about the exit code (AKA return value).

You can do this without installing anything on the servers. You could, for example, write a bash script that fetches the /temp content via curl and then does some string matching. Sub "bash" for your scripting language of choice.

The stock check_http plugin can look for a certain string, but it cannot return different status values for different strings, as far as I can see.

If you don't want to write something, dig around Nagios Exchange and/or Monitoring Exchange.

1

It looks like the check you are performing is just to see if the http service is active. This does not try to parse the content.
Take a look at check_http_content plugin from here

  • No, not at all! My goal is to monitor temperature in server racks. There is a Nagios installation available outside the server racks and the temperature values are measured by servers inside the racks. The title of the question is "How to check temperature..."... – WeSee Sep 9 '15 at 20:35
  • Not at all? What happens when you put the url in a browser? It says one of the messages right? The check you are using does not care about the content of the page just that the service is up and responding. Which in the case of service monitoring is what you want. But in this case you actually have to parse the output of the page to determine the which is why I suggested that plugin. – Eddie Dunn Sep 9 '15 at 20:40
  • I don't want to parse the content to see if temp is OKor CRITICAL but I want the content itself be the result to Nagios. E.g. the plugin just differentiates between OK and CRITICAL, there is no WARNING or UNKNOWN state. – WeSee Sep 9 '15 at 20:50
  • I am just telling you what it looks like you are doing and trying to offer suggestions. I have done exactly this in that past (for this purpose) and have always just made nrpe plugins and sent the data that way. It does not sound like this is an option in your case. – Eddie Dunn Sep 9 '15 at 21:01
  • 1
    I don't want to parse the content ... You may not want that, but it is almost certainly what you, or some script you find/use, will have to do. You will probably have to write a check script that makes the request and parses the content, and emits the proper exit code. Nagios uses exit code of the check commands to determine the status. The string is just saved for the benefit of the end user. – Zoredache Sep 9 '15 at 21:20
0

Try this perl script with -C and -W options: check_http_enhanced

  • While this may work, we generally don't encourage advising people to run an unknown script without any explanation of what it's doing and how. Also, if that page should be moved or deleted, your answer will be useless. – Jenny D Aug 7 '17 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.