Ubuntu 12.04 LTS and Nagios

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
dominicw
Posts: 8
Joined: Tue Aug 06, 2013 3:14 pm

Ubuntu 12.04 LTS and Nagios

Post by dominicw »

Hi Guys, this is my first post on the forum, I hope I make this post in the correct section.

I have installed Nagios on my Ubuntu server.
Nagios is running, Apache also is running.

When I want to monitor a website of mine Nagios says:

Host State Information
Host Status: DOWN
(for 0d 0h 30m 44s)
Status Information: PING CRITICAL - Packet loss = 100%
Performance Data: rta=5000.000000ms;5000.000000;5000.000000;0.000000 pl=100%;100;100;0
Current Attempt: 1/10 (HARD state)
Last Check Time: 2013-08-06 19:45:21
Check Type: ACTIVE
Check Latency / Duration: 0.000 / 10.018 seconds
Next Scheduled Active Check: 2013-08-06 19:50:31
Last State Change: 2013-08-06 19:19:31
Last Notification: 2013-08-06 19:19:31 (notification 1)
Is This Host Flapping? NO
(4.01% state change)
In Scheduled Downtime? NO
Last Update: 2013-08-06 19:50:11 ( 0d 0h 0m 4s ago)
Active Checks: ENABLED
Passive Checks: ENABLED
Obsessing: ENABLED
Notifications: ENABLED
Event Handler: ENABLED
Flap Detection: ENABLE

The site is up and running, it does the same for other sites, including Google.com

When I enter the check_http command, Ubuntu states that the command is not found.

LS from plugins folder:
root@h2200554:/etc/nagios3/conf.d# ls
contacts_nagios2.cfg generic-service_nagios2.cfg services_nagios2.cfg
extinfo_nagios2.cfg hostgroups_nagios2.cfg test-google.cfg
generic-host_nagios2.cfg localhost_nagios2.cfg timeperiods_nagios2.cfg

Cat from test-google.cfg
root@h2200554:/etc/nagios3/conf.d# cat test-google.cfg
define host{
use generic-host
host_name google
alias google
address google.com
}

define service{
use generic-service
host_name google
service_description HTTP
check_command check_http
}

What is the cause of this problem and how can I fix this?

Your help is higly appreciated.

Edit:

Figured out how I can run a plugin from the CLI.

root@h2200554:~# cd /usr/lib/nagios/plugins
root@h2200554:/usr/lib/nagios/plugins# ./check_http -I http://www.google.com
HTTP OK: HTTP/1.0 302 Found - 1002 bytes in 0,062 second response time |time=0,062269s;;;0,000000 size=1002B;;;0
root@h2200554:/usr/lib/nagios/plugins#

So if this is working, why is it not working in Nagios?
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Ubuntu 12.04 LTS and Nagios

Post by lmiltchev »

What are the permissions on check_http?

Code: Select all

ls -la /usr/lib/nagios/plugins/check_http
Can you run the check as nagios user?

Code: Select all

su - nagios -c "/usr/lib/nagios/plugins/check_http -I google.com"
What is the output of the following command?

Code: Select all

grep nag /etc/group
Be sure to check out our Knowledgebase for helpful articles and solutions!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Ubuntu 12.04 LTS and Nagios

Post by abrist »

There could be more than one issue, but I noticed rather quickly that your listing of the config directory was missing a commands.cfg file. This file should have all of the "vanilla" command definitions, including check_http. Maybe it is located somewhere else?

Code: Select all

find / -name commands.cfg
EDIT: This file name may be different in your environment. You may also want to grep the config directory for check_http to see if you have a definition in another file:

Code: Select all

grep -5 check_http /etc/nagios3/conf.d/*
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
dominicw
Posts: 8
Joined: Tue Aug 06, 2013 3:14 pm

Re: Ubuntu 12.04 LTS and Nagios

Post by dominicw »

I am kinda new to Linux Ubuntu, so the output below doesn''t say everything to me.
Is the output below something you can identify the problem with?

Strange enough no output here.
root@h2200554:~# su - nagios -c "/usr/lib/nagios/plugins/check_http -I google.com"
root@h2200554:~#

root@h2200554:~# grep nag /etc/group
nagios:x:127:www-data

root@h2200554:~# ls -la /usr/lib/nagios/plugins/check_http
-rwxr-xr-x 1 root root 146656 jul 5 11:13 /usr/lib/nagios/plugins/check_http
root@h2200554:~#

root@h2200554:~# find / -name commands.cfg
/usr/share/doc/nagios3-common/examples/commands.cfg
/usr/share/doc/nagios3-common/examples/template-object/commands.cfg
/etc/nagios3/commands.cfg
root@h2200554:~#

Thanks for your help.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Ubuntu 12.04 LTS and Nagios

Post by lmiltchev »

You forgot to run the last command as requested by abrist:

Code: Select all

grep -5 check_http /etc/nagios3/conf.d/*
In addition to this, run the following command and show the output:

Code: Select all

grep commands.cfg /etc/nagios3/nagios.cfg
Show us the check_http command definition that you have in "/etc/nagios3/commands.cfg".

The "nagios" user is not part the the "nagios" group - only apache is, so run the following command to add it:

Code: Select all

useradd -G nagios nagios
Be sure to check out our Knowledgebase for helpful articles and solutions!
dominicw
Posts: 8
Joined: Tue Aug 06, 2013 3:14 pm

Re: Ubuntu 12.04 LTS and Nagios

Post by dominicw »

Whoops sorry:

root@h2200554:~# grep -5 check_http /etc/nagios3/conf.d/*
/etc/nagios3/conf.d/services_nagios2.cfg-# check that web services are running
/etc/nagios3/conf.d/services_nagios2.cfg-define service {
/etc/nagios3/conf.d/services_nagios2.cfg- hostgroup_name http-servers
/etc/nagios3/conf.d/services_nagios2.cfg- service_description HTTP
/etc/nagios3/conf.d/services_nagios2.cfg: check_command check_http
/etc/nagios3/conf.d/services_nagios2.cfg- use generic-service
/etc/nagios3/conf.d/services_nagios2.cfg- notification_interval 0 ; set > 0 if you want to be renotified
/etc/nagios3/conf.d/services_nagios2.cfg-}
/etc/nagios3/conf.d/services_nagios2.cfg-
/etc/nagios3/conf.d/services_nagios2.cfg-# check that ssh services are running
--
/etc/nagios3/conf.d/test.cfg-
/etc/nagios3/conf.d/test.cfg-define service{
/etc/nagios3/conf.d/test.cfg-use generic-service
/etc/nagios3/conf.d/test.cfg-host_name google
/etc/nagios3/conf.d/test.cfg-service_description HTTP
/etc/nagios3/conf.d/test.cfg:check_command check_http
/etc/nagios3/conf.d/test.cfg-}
root@h2200554:~#


root@h2200554:~# grep commands.cfg /etc/nagios3/nagios.cfg
cfg_file=/etc/nagios3/commands.cfg
#cfg_file=/etc/nagios3/objects/commands.cfg
root@h2200554:~#

When trying to enter the last command I got this output:
root@h2200554:~# useradd -G nagios nagios
useradd: user 'nagios' already exists

And at last, I checked the config but didnt see anything regarding HTTP, maybe this is the issue?


root@h2200554:/etc/nagios3# cat commands.cfg
###############################################################################
# COMMANDS.CFG - SAMPLE COMMAND DEFINITIONS FOR NAGIOS
###############################################################################

################################################################################
# NOTIFICATION COMMANDS
################################################################################

# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHos t: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nS ervice: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDAT ETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOS TALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}

################################################################################
# HOST CHECK COMMANDS
################################################################################

# On Debian, check-host-alive is being defined from within the
# nagios-plugins-basic package

################################################################################
# PERFORMANCE DATA COMMANDS
################################################################################


# 'process-host-perfdata' command definition
define command{
command_name process-host-perfdata
command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTST ATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /var/lib/nagios3/host-perfdata.out
}

# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$ SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDA TA$\n" >> /var/lib/nagios3/service-perfdata.out
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Ubuntu 12.04 LTS and Nagios

Post by abrist »

Looks like you are most definitely missing a command definition for check_http. It may be different depending on your environment, but the following is the default definition:

Code: Select all

define command {
       command_name                             check_http
       command_line                             $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
}
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
dominicw
Posts: 8
Joined: Tue Aug 06, 2013 3:14 pm

Re: Ubuntu 12.04 LTS and Nagios

Post by dominicw »

I have added this to my /etc/nagios-plugins/config/http.cfg file.
define command {
command_name check_http
command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
}

But when I restart Nagios Core I receive the message:

Processing object config file '/etc/nagios-plugins/config/http.cfg'...
Warning: Duplicate definition found for command 'check_http' (config file '/etc/nagios-plugins/config/http.cfg', starting on line 2)
Error: Could not add object property in file '/etc/nagios-plugins/config/http.cfg' on line 3.
Error processing object config files!
* errors in config!

What in the world could be causing this? Did I place the text in the wrong file?
dominicw
Posts: 8
Joined: Tue Aug 06, 2013 3:14 pm

Re: Ubuntu 12.04 LTS and Nagios

Post by dominicw »

Edit: my mistake, I placed the text in /etc/nagios3/commands.cfg instead of stated above.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Ubuntu 12.04 LTS and Nagios

Post by abrist »

Nope, it looks like that command is defined in the nagios plugins config. Interesting though, as you, earlier in this thread, were receiving an error relating to check_http missing. Did you install the nagios-plugins pack after attempting to set up the check?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked