Failed to Start Nagios service

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Failed to Start Nagios service

Postby Ravikimt » Thu Nov 29, 2018 9:16 am

Hi All,

I have installed nagios-4.4.1 version on my Ubuntu 18.04 LTS. Everything look fine but I am only getting below mentioned error while starting my Nagios service can anyone help me on this how I can get rid of this problem.
Code: Select all
● nagios.service - Nagios Core 4.4.1
   Loaded: loaded (/lib/systemd/system/nagios.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2018-11-29 14:06:12 UTC; 3s ago
     Docs: https://www.nagios.org/documentation
  Process: 19402 ExecStopPost=/bin/rm -f /usr/local/nagios/var/rw/nagios.cmd (code=exited, status=0/SUCCESS)
  Process: 19391 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
  Process: 19390 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
Main PID: 19401 (code=exited, status=1/FAILURE)

Nov 29 14:06:12 Nginx-Backup nagios[19390]: Total Errors:   0
Nov 29 14:06:12 Nginx-Backup nagios[19390]: Things look okay - No serious problems were detected during the pre-flight check
Nov 29 14:06:12 Nginx-Backup systemd[1]: Started Nagios Core 4.4.1.
Nov 29 14:06:12 Nginx-Backup nagios[19401]: Nagios 4.3.4 starting... (PID=19401)
Nov 29 14:06:12 Nginx-Backup nagios[19401]: Local time is Thu Nov 29 14:06:12 UTC 2018
Nov 29 14:06:12 Nginx-Backup systemd[1]: nagios.service: Main process exited, code=exited, status=1/FAILURE
Nov 29 14:06:12 Nginx-Backup nagios[19401]: LOG VERSION: 2.0
Nov 29 14:06:12 Nginx-Backup systemd[1]: nagios.service: Failed with result 'exit-code'.
Nov 29 14:06:12 Nginx-Backup nagios[19401]: [u]qh: Failed to init socket '/usr/local/nagios/var/rw/nagios.qh'. unlink() failed: Permission denied[/u]
Nov 29 14:06:12 Nginx-Backup nagios[19401]: Error: Failed to initialize query handler. Aborting
Ravikimt
 
Posts: 77
Joined: Tue Apr 03, 2018 12:02 pm

Re: Failed to Start Nagios service

Postby scottwilkerson » Thu Nov 29, 2018 9:35 am

Looks like there is an issue with this file:
Code: Select all
ls -l /usr/local/nagios/var/rw/nagios.qh


If it exists you may need to delete the file and try starting nagios again
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 16617
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Failed to Start Nagios service

Postby Ravikimt » Mon Dec 10, 2018 6:52 am

@scottwilkerson Thanks for the help. The previous issue got resolved but Now I am facing the another issue. I am not getting any error while running pre-flight check command for the nagios.cfg file

I am getting below mentioned error in nagios.log. Please help me here because it's not triggering the alerts

Code: Select all
[1544442429] wproc:   stderr line 01: /bin/sh: 1: /usr/bin/sendEmail: not found
[1544442429] wproc:   stderr line 02: /usr/bin/printf: write error: Broken pipe
Ravikimt
 
Posts: 77
Joined: Tue Apr 03, 2018 12:02 pm

Re: Failed to Start Nagios service

Postby tgriep » Tue Dec 11, 2018 4:36 pm

The error is coming from the commands that send the email notifications and it looks like the sendEmail command is not installed so run this to install it.
Code: Select all
apt install sendemail


If it still fails, can you post your Nagios commands file so we can check the syntax for the mailer commands?
Code: Select all
/usr/local/nagios/etc/objects/commands.cfg


Thanks
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8340
Joined: Thu Oct 30, 2014 9:02 am

Re: Failed to Start Nagios service

Postby Ravikimt » Wed Dec 12, 2018 6:48 am

@tgriep Thanks for the help now I am getting below error after installing sendemail. It's showing me "Authentication not supported by the remote SMTP server!"

But the same SMTP server credential I am using somewhere else and it's working fine. I am suspecting that it's a not configuration issue please share your thought on the same.


Code: Select all
[1544614007] wproc:   stdout line 01: Dec 12 11:26:40 nginx-backup sendEmail[7021]: NOTICE => Authentication not supported by the remote SMTP server!
[1544614007] wproc:   stdout line 02: Dec 12 11:26:45 nginx-backup sendEmail[7021]: ERROR => Received:  530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [BYAPR11CA0100.namprd11.prod.outlook.com]
Ravikimt
 
Posts: 77
Joined: Tue Apr 03, 2018 12:02 pm

Re: Failed to Start Nagios service

Postby tgriep » Wed Dec 12, 2018 2:23 pm

Couple of thing to check. See if the SMTP server has a filter that only allows certain hosts or certain IP addresses to forward emails through it.
Another thing, if the Nagios server is not supplying a valid from address, the SMTP server may block the emails as well so make sure that is set in the email notify command on the Nagios server.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
 
Posts: 8340
Joined: Thu Oct 30, 2014 9:02 am

Re: Failed to Start Nagios service

Postby Ravikimt » Fri Dec 14, 2018 4:45 am

Hi tgriep, Firstly we don't have any mail server, we are using "smtp.office365.com" to send the emails we don't have suck any kind of options there "Only allows certain hosts or certain IP addresses to forward emails through ".

I verified that nagios server is supplying a valid from address. Still I am facing the same issue attaching email notify command for your reference.

resource.cfg file

Code: Select all
$USER1$=/usr/local/nagios/libexec

Code: Select all
$USER5$=nagios@xyz.com-email

Code: Select all
$USER6$=password

Code: Select all
$USER7$=smtp.office365.com


command.cfg

Code: Select all
# '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$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/sendEmail -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nNote: This is an automated message that is system generated so please do not reply to this email. For any queries write to 'tech.support@xyz.com'"


Code: Select all
# '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\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/sendEmail -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n\nNote: This is an automated message that is system generated so please do not reply to this email. For any queries write to 'tech.support@xyz.com'"
        }


Please help me here to solve this issue.
Ravikimt
 
Posts: 77
Joined: Tue Apr 03, 2018 12:02 pm

Re: Failed to Start Nagios service

Postby danjoh » Fri Dec 14, 2018 5:33 am

I do not know sendEmail, but checking the Web (http://caspian.dotconf.net/menu/Software/SendEmail/) it looks like you can specify the message body using the -m parameter (which you have...) and then you probable do not need the " /usr/bin/printf "%b ..." part.

So I would try something like this:

Code: Select all
# 'notify-host-by-email' command definition
define command{
        command_name    notify-host-by-email
        command_line    /usr/bin/sendEmail -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nNote: This is an automated message that is system generated so please do not reply to this email. For any queries write to 'tech.support@xyz.com'"

# 'notify-service-by-email' command definition
define command{
        command_name    notify-service-by-email
        command_line    /usr/bin/sendEmail -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n\nNote: This is an automated message that is system generated so please do not reply to this email. For any queries write to 'tech.support@xyz.com'"
        }


Depending on how your actual $USER6$ (password) looks like, you may have to add quotes to $USER6$ when you "use" it in the command (hint: shell special characters).

And by the way, what does /var/log/sendEmail say?
--
D/\N
danjoh
 
Posts: 59
Joined: Mon Dec 07, 2015 10:43 am
Location: Zürich, Switzerland

Re: Failed to Start Nagios service

Postby Ravikimt » Fri Dec 14, 2018 7:11 am

I have one doubt, We are running Nagios core on two machines with the same configuration. In one machine Nagios is working fine without any issues but in another machine we are facing this issue.

How it can be possible something works on one machine and doesn't work on another machine.? I have verified that both the machines have same configuration file with the same permissions.

Only difference is that we are running Nagios on Ubuntu 16.04 LTS in one machine and another on 18.04 LTS.
Ravikimt
 
Posts: 77
Joined: Tue Apr 03, 2018 12:02 pm

Re: Failed to Start Nagios service

Postby danjoh » Fri Dec 14, 2018 7:40 am

Different versions of sendEmail?

Different paths to sendEmail?
Run
Code: Select all
locate sendEmail
and/or
Code: Select all
which sendEmail
on both systems and check for differences.
--
D/\N
danjoh
 
Posts: 59
Joined: Mon Dec 07, 2015 10:43 am
Location: Zürich, Switzerland

Next

Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 17 guests