nagios service restart failed.

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.
anoopjeev
Posts: 29
Joined: Wed Jul 26, 2017 6:58 pm

nagios service restart failed.

Post by anoopjeev »

i have installed nagios core on centsos 7. After installation, i added one host to the windows.cfg file and unchecked in nagios.cfg. When i tried to restart nagios service, it fails. I have added the output after i ran the commands below. Pls help.

#Error when i try to restart nagios service
service nagios restart
Restarting nagios (via systemctl): Job for nagios.service failed because the control process exited with error code. See "systemctl status nagios.service" and "journalctl -xe" for details.
[FAILED]

#systemctl message
systemctl -l status nagios.service
● nagios.service - LSB: Starts and stops the Nagios monitoring server
Loaded: loaded (/etc/rc.d/init.d/nagios; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2017-07-26 19:37:54 EDT; 16min ago
Docs: man:systemd-sysv-generator(8)
Process: 3222 ExecStart=/etc/rc.d/init.d/nagios start (code=exited, status=8)

Jul 26 19:37:54 localhost.localdomain nagios[3222]: Check your configuration file(s) to ensure that they contain valid
Jul 26 19:37:54 localhost.localdomain nagios[3222]: directives and data definitions. If you are upgrading from a previous
Jul 26 19:37:54 localhost.localdomain nagios[3222]: version of Nagios, you should be aware that some variables/definitions
Jul 26 19:37:54 localhost.localdomain nagios[3222]: may have been removed or modified in this version. Make sure to read
Jul 26 19:37:54 localhost.localdomain nagios[3222]: the HTML documentation regarding the config files, as well as the
Jul 26 19:37:54 localhost.localdomain nagios[3222]: 'Whats New' section to find out what has changed.
Jul 26 19:37:54 localhost.localdomain systemd[1]: nagios.service: control process exited, code=exited status=8
Jul 26 19:37:54 localhost.localdomain systemd[1]: Failed to start LSB: Starts and stops the Nagios monitoring server.
Jul 26 19:37:54 localhost.localdomain systemd[1]: Unit nagios.service entered failed state.
Jul 26 19:37:54 localhost.localdomain systemd[1]: nagios.service failed.


#journalctl -xe
journalctl -xe
Jul 26 20:06:47 localhost.localdomain nagios[3818]: Website: https://www.nagios.org
Jul 26 20:06:47 localhost.localdomain nagios[3818]: Reading configuration data...
Jul 26 20:06:47 localhost.localdomain nagios[3818]: Read main config file okay...
Jul 26 20:06:47 localhost.localdomain nagios[3818]: Error: Could not find any host matc
Jul 26 20:06:47 localhost.localdomain nagios[3818]: Error: Failed to expand host list '
Jul 26 20:06:47 localhost.localdomain nagios[3818]: Error processing object config file
Jul 26 20:06:47 localhost.localdomain nagios[3818]: ***> One or more problems was encou
Jul 26 20:06:47 localhost.localdomain nagios[3818]: Check your configuration file(s) to
Jul 26 20:06:47 localhost.localdomain nagios[3818]: directives and data definitions. I
Jul 26 20:06:47 localhost.localdomain nagios[3818]: version of Nagios, you should be aw
Jul 26 20:06:47 localhost.localdomain nagios[3818]: may have been removed or modified i
Jul 26 20:06:47 localhost.localdomain nagios[3818]: the HTML documentation regarding th
Jul 26 20:06:47 localhost.localdomain nagios[3818]: 'Whats New' section to find out wha
Jul 26 20:06:47 localhost.localdomain systemd[1]: nagios.service: control process exite
Jul 26 20:06:47 localhost.localdomain systemd[1]: Failed to start LSB: Starts and stops
-- Subject: Unit nagios.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/li ... temd-devel


--
-- Unit nagios.service has failed.
--
-- The result is failed.
Jul 26 20:06:47 localhost.localdomain systemd[1]: Unit nagios.service entered failed st
Jul 26 20:06:47 localhost.localdomain systemd[1]: nagios.service failed.
Jul 26 20:06:47 localhost.localdomain polkitd[655]: Unregistered Authentication Agent f
lines 2967-2991/2991 (END)
bolson

Re: nagios service restart failed.

Post by bolson »

Hello anoopjeev,

Please run the following commant and post your result.

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Thank you!
anoopjeev
Posts: 29
Joined: Wed Jul 26, 2017 6:58 pm

Re: nagios service restart failed.

Post by anoopjeev »

[root@localhost etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.3.2
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2017-05-09
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Error: Could not find any host matching 'winserver' (config file '/usr/local/nagios/etc/objects/windows.cfg', starting on line 167)
Error: Failed to expand host list 'winserver' for service 'Explorer' (/usr/local/nagios/etc/objects/windows.cfg:167)
Error processing object config files!


***> One or more problems was encountered while processing the config files...

Check your configuration file(s) to ensure that they contain valid
directives and data definitions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
bolson

Re: nagios service restart failed.

Post by bolson »

Please attach /usr/local/nagios/etc/objects/windows.cfg

Thank you!
anoopjeev
Posts: 29
Joined: Wed Jul 26, 2017 6:58 pm

Re: nagios service restart failed.

Post by anoopjeev »

###############################################################################
# WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE
#
#
# NOTES: This config file assumes that you are using the sample configuration
# files that get installed with the Nagios quickstart guide.
#
###############################################################################




###############################################################################
###############################################################################
#
# HOST DEFINITIONS
#
###############################################################################
###############################################################################

# Define a host for the Windows machine we'll be monitoring
# Change the host_name, alias, and address to fit your situation

define host{
use windows-server ; Inherit default values from a template
host_name IA0CW007 ; The name we're giving to this host
alias IA0CW007 ; A longer name associated with the host
address 10.52.94.31 ; IP address of the host
}
###############################################################################
###############################################################################
#
# HOST GROUP DEFINITIONS
#
###############################################################################
###############################################################################


# Define a hostgroup for Windows machines
# All hosts that use the windows-server template will automatically be a member of thi$

define hostgroup{
hostgroup_name windows-servers ; The name of the hostgroup
alias Windows Servers ; Long name of the group
}




###############################################################################
###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################


# Create a service for monitoring the version of NSCLient++ that is installed
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name IA0CW007
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}



# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined above
define service{
use generic-service
host_name IA0CW007
service_description Uptime
check_command check_nt!UPTIME
}



# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name IA0CW007
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}

# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name IA0CW007
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}

# Create a service for monitoring C:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name IA0CW007
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}

# Create a service for monitoring E:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name IA0CW007
service_description E:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
# Create a service for monitoring F:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name IA0CW007
service_description F:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}

# Create a service for monitoring H:\ disk usage
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name IA0CW007
service_description H:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}

# Create a service for monitoring the W3SVC service
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name winserver
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}

# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name winserver
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}



# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name winserver
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}
when i entered cd /usr/local/nagios/etc/objects/windows.cfg i got the below:
bash: cd: /usr/local/nagios/etc/objects/windows.cfg: Not a directory
I then did nano windows.cfg after i browsed to the directory.
This is my first time working on linux. Please pardon for silly mistakes or doubts (if any).
bolson

Re: nagios service restart failed.

Post by bolson »

Please scroll down to the bottom of the file. I believe this is the cause of your issue:

# Create a service for monitoring the W3SVC service
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name winserver
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}

# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name winserver
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}



# Create a service for monitoring the Explorer.exe process
# Change the host_name to match the name of the host you defined above

define service{
use generic-service
host_name winserver
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}
anoopjeev
Posts: 29
Joined: Wed Jul 26, 2017 6:58 pm

Re: nagios service restart failed.

Post by anoopjeev »

Thankyou bolson. That worked! :D

I have installed nagios client on the server. But still web interface shows it could not fetch info from the server.
I have added nagios server in the allowed host, and checked the first three options while installing the client as per this video https://www.youtube.com/watch?v=GxdPh9hk844

Please refer the attachment for the error.
Can we continue the same thread or u want me to open a new one?
Attachments
Capture.JPG
bolson

Re: nagios service restart failed.

Post by bolson »

Did you install the agent (nsclient++) on the Windows host? In order to monitor a remote host, you need to have an agent running on the remote host.
anoopjeev
Posts: 29
Joined: Wed Jul 26, 2017 6:58 pm

Re: nagios service restart failed.

Post by anoopjeev »

I did install the agent.
Check the attachment please.
Attachments
1.JPG
bolson

Re: nagios service restart failed.

Post by bolson »

Go to a command prompt on your Nagios server and type

Code: Select all

IA0CW007
And post the result. This seems like a Windows Firewall issue.
Locked