Ошибка nagios: Could not open CGI config file '/etc/nagios/cgi.cfg' for reading! [SOLVED]

Добрый день!

Не могу понять почему происходит сабж.
Авторизацию для нагиоса отстроил в аппаче, но при попытке обращения к каким либо динамическим страницам, возникает эта ошибка.
При этом нагиос пишет: Make sure you've installed a CGI config file in its proper location. See the error message about for details on where the CGI is expecting to find the configuration file. A sample CGI configuration file (named cgi.cfg) can be found in the sample-config/ subdirectory of the Nagios source code distribution.

Проверял, лежит там и все ок, права на него вот такие:

 ls -la /etc/nagios/cgi.cfg
-rw-rw-r-- 1 nagios nagios 10690 Jul 15 13:49 /etc/nagios/cgi.cfg

/etc/nagios/cgi.cfg

/etc/nagios/cgi.cfg дефолтный?
Если да, то надое его править: дать пользователю, под которым вы авторизируетесь в апаче права на те пункты меню, что вам нужны. Там еще есть /etc/nagios/cgi.cfg-sample - внем все описано.
Почему именно Could not open CGI config file '/etc/nagios/cgi.cfg' for reading! А на /etc/nagios/ какие права?

cgi.cfg действительно

cgi.cfg действительно дефолтный
права на /etc/nagios/

ls -la /etc/nagios
total 64
drwxr-x---  3 nagios nagios   208 Jul 15 13:51 .
drwxr-xr-x 59 root   root    3656 Jul 16 12:01 ..
-rw-r--r--  1 nagios nagios     0 Jul 15 13:49 .keep_net-analyzer_nagios-core-0
-rw-rw-r--  1 nagios nagios 10690 Jul 15 13:49 cgi.cfg
-rw-rw-r--  1 nagios nagios 42478 Jul 15 13:49 nagios.cfg
drwxrwxr-x  2 nagios nagios   304 Jul 15 13:49 objects
-rw-rw----  1 nagios nagios  1336 Jul 15 13:49 resource.cfg

ну я так понимаю cgi скрипт

ну я так понимаю cgi скрипт нагиоса выполняется от имени апача? Тогда естественно у него нет прав на чтение /etc/nagios/. Добавьте чтение для всех на каталог. Но cgi.cfg надо править в любом случае. Там все просто.

Спасибо, огромное за то, что

Спасибо, огромное за то, что откликнулись. Права на чтение я добавил, теперь:

ls -la /etc/nagios
total 64
drwxr-xr--  3 nagios nagios   208 Jul 15 13:51 .
drwxr-xr-x 59 root   root    3656 Jul 16 12:01 ..
-rw-r--r--  1 nagios nagios     0 Jul 15 13:49 .keep_net-analyzer_nagios-core-0
-rw-rw-r--  1 nagios nagios 10690 Jul 15 13:49 cgi.cfg
-rw-rw-r--  1 nagios nagios 42478 Jul 15 13:49 nagios.cfg
drwxrwxr-x  2 nagios nagios   304 Jul 15 13:49 objects
-rw-rw----  1 nagios nagios  1336 Jul 15 13:49 resource.cfg

Ситуация не поменялась.
Попробовал найти cgi.cfg-sample, у меня его нигде нет :(

надо sudo chmod 755

надо sudo chmod 755 /etc/nagios.
Посмотрите сам cgi.cfg, там навернео тоже все с коментариями. Sample может быть в /usr/share.. но думаю он не отличается от дефолтного в /etc/nagios :)

Я пробовал найти

Я пробовал найти cgi.cfg-sample вот так find / | grep cgi.cfg-sample ничего не находит.
После chmod 755 /etc/nagios ситуация не изменилась.
В самом cgi.cfg, действительно все с комментариями, попробую разобраться.

,

Да там не в чем разбираться, если для одного пользователя, то просто раскоментировать все строки и изменить имя юзера на нужное. После изменения прав, ошибка таже? Хотя может там в конфиге все заремарено и поэтому он ругается?..

Посмотрел я в этот файл,

Посмотрел я в этот файл, нашел там строки с авторизацией, где указан юзер nagiosadmin, попробовал заменить на своего "admin", которого заводил через htpasswd. Не помогло.
Как-то мне не очень понятно, куда там прописываются пользователи, которые имеют доступ?

то что касается авторизации,

то что касается авторизации, у меня так:
(строки из cgi.cfg)

use_authentication=1
authorized_for_system_information=mirage
authorized_for_configuration_information=mirage
authorized_for_system_commands=mirage
authorized_for_all_services=mirage
authorized_for_all_hosts=mirage
authorized_for_all_service_commands=mirage
authorized_for_all_host_commands=mirage

mirage - пользователь в .htaccess

Сейчас попробую сделать еще

Сейчас попробую сделать еще раз, мож что-то упустил когда менял на admin
Это мой .htaccess:

AuthName "Access"
AuthType Basic
AuthUserFile /usr/share/nagios/htpasswd.users
Require valid-user

.

Поменяйте в cgi.cfg все nagiosadmin на admin. Я естественно имел ввиду htpasswd а не htaccess, извиняюсь )

Все так и сделал, рестартанул

Все так и сделал, рестартанул апач и теперь вот:
Error: Could not read object configuration data!

ClearKbdBuf

ClearKbdBuf написал(а):
Error: Could not read object configuration data!

Это кто говорит?
Ну и апач то тут причем? Нагиос наверное лучше рестартовать...

Я Вас благодарю за помощь и

Я Вас благодарю за помощь и содействие!
Все заработало ситуация была следующая:
После того, как я рестартовал апач исчез сабж. Но появилось при открытии динамических страниц сообщение:
Error: Could not read object configuration data!
Вы меня навели на нужную мысль, дело в том, что я вообще забыл запустить нагиос. После его запуска стало все работать по-человечески.

Я думаю, что проблема решена! Еще раз благодарю.

,

Попробуйте тогда вернуть chmod 750 /etc/nagios. Может ему и не нужно 755.. У меня nagios под freebsd, так что точно не уверен как должно быть, но у меня есть 755

Все таки без 755 он не может

Все таки без 755 он не может жить :)

Вот

Вот cgi.conf:

#################################################################
#
# CGI.CFG - Sample CGI Configuration File for Nagios 3.0.6
#
# Last Modified: 11-30-2008
#
#################################################################


# MAIN CONFIGURATION FILE
# This tells the CGIs where to find your main configuration file.
# The CGIs will read the main and host config files for any other
# data they might need.

main_config_file=/etc/nagios/nagios.cfg



# PHYSICAL HTML PATH
# This is the path where the HTML files for Nagios reside.  This
# value is used to locate the logo images needed by the statusmap
# and statuswrl CGIs.

physical_html_path=/usr/share/nagios/htdocs



# URL HTML PATH
# This is the path portion of the URL that corresponds to the
# physical location of the Nagios HTML files (as defined above).
# This value is used by the CGIs to locate the online documentation
# and graphics.  If you access the Nagios pages with an URL like
# http://www.myhost.com/nagios, this value should be '/nagios'
# (without the quotes).

url_html_path=/nagios



# CONTEXT-SENSITIVE HELP
# This option determines whether or not a context-sensitive
# help icon will be displayed for most of the CGIs.
# Values: 0 = disables context-sensitive help
#         1 = enables context-sensitive help

show_context_help=0



# PENDING STATES OPTION
# This option determines what states should be displayed in the web
# interface for hosts/services that have not yet been checked.
# Values: 0 = leave hosts/services that have not been check yet in their origina
#         1 = mark hosts/services that have not been checked yet as PENDING

use_pending_states=1




# AUTHENTICATION USAGE
# This option controls whether or not the CGIs will use any
# authentication when displaying host and service information, as
# well as committing commands to Nagios for processing.
#
# Read the HTML documentation to learn how the authorization works!

# NOTE: It is a really *bad* idea to disable authorization, unless
# you plan on removing the command CGI (cmd.cgi)!  Failure to do
# so will leave you wide open to kiddies messing with Nagios and
# possibly hitting you with a denial of service attack by filling up
# your drive by continuously writing to your command file!
#
# Setting this value to 0 will cause the CGIs to *not* use
# authentication (bad idea), while any other value will make them
# use the authentication functions (the default).

use_authentication=1


# x509 CERT AUTHENTICATION
# When enabled, this option allows you to use x509 cert (SSL)
# authentication in the CGIs.  This is an advanced option and should
# not be enabled unless you know what you're doing.

use_ssl_authentication=0

Видимо нужно последовать совету производителя:




# DEFAULT USER
# Setting this variable will define a default user name that can
# access pages without authentication.  This allows people within a
# secure domain (i.e., behind a firewall) to see the current status
# without authenticating.  You may want to use this to avoid basic
# authentication if you are not using a secure server since basic
# authentication transmits passwords in the clear.
#
# Important:  Do not define a default username unless you are
# running a secure web server and are sure that everyone who has
# access to the CGIs has been authenticated in some manner!  If you
# define this variable, anyone who has not authenticated to the web
# server will inherit all rights you assign to this user!

#default_user_name=guest

# SYSTEM/PROCESS INFORMATION ACCESS
# This option is a comma-delimited list of all usernames that
# have access to viewing the Nagios process information as
# provided by the Extended Information CGI (extinfo.cgi).  By
# default, *no one* has access to this unless you choose to
# not use authorization.  You may use an asterisk (*) to
# authorize any user who has authenticated to the web server.

authorized_for_system_information=nagiosadmin



# CONFIGURATION INFORMATION ACCESS
# This option is a comma-delimited list of all usernames that
# can view ALL configuration information (hosts, commands, etc).
# By default, users can only view configuration information
# for the hosts and services they are contacts for. You may use
# an asterisk (*) to authorize any user who has authenticated
# to the web server.

authorized_for_configuration_information=nagiosadmin



# SYSTEM/PROCESS COMMAND ACCESS
# This option is a comma-delimited list of all usernames that
# can issue shutdown and restart commands to Nagios via the
# command CGI (cmd.cgi).  Users in this list can also change
# the program mode to active or standby. By default, *no one*
# has access to this unless you choose to not use authorization.
# You may use an asterisk (*) to authorize any user who has
# authenticated to the web server.

authorized_for_system_commands=nagiosadmin



# GLOBAL HOST/SERVICE VIEW ACCESS
# These two options are comma-delimited lists of all usernames that
# can view information for all hosts and services that are being
# monitored.  By default, users can only view information
# for hosts or services that they are contacts for (unless you
# you choose to not use authorization). You may use an asterisk (*)
# to authorize any user who has authenticated to the web server.

authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin



# GLOBAL HOST/SERVICE COMMAND ACCESS
# These two options are comma-delimited lists of all usernames that
# can issue host or service related commands via the command
# CGI (cmd.cgi) for all hosts and services that are being monitored.
# By default, users can only issue commands for hosts or services
# that they are contacts for (unless you you choose to not use
# authorization).  You may use an asterisk (*) to authorize any
# user who has authenticated to the web server.

authorized_for_all_service_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin

# STATUSMAP BACKGROUND IMAGE
# This option allows you to specify an image to be used as a
# background in the statusmap CGI.  It is assumed that the image
# resides in the HTML images path (i.e. /usr/local/nagios/share/images).
# This path is automatically determined by appending "/images"
# to the path specified by the 'physical_html_path' directive.
# Note:  The image file may be in GIF, PNG, JPEG, or GD2 format.
# However, I recommend that you convert your image to GD2 format
# (uncompressed), as this will cause less CPU load when the CGI
# generates the image.

#statusmap_background_image=smbackground.gd2



# DEFAULT STATUSMAP LAYOUT METHOD
# This option allows you to specify the default layout method
# the statusmap CGI should use for drawing hosts.  If you do
# not use this option, the default is to use user-defined
# coordinates.  Valid options are as follows:
#       0 = User-defined coordinates
#       1 = Depth layers

#       2 = Collapsed tree
#       3 = Balanced tree
#       4 = Circular
#       5 = Circular (Marked Up)

default_statusmap_layout=5



# DEFAULT STATUSWRL LAYOUT METHOD
# This option allows you to specify the default layout method
# the statuswrl (VRML) CGI should use for drawing hosts.  If you
# do not use this option, the default is to use user-defined
# coordinates.  Valid options are as follows:
#       0 = User-defined coordinates
#       2 = Collapsed tree
#       3 = Balanced tree
#       4 = Circular

default_statuswrl_layout=4

# STATUSWRL INCLUDE
# This option allows you to include your own objects in the
# generated VRML world.  It is assumed that the file
# resides in the HTML path (i.e. /usr/local/nagios/share).

#statuswrl_include=myworld.wrl



# PING SYNTAX
# This option determines what syntax should be used when
# attempting to ping a host from the WAP interface (using
# the statuswml CGI.  You must include the full path to
# the ping binary, along with all required options.  The
# $HOSTADDRESS$ macro is substituted with the address of
# the host before the command is executed.
# Please note that the syntax for the ping binary is
# notorious for being different on virtually ever *NIX
# OS and distribution, so you may have to tweak this to
# work on your system.

ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$

# REFRESH RATE
# This option allows you to specify the refresh rate in seconds
# of various CGIs (status, statusmap, extinfo, and outages).

refresh_rate=90



# ESCAPE HTML TAGS
# This option determines whether HTML tags in host and service
# status output is escaped in the web interface.  If enabled,
# your plugin output will not be able to contain clickable links.

escape_html_tags=1




# SOUND OPTIONS
# These options allow you to specify an optional audio file
# that should be played in your browser window when there are
# problems on the network.  The audio files are used only in
# the status CGI.  Only the sound for the most critical problem
# will be played.  Order of importance (higher to lower) is as
# follows: unreachable hosts, down hosts, critical services,
# warning services, and unknown services. If there are no
# visible problems, the sound file optionally specified by
# 'normal_sound' variable will be played.
#
#
# <varname>=<sound_file>
#
# Note: All audio files must be placed in the /media subdirectory
# under the HTML path (i.e. /usr/local/nagios/share/media/).

#host_unreachable_sound=hostdown.wav
#host_down_sound=hostdown.wav
#service_critical_sound=critical.wav
#service_warning_sound=warning.wav
#service_unknown_sound=warning.wav
#normal_sound=noproblem.wav

# URL TARGET FRAMES
# These options determine the target frames in which notes and
# action URLs will open.

action_url_target=_blank
notes_url_target=_blank




# LOCK AUTHOR NAMES OPTION
# This option determines whether users can change the author name
# when submitting comments, scheduling downtime.  If disabled, the
# author names will be locked into their contact name, as defined in Nagios.
# Values: 0 = allow editing author names
#         1 = lock author names (disallow editing)

lock_author_names=1

# SPLUNK INTEGRATION OPTIONS
# These options allow you to enable integration with Splunk
# in the web interface.  If enabled, you'll be presented with
# "Splunk It" links in various places in the CGIs (log file,
# alert history, host/service detail, etc).  Useful if you're
# trying to research why a particular problem occurred.
# For more information on Splunk, visit http://www.splunk.com/

# This option determines whether the Splunk integration is enabled
# Values: 0 = disable Splunk integration
#         1 = enable Splunk integration

#enable_splunk_integration=1


# This option should be the URL used to access your instance of Splunk

#splunk_url=http://127.0.0.1:8000/

Думаю стоит долго и утомительно понимать:
# Read the HTML documentation to learn how the authorization works!

Настройки просмотра комментариев

Выберите нужный метод показа комментариев и нажмите "Сохранить установки".