Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiencing Issues in Nagios3 #2

Closed
obeardly opened this issue Apr 9, 2018 · 7 comments
Closed

Experiencing Issues in Nagios3 #2

obeardly opened this issue Apr 9, 2018 · 7 comments

Comments

@obeardly
Copy link

obeardly commented Apr 9, 2018

Should this work with nagios3? I continuously get the following error:

Error in configuration file '/etc/nagios3/nagios.cfg' - Line 10 (NULL value)
   Error processing main config file!

However, line 10 is just define command {

Any help would be appreciated.

@RunlevelConsulting
Copy link
Owner

Looks like the definition above Line 10 is broken, does it have a closing curly bracket?

@obeardly
Copy link
Author

obeardly commented Apr 9, 2018

No, when it threw the error, I moved the "define command" statement to the beginning of the nagios.cfg file, and it still gives the error. If I comment the two "define command" statements out, it works fine. I was thinking that maybe the syntax has changed.

define command {
command_name notify-host-slack-opintel
command_line /bin/bash /etc/nagios3/notification_slack.sh -a "$NOTIFICATIONTYPE$" -b "$HOSTNAME$" -c "$HOSTSTATE$" -d "$HOSTOUTPUT$" -y "opintel" -z "https://hooks.slack.com/services/lotsofgobblygoop"
}

I would appreciate any guidance you can give. Thanks!

@RunlevelConsulting
Copy link
Owner

RunlevelConsulting commented Apr 10, 2018

Hm...

Just as a note, the webhook address shouldn't include the URL: https://hooks.slack.com/services/
It should just be the code: e.g - T07B2S2CC/B1HDDQ83A/naizPgXARIlUSixE0RUL93Oy

Also, can you run
/usr/local/nagios/bin/nagios -v /etc/nagios3/nagios.cfg
(You may have to modify the command to match your path)

If you don't mind, post the output here and I'll take a look (feel free to comment out anything confidential). This script is currently working in production elsewhere on Nagios3 so hopefully we can work it out.

@RunlevelConsulting
Copy link
Owner

As an aside, if you want to test the script without Nagios you can run
/bin/bash /etc/nagios3/notification_slack.sh -a "WARNING" -b "test.domain.com" -c "DOWN" -d "This is a test" -y "opintel" -z "T07B2S2CC/B1HDDQ83A/naizPgXARIlUSixE0RUL93Oy"
directly in the command line - replacing the webhook code for your own. This will at least confrm that the script will work when you get the Nagios side sorted.

@obeardly
Copy link
Author

Thanks for the above test. I was able to run it and alert Slack. However, the following syntax:

define command {
command_name notify-host-slack-opintel
command_line /bin/bash /etc/nagios3/notification_slack.sh -a "$NOTIFICATIONTYPE$" -b "$HOSTNAME$" -c "$HOSTSTATE$" -d "$HOSTOUTPUT$" -y "opintel" -z "T03AD0X2H/B8JCJ6M2A/SlIK8yEb6xobfuscated"
}

still results in an error. I'm on Devuan, which is Debian minus systemd. I ran:

/usr/sbin/nagios3 -v /etc/nagios3/nagios.cfg

which resulted in:

Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL

Website: http://www.nagios.org
Reading configuration data...
Error in configuration file '/etc/nagios3/nagios.cfg' - Line 1306 (NULL value)
   Error processing main config file!



***> 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 defintions.  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.

Line 1306 is the define command statement that is listed above. It just doesn't like that syntax for some reason. I'm sure I must be doing something wrong. Thanks for all of your assistance.

@obeardly
Copy link
Author

So it turns out this was a misunderstanding on my part. The define command statement for the version of nagios I'm running has to be in /etc/nagios3/commands.cfg. If you put it in the /etc/nagios3/nagios.cfg file, it will error out on you every time. My apologies for wasting your time. It's been many years since I've stood up a nagios server. Thanks again for all of your help.

@RunlevelConsulting
Copy link
Owner

Ah of course, I didn't have a Nagios setup to look at anymore these days (this tool was written for an old client) and I was trying to remember the way it's configured. You're right, nagios.cfg is a different syntax than the command / host / service definitions.

Not a waste of time at all, your feedback has made it clear I need to improve the documentation so thank you for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants