I would like to monitor/test multiple virtual hosts in an Apache Webserver and besides, I would like that these checks appears as a one service in Nagios -> HTTP. And if one of the web/URL fails, the service appears as failed/alarm. I dont know if it's possible.

i've installed Nagios in another server and i want to check if the webs are answering status code 200.

So, the question is, nagios could be configurated to check multiple websites in the same service? Is it maybe possible to set multiple check_command in a service?

check_command   check_httpv!google.com
check_command   check_httpv!gmail.com

How are you monitoring virtual hosts in nagios? are you creating a service per website?

Regards and thank you in advance!


check_http can only check one site at a time. If you need to check multiple sites in a single service check, you would need to write your own check to implement the logic. This could easily be done in a simple shell script that calls check_http for each virtual host and returns the appropriate failure code to Nagios if any of the check_http executions are unsuccessful. Such a script might look like the following.


for HOST in $* ; do
   check_http -H $HOST [...other args...] >/dev/null 
   if [ $? -ne 0 ] ; then
      echo "$HOST not responding"
      exit 2
echo "All hosts ok"
exit 0

Alternatively, you may be able to use Nagios' service dependencies to reach your goal. Assume for the moment that you wish to check all of your Apache virtual hosts but not be flooded with a notification for each one if the Apache process is not available. This would allow you to see the status detail of each virtual host, allow for more fine grained reporting, and let you have different notification and time period options.

To implement this you would create a service check for each virtual host, then create one check for Apache, presumably by using check_http to check via the IP address and make sure something is listening on port 80.

Next you would create service dependencies for each virtual host's service check and configure them to be dependent on the Apache check. If the Apache check fails, all of the virtual host checks (which depend on the Apache check) will stop sending notifications and/or executing checks until the Apache check recovers.


Write a bash script that calls check_http.pl multiple times for every argument passed.

Configure it as your own service type and you're ready to go.

I'm not familiar enough with bash to do this off the top of my head, but some basic bash tutorials will get you basically through all of this easily.


The "correct" way to do this is to use check_multi:


Configure a check_multi to call multiple check_http checks at once (see check_http --help and look at the -H and -I flags). You can give it thresholds for how many need to be warn/crit until the multi-service is warn/crit, etc. It's very powerful and flexible.

You could also use check_cluster (this is an old-fasioned way to do it, and it results in lots of extra services littering the nagios web UI). If you wanted to go this route, you can read the official docs about monitoring clusters:



Yes it's possible, I blogged about it. Duplicating core stuff here.

You need (1) a script that takes a list of URLs, checks them and returns status codes as appropriate, (2) a Nagios command that uses the script, (3) a host definition that uses the command for checking.

Put the script in /etc/nagios3/check_urls.

Define the command in /etc/nagios3/conf.d/commands.cfg:

define command {
    command_name check_urls
    command_line /etc/nagios3/check_urls $_HOSTURLS$

Define the host in /etc/nagios3/conf.d/hosts.cfg:

define host {
    host_name     example-host
    alias         My Example
    check_command check_urls
    _urls         my-blog.com,my-api.com/check
  • Thank for the answer, finally i went with Xymon that fits the customers requirements and in my opinion configuration is easier and simpler than nagios! – Adrian Perez May 20 '13 at 16:55

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.