Command File


#1

Hi everyone, first post.

I love nagios and have convinced work to allow me to seutp it as our main monitoring system, brilliant! :smiley: But I have run into a bump during my installation.

When I try to schedule a system check I get:

"Error: Could not stat() command file ‘/usr/local/nagios/var/rw/nagios.cmd’!

The external command file may be missing, Nagios may not be running, and/or Nagios may not be checking external commands.

An error occurred while attempting to commit your command for processing."

I have installed Nagios on Red Hat Enterprise Linux AS release 4 (Nahant) by following a few guides.

What I have done so far is:

Created the user nagios
Created the group nagcmd
Added apache to nagcmd

Configured nagios with:
./configure --prefix=/usr/local/nagios --sbindir=/var/www/cgi-bin --datadir=/var/www/html --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd --with-htmurl= --with-cgiurl=/cgi-bin

make all && make fullinstall

Nagios Plugins with:
./configure --with-cgiurl=/cgi-bin
make && make install

The following are my configs:

Nagios.cfg:
[blockquote]
log_file=/usr/local/nagios/var/nagios.log
cfg_file=/usr/local/nagios/etc/commands.cfg
cfg_file=/usr/local/nagios/etc/contactgroups.cfg
cfg_file=/usr/local/nagios/etc/contacts.cfg
cfg_file=/usr/local/nagios/etc/hostgroups.cfg
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/www.ittdublin.ie.cfg
cfg_file=/usr/local/nagios/etc/mail.itnet.ie.cfg
cfg_file=/usr/local/nagios/etc/netsoc.cfg
object_cache_file=/usr/local/nagios/var/objects.cache
resource_file=/usr/local/nagios/etc/resource.cfg
status_file=/usr/local/nagios/var/status.dat
nagios_user=nagios
nagios_group=nagios
check_external_commands=1
command_check_interval=-1
command_file=/usr/local/nagios/var/rw/nagios.cmd
external_command_buffer_slots=4096
comment_file=/usr/local/nagios/var/comments.dat
downtime_file=/usr/local/nagios/var/downtime.dat
lock_file=/usr/local/nagios/var/nagios.lock
temp_file=/usr/local/nagios/var/nagios.tmp
event_broker_options=-1
log_rotation_method=d
log_archive_path=/usr/local/nagios/var/archives
use_syslog=1
log_notifications=1
log_service_retries=1
log_host_retries=1
log_event_handlers=1
log_initial_states=0
log_external_commands=1
log_passive_checks=1
service_inter_check_delay_method=s
max_service_check_spread=30
service_interleave_factor=s
host_inter_check_delay_method=s
max_host_check_spread=30
max_concurrent_checks=0
service_reaper_frequency=10
check_result_buffer_slots=4096
auto_reschedule_checks=0
auto_rescheduling_interval=30
auto_rescheduling_window=180
sleep_time=0.25
service_check_timeout=60
host_check_timeout=30
event_handler_timeout=30
notification_timeout=30
ocsp_timeout=5
perfdata_timeout=5
retain_state_information=1
state_retention_file=/usr/local/nagios/var/retention.dat
retention_update_interval=60
use_retained_program_state=1
use_retained_scheduling_info=0
interval_length=60
use_aggressive_host_checking=0
execute_service_checks=1
accept_passive_service_checks=1
execute_host_checks=1
accept_passive_host_checks=1
enable_notifications=1
enable_event_handlers=1
process_performance_data=0
obsess_over_services=0
check_for_orphaned_services=1
check_service_freshness=1
service_freshness_check_interval=60
check_host_freshness=0
host_freshness_check_interval=60
aggregate_status_updates=1
status_update_interval=15
enable_flap_detection=0
low_service_flap_threshold=5.0
high_service_flap_threshold=20.0
low_host_flap_threshold=5.0
high_host_flap_threshold=20.0
date_format=us
p1_file=/usr/local/nagios/bin/p1.pl
illegal_object_name_chars=~!$%^&*|'"<>?,()= illegal_macro_output_chars=~$&|’"<>
use_regexp_matching=0
use_true_regexp_matching=0
admin_email=cquigley@ittdublin.ie
admin_pager=pagenagios
daemon_dumps_core=0
[/blockquote]

cgi.cfg:

[blockquote]main_config_file=/usr/local/nagios/etc/nagios.cfg
physical_html_path=/var/www/html
url_html_path=
show_context_help=0
use_authentication=1
authorized_for_system_information=monitor
authorized_for_configuration_information=monitor
authorized_for_system_commands=monitor
authorized_for_all_services=monitor
authorized_for_all_hosts=monitor
authorized_for_all_service_commands=monitor
authorized_for_all_host_commands=monitor
default_statusmap_layout=5
default_statuswrl_layout=4
ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$
refresh_rate=90[/blockquote]

Permissions:
Nagios:
[blockquote][root@Nagios etc]# ls -lR /usr/local/nagios/
/usr/local/nagios/:
total 40
drwxrwxr-x 2 nagios nagios 4096 Feb 20 10:23 bin
drwxrwxr-x 2 nagios nagios 4096 Feb 20 11:50 etc
drwxr-xr-x 2 nagios nagios 4096 Feb 20 10:59 libexec
drwxr-xr-x 3 nagios nagios 4096 Feb 20 10:59 share
drwxrwxr-x 4 nagios nagios 4096 Feb 20 11:51 var

/usr/local/nagios/bin:
total 412
-rwxrwxr-- 1 nagios nagios 378788 Feb 20 10:23 nagios
-rwxrwxr-- 1 nagios nagios 25040 Feb 20 10:23 nagiostats

/usr/local/nagios/etc:
total 228
-rw-r–r-- 1 nagios nagios 9500 Feb 20 11:20 cgi.cfg
-rw-rw-r-- 1 nagios nagios 9565 Feb 20 10:23 cgi.cfg-sample
-rw-rw-r-- 1 nagios nagios 8579 Feb 20 10:23 commands.cfg
-rw-r–r-- 1 nagios nagios 141 Feb 20 11:03 contactgroups.cfg
-rw-r–r-- 1 nagios nagios 872 Feb 20 11:03 contacts.cfg
-rw-r–r-- 1 nagios nagios 253 Feb 20 11:05 hostgroups.cfg
-rw-r–r-- 1 nagios nagios 362 Feb 20 11:04 hosts.cfg
-rw-r–r-- 1 nagios nagios 22 Feb 20 10:27 htpasswd.users
-rw-rw-r-- 1 nagios nagios 12469 Feb 20 10:23 localhost.cfg
-rw-r–r-- 1 nagios nagios 484 Feb 20 11:04 mail.itnet.ie.cfg
-rw-r–r-- 1 nagios nagios 31309 Feb 20 11:49 nagios.cfg
-rw-rw-r-- 1 nagios nagios 31134 Feb 20 10:23 nagios.cfg-sample
-rw-r–r-- 1 nagios nagios 479 Feb 20 11:04 netsoc.cfg
-rw-rw---- 1 nagios nagios 1338 Feb 20 10:23 resource.cfg
-rw-r–r-- 1 nagios nagios 2194 Feb 20 11:07 services.cfg
-rw-r–r-- 1 nagios nagios 314 Feb 20 11:04 timeperiods.cfg
-rw-r–r-- 1 nagios nagios 487 Feb 20 11:04 www.ittdublin.ie.cfg

/usr/local/nagios/libexec:
total 2468
-rwxr-xr-x 1 nagios nagios 47474 Feb 20 10:59 check_apt
-rwxr-xr-x 1 nagios nagios 2274 Feb 20 10:59 check_breeze
-rwxr-xr-x 1 nagios nagios 55988 Feb 20 10:59 check_by_ssh
lrwxrwxrwx 1 root root 9 Feb 20 10:59 check_clamd -> check_tcp
-r-xr-x— 1 nagios nagios 55685 Feb 20 10:59 check_dhcp
-rwxr-xr-x 1 nagios nagios 52424 Feb 20 10:59 check_dig
-rwxr-xr-x 1 nagios nagios 70762 Feb 20 10:59 check_disk
-rwxr-xr-x 1 nagios nagios 8168 Feb 20 10:59 check_disk_smb
-rwxr-xr-x 1 nagios nagios 57559 Feb 20 10:59 check_dns
-rwxr-xr-x 1 nagios nagios 30230 Feb 20 10:59 check_dummy
-rwxr-xr-x 1 nagios nagios 3233 Feb 20 10:59 check_file_age
-rwxr-xr-x 1 nagios nagios 6400 Feb 20 10:59 check_flexlm
-rwxr-xr-x 1 nagios nagios 55376 Feb 20 10:59 check_fping
lrwxrwxrwx 1 root root 9 Feb 20 10:59 check_ftp -> check_tcp
-rwxr-xr-x 1 nagios nagios 53254 Feb 20 10:59 check_hpjd
-rwxr-xr-x 1 nagios nagios 111598 Feb 20 10:59 check_http
-r-xr-x— 1 nagios nagios 62858 Feb 20 10:59 check_icmp
-rwxr-xr-x 1 nagios nagios 15292 Feb 20 10:59 check_ifoperstatus
-rwxr-xr-x 1 nagios nagios 12858 Feb 20 10:59 check_ifstatus
lrwxrwxrwx 1 root root 9 Feb 20 10:59 check_imap -> check_tcp
-rwxr-xr-x 1 nagios nagios 7437 Feb 20 10:59 check_ircd
lrwxrwxrwx 1 root root 9 Feb 20 10:59 check_jabber -> check_tcp
-rwxr-xr-x 1 nagios nagios 46860 Feb 20 10:59 check_ldap
lrwxrwxrwx 1 root root 10 Feb 20 10:59 check_ldaps -> check_ldap
-rwxr-xr-x 1 nagios nagios 41915 Feb 20 10:59 check_load
-rwxr-xr-x 1 nagios nagios 6059 Feb 20 10:59 check_log
-rwxr-xr-x 1 nagios nagios 20369 Feb 20 10:59 check_mailq
-rwxr-xr-x 1 nagios nagios 39465 Feb 20 10:59 check_mrtg
-rwxr-xr-x 1 nagios nagios 37737 Feb 20 10:59 check_mrtgtraf
-rwxr-xr-x 1 nagios nagios 57150 Feb 20 10:59 check_mysql
-rwxr-xr-x 1 nagios nagios 53954 Feb 20 10:59 check_mysql_query
-rwxr-xr-x 1 nagios nagios 44288 Feb 20 10:59 check_nagios
lrwxrwxrwx 1 root root 9 Feb 20 10:59 check_nntp -> check_tcp
lrwxrwxrwx 1 root root 9 Feb 20 10:59 check_nntps -> check_tcp
-rwxr-xr-x 1 nagios nagios 55882 Feb 20 10:59 check_nt
-rwxr-xr-x 1 nagios nagios 56509 Feb 20 10:59 check_ntp
-rwxr-xr-x 1 nagios nagios 75532 Feb 20 10:59 check_nwstat
-rwxr-xr-x 1 nagios nagios 8325 Feb 20 10:59 check_oracle
-rwxr-xr-x 1 nagios nagios 48722 Feb 20 10:59 check_overcr
-rwxr-xr-x 1 nagios nagios 61728 Feb 20 10:59 check_ping
lrwxrwxrwx 1 root root 9 Feb 20 10:59 check_pop -> check_tcp
-rwxr-xr-x 1 nagios nagios 60760 Feb 20 10:59 check_procs
-rwxr-xr-x 1 nagios nagios 46219 Feb 20 10:59 check_radius
-rwxr-xr-x 1 nagios nagios 46796 Feb 20 10:59 check_real
-rwxr-xr-x 1 nagios nagios 9712 Feb 20 10:59 check_rpc
-rwxr-xr-x 1 nagios nagios 1176 Feb 20 10:59 check_sensors
lrwxrwxrwx 1 root root 9 Feb 20 10:59 check_simap -> check_tcp
-rwxr-xr-x 1 nagios nagios 84258 Feb 20 10:59 check_smtp
-rwxr-xr-x 1 nagios nagios 66712 Feb 20 10:59 check_snmp
lrwxrwxrwx 1 root root 9 Feb 20 10:59 check_spop -> check_tcp
-rwxr-xr-x 1 nagios nagios 43280 Feb 20 10:59 check_ssh
lrwxrwxrwx 1 root root 9 Feb 20 10:59 check_ssmtp -> check_tcp
-rwxr-xr-x 1 nagios nagios 46552 Feb 20 10:59 check_swap
-rwxr-xr-x 1 nagios nagios 81594 Feb 20 10:59 check_tcp
-rwxr-xr-x 1 nagios nagios 45839 Feb 20 10:59 check_time
lrwxrwxrwx 1 root root 9 Feb 20 10:59 check_udp -> check_tcp
-rwxr-xr-x 1 nagios nagios 53856 Feb 20 10:59 check_ups
-rwxr-xr-x 1 nagios nagios 41237 Feb 20 10:59 check_users
-rwxr-xr-x 1 nagios nagios 3024 Feb 20 10:59 check_wave
-rwxr-xr-x 1 nagios nagios 41625 Feb 20 10:59 negate
-rwxr-xr-x 1 nagios nagios 40804 Feb 20 10:59 urlize
-rwxr-xr-x 1 nagios nagios 2069 Feb 20 10:59 utils.pm
-rwxr-xr-x 1 nagios nagios 860 Feb 20 10:59 utils.sh

/usr/local/nagios/share:
total 8
drwxr-xr-x 4 nagios nagios 4096 Feb 20 10:59 locale

/usr/local/nagios/share/locale:
total 16
drwxr-xr-x 3 nagios nagios 4096 Feb 20 10:59 de
drwxr-xr-x 3 nagios nagios 4096 Feb 20 10:59 fr

/usr/local/nagios/share/locale/de:
total 8
drwxr-xr-x 2 nagios nagios 4096 Feb 20 10:59 LC_MESSAGES

/usr/local/nagios/share/locale/de/LC_MESSAGES:
total 16
-rw-r–r-- 1 nagios nagios 9519 Feb 20 10:59 nagios-plugins.mo

/usr/local/nagios/share/locale/fr:
total 8
drwxr-xr-x 2 nagios nagios 4096 Feb 20 10:59 LC_MESSAGES

/usr/local/nagios/share/locale/fr/LC_MESSAGES:
total 80
-rw-r–r-- 1 nagios nagios 73399 Feb 20 10:59 nagios-plugins.mo

/usr/local/nagios/var:
total 100
drwxrwxr-x 2 nagios nagios 4096 Feb 20 10:23 archives
-rw-rw-r-- 1 nagios nagios 238 Feb 20 10:30 comments.dat
-rw-rw-r-- 1 nagios nagios 239 Feb 20 10:30 downtime.dat
-rw-r–r-- 1 nagios nagios 5 Feb 20 11:49 nagios.lock
-rw-rw-r-- 1 nagios nagios 15163 Feb 20 11:49 nagios.log
-rw-r–r-- 1 nagios nagios 9132 Feb 20 11:49 objects.cache
-rw------- 1 nagios nagios 7126 Feb 20 11:49 retention.dat
drwxrwsr-x 2 nagios nagcmd 4096 Feb 20 11:49 rw
-rw-rw-r-- 1 nagios nagios 6965 Feb 20 11:51 status.dat

/usr/local/nagios/var/archives:
total 0

/usr/local/nagios/var/rw:
total 4
prw-rw---- 1 nagios nagcmd 0 Feb 20 11:49 nagios.cmd
[/blockquote]

Webroot:
[blockquote][root@Nagios etc]# ls -lR /var/www/
/var/www/:
total 48
drwxrwxr-x 2 nagios nagios 4096 Feb 20 11:16 cgi-bin
drwxr-xr-x 3 root root 4096 Feb 19 12:28 error
drwxrwxr-x 8 nagios nagios 4096 Feb 20 10:27 html
drwxr-xr-x 3 root root 4096 Feb 19 12:28 icons
drwxr-xr-x 13 root root 4096 Feb 19 12:28 manual
drwxr-xr-x 2 webalizer root 4096 Feb 19 15:14 usage

/var/www/cgi-bin:
total 1804
-rwxrwxr-x 1 nagios nagios 156948 Feb 20 10:23 avail.cgi
-rwxrwxr-x 1 nagios nagios 165816 Feb 20 10:23 cmd.cgi
-rwxrwxr-x 1 nagios nagios 122196 Feb 20 10:23 config.cgi
-rwxrwxr-x 1 nagios nagios 182360 Feb 20 10:23 extinfo.cgi
-rwxrwxr-x 1 nagios nagios 111508 Feb 20 10:23 history.cgi
-rwxrwxr-x 1 nagios nagios 107764 Feb 20 10:23 notifications.cgi
-rwxrwxr-x 1 nagios nagios 108984 Feb 20 10:23 outages.cgi
-rwxrwxr-x 1 nagios nagios 107668 Feb 20 10:23 showlog.cgi
-rwxrwxr-x 1 nagios nagios 161272 Feb 20 10:23 status.cgi
-rwxrwxr-x 1 nagios nagios 121300 Feb 20 10:23 statuswml.cgi
-rwxrwxr-x 1 nagios nagios 107796 Feb 20 10:23 statuswrl.cgi
-rwxrwxr-x 1 nagios nagios 127892 Feb 20 10:23 summary.cgi
-rwxrwxr-x 1 nagios nagios 128536 Feb 20 10:23 tac.cgi
/var/www/html:
total 92
drwxrwxr-x 2 nagios nagios 4096 Feb 20 10:23 contexthelp
drwxrwxr-x 3 nagios nagios 4096 Feb 20 10:23 docs
drwxrwxr-x 3 nagios nagios 4096 Feb 20 10:23 images
-rw-rw-r-- 1 nagios nagios 658 Feb 20 10:23 index.html
-rw-rw-r-- 1 nagios nagios 2410 Feb 20 10:23 main.html
drwxrwxr-x 2 nagios nagios 4096 Feb 20 10:23 media
-rw-rw-r-- 1 nagios nagios 26 Feb 20 10:23 robots.txt
-rw-rw-r-- 1 nagios nagios 12533 Feb 20 10:23 side.html
drwxrwxr-x 2 nagios nagios 4096 Feb 20 10:23 ssi
drwxrwxr-x 2 nagios nagios 4096 Feb 20 10:23 stylesheets[/blockquote]

I could really use any and ALL input that anyone can give me. I am so close to having this working but its pointless the way it is.

Thanks very much,.


#2

./configure --prefix=/usr/local/nagios --sbindir=/var/www/cgi-bin --datadir=/var/www/html --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd --with-htmurl= --with-cgiurl=/cgi-bin

Don’t look good to me. Use all the defaults except for one like this:
make clean
./configure --with-command-group=nagcmd


#3

The reason I did this is because with the defaults and having nagios/sbin in a different location other than the default apache cgi-bin I had “Internal Server Error” problems. So I decided to make nagios the main site.


#4

I fixed this problem, for anyone having similar problems I had to disable SELinux under Redhat. Thanks for the help all.