6

I am using Nagios XI. I entered following command in order to monitor httpd service of the remote Linux server (128.19.5.131):

/usr/local/nagios/libexec/check_http -H 128.19.5.131

It is giving me following output:

HTTP WARNING: HTTP/1.1 403 Forbidden

nobody
  • 19,814
  • 17
  • 56
  • 77
Mandar Shinde
  • 1,735
  • 4
  • 20
  • 28

8 Answers8

10

I solved it by executing

$ touch /var/www/html/index.html
$ chmod 755 /var/www/html/index.html

on the remote server.

J0e3gan
  • 8,740
  • 10
  • 53
  • 80
user3471980
  • 101
  • 1
  • 2
9

You can put a username/password and tell nagios what to expect via -e. It is not a must to authorize in any case and it is also not critical to have a WARNING.

 /usr/local/nagios/libexec/check_http -H 128.19.5.131 -e 'HTTP' --authorization=username:password

Update:

The reason why you get forbidden is because you don't have any index file and directory listing is disabled. You can create a file nagios.txt (without putting anything in) and let nagios fetch that file instead of a directory which it is not allowed to view.

Daniel W.
  • 31,164
  • 13
  • 93
  • 151
  • `HTTP OK HTTP/1.1 403 Forbidden - 3962 bytes in 0.002 seconds |time=0.001552s;;;0.000000 size=3962B;;;0` Seeming to be a positive result, but `HTTP/1.1 403 Forbidden` part still persists. – Mandar Shinde May 15 '14 at 09:11
  • Maybe you have a virtual host configured and it depends on a hostname, rather than on IP ? What happens when you go via browser to the IP 128.19.5.131 (from the same network as the nagios ofc). – Daniel W. May 15 '14 at 09:14
  • Nagios server (172.xx.xx.xx) is part of a different network than the target host. – Mandar Shinde May 15 '14 at 09:21
2

I created a file with name index.html in the /var/www/html directory of the remote Linux machine (128.19.5.131). Restarted the HTTP service with service httpd restart and then executed the same command, i.e. :

nagiossrv root [libexec] >/usr/local/nagios/libexec/check_http -H 128.19.5.131

I got following output:

HTTP OK HTTP/1.1 200 OK - 250 bytes in 0.001 seconds |time=0.000977s;;;0.000000 size=250B;;;0

I do not know whether it is proper to add index.html file in the /var/www/html directory of each host to be monitored or not, but it is showing desired results in the Nagios XI console.

Mandar Shinde
  • 1,735
  • 4
  • 20
  • 28
  • What exactly do you mean by "monitoring" in this scenario? It sounds like you installed a complete HTTP server with no purpose but to serve an index.html file to Nagios? Is there any reason you couldn't have done a simple ping check instead? – pzkpfw Dec 06 '20 at 18:11
2

Explanation is in:

vim /etc/httpd/conf.d/welcome.conf
# 
# This configuration file enables the default "Welcome"
# page if there is no default index page present for
# the root URL.  To disable the Welcome page, comment
# out all the lines below.
#
<LocationMatch "^/+$">
#Options -Indexes                        #<----- comment out this line
#ErrorDocument 403 /error/noindex.html   #<----- comment out this line
</LocationMatch>
$ service httpd restart
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
BigED
  • 21
  • 1
0

You can add a line like this:

# 'check_http_80' command definition
define command{
        command_name    check_http_80
        command_line    /usr/lib/nagios/plugins/check_http -H '$HOSTADDRESS$':80 -I '$HOSTADDRESS$'
        }

to your /etc/nagios-plugins/config/http.cfg and change check_http for check_http_80 in your server configuration file.

Then restart you nagios server.

0

i did this and it works perfectly !! follow these commands:

touch /var/www/html/index.html
chmod 755 /var/www/html/index.html
systemctl nagios restart
systemctl httpd restart

Thanks !

-1

On CentOS 8 2004 NREP client, Monitored by Nagios Ubuntu 20.04 Server. Use commands touch /var/www/html/index.html chmod 755 /var/www/html/index.html The Centos 8 /var/www/html/ directory should be populated with index.html. After that from Ubuntu Nagios Server run command /usr/lib/nagios/plugins/check_nrpe -H 10.0.0.20 -c check_http the results HTTP OK:

Off Grid
  • 21
  • 1
  • 6
-1

touch /var/www/html/index.html

This just worked in my case.