Basic nagios question

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.

Basic nagios question

Postby quandary » Mon Feb 11, 2019 11:23 am

Hi,

I need to set up an monitoring system for my company, i'm trying to configure nagios for Windows server monitoring, i followed theses steps :

https://assets.nagios.com/downloads/nag ... installing

First i have to say that the paths was wrong for ncpa.cfg, my commands.cfg file wasn't created at all, and some of other things that are burning my brain.

So far i did theses steps :

1 - Followed the usual check_ncpa.py plugins install #Everything ok
2 - I had to create "commands.cfg" to /usr/local/nagios/etc/ and added :
Code: Select all
define command {
    command_name    check_ncpa
    command_line    $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
}

3 - I used locate to find ncpa.cfg (/usr/local/ncpa/etc/ncpa.cfg) and i edited it with the usual config :
Code: Select all
define host {
    host_name               SRV-AADC
    address                 192.168.70.28
    check_command           check_ncpa!-t '' -P 5693 -M system/agent_version
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    contacts                nagiosadmin
    notification_interval   60
    notification_period     24x7
    notifications_enabled   1
    icon_image              ncpa.png
    statusmap_image         ncpa.png
    register                1
}

define service {
    host_name               SRV-AADC
    service_description     CPU Usage
    check_command           check_ncpa!-t '' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}
define service {
    host_name               SRV-AADC
    service_description     CPU Usage
    check_command           check_ncpa!-t '' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}

define service {
    host_name               SRV-AADC
    service_description     Memory Usage
    check_command           check_ncpa!-t '' -P 5693 -M memory/virtual -w 50 -c 80 -u G
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}

define service {
    host_name               SRV-AADC
    service_description     Process Count
    check_command           check_ncpa!-t '' -P 5693 -M processes -w 150 -c 200
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}

4 - I have installed NCPA for W32 bits on my 2012 server without ANY config cuz i there is no clear explanation, wtf is a token ? where do i find it ? what is the point of this thing ? I do not specify any token and the install keep going... so i was able to check local server 127.0.0.1:5693 was working find just pressed enter at login screen, no password...
5 - Did a "net stop ncpalistener && net start ncpalistener && net stop ncpapassive && net stop ncpapassive" on my sh**ty 2012 R2 server.
6 - Did a "service nagios restart" and here we are that's where the pain in the a** become

This is the fourth monitoring software i'm trying to set up and there no "normal" installation for monitoring, it has to be complicated all the time, i can't understand why dev's are building brain salad, i just want to monitor my windows servers :'(

Back to the job, i get this error message (service can't start obviously, btw nagios gui was ok before npca install)

Code: Select all
févr. 11 16:52:31 Nagios nagios[38799]: Nagios Core 4.4.3
févr. 11 16:52:31 Nagios nagios[38799]: Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
févr. 11 16:52:31 Nagios nagios[38799]: Copyright (c) 1999-2009 Ethan Galstad
févr. 11 16:52:31 Nagios nagios[38799]: Last Modified: 2019-01-15
févr. 11 16:52:31 Nagios nagios[38799]: License: GPL
févr. 11 16:52:31 Nagios nagios[38799]: Website: https://www.nagios.org
févr. 11 16:52:31 Nagios nagios[38799]: Reading configuration data...
févr. 11 16:52:31 Nagios nagios[38799]:    Read main config file okay...
févr. 11 16:52:31 Nagios nagios[38799]: Error: Unexpected token or statement in file '/usr/local/ncpa/etc/ncpa.cfg' on line 12.
févr. 11 16:52:31 Nagios nagios[38799]: Error: Command name of command line is NULL
févr. 11 16:52:31 Nagios nagios[38799]: Error: Could not register command (config file '/usr/local/nagios/etc/objects/commands.cfg', starting on line 257)
févr. 11 16:52:31 Nagios nagios[38799]:    Error processing object config files!
févr. 11 16:52:31 Nagios nagios[38799]: ***> One or more problems was encountered while processing the config files...
févr. 11 16:52:31 Nagios nagios[38799]:      Check your configuration file(s) to ensure that they contain valid
févr. 11 16:52:31 Nagios nagios[38799]:      directives and data definitions.  If you are upgrading from a previous
févr. 11 16:52:31 Nagios nagios[38799]:      version of Nagios, you should be aware that some variables/definitions
févr. 11 16:52:31 Nagios nagios[38799]:      may have been removed or modified in this version.  Make sure to read
févr. 11 16:52:31 Nagios nagios[38799]:      the HTML documentation regarding the config files, as well as the
févr. 11 16:52:31 Nagios nagios[38799]:      'Whats New' section to find out what has changed.
févr. 11 16:52:31 Nagios systemd[1]: nagios.service: Control process exited, code=exited status=1
févr. 11 16:52:31 Nagios systemd[1]: Failed to start Nagios Core 4.4.3.


BTW sorry kids for my language but i'm a bit pis**d off, 6 hours on this thing and can't get it to work for a simple task : a windows server check, i tryied at least twenty google "solution" nothing worked and it f**ked up my server so i had to used a snapshot to fresh install and tryed back npca install and here i am.

I appologize too for any english grammatical/or anything mistake cuz that's not my main language and my studies didn't helped so i had to learn by myself :X
quandary
 
Posts: 4
Joined: Mon Feb 11, 2019 10:55 am

Re: Basic nagios question

Postby npolovenko » Mon Feb 11, 2019 5:56 pm

Hello, @quandary.

First i have to say that the paths was wrong for ncpa.cfg, my commands.cfg file wasn't created at all, and some of other things that are burning my brain.


Do you mean the ncpa.cfg file on the windows server that was supposed to be in C:\Program Files (x86)\Nagios\NCPA\etc\ncpa.cfg? Where was it in your case?

You did not have the commands.cfg file in the /usr/local/nagios/etc/ folder on the Nagios server? What tutorial did you use to install the Core?





I used locate to find ncpa.cfg (/usr/local/ncpa/etc/ncpa.cfg) and i edited it with the usual config

No, you need to create a new file called ncpa.cfg in /usr/local/nagios/etc/.
/usr/local/nagios/etc/ncpa.cfg

And add these configs to the file:
Code: Select all
define host {
    host_name               SRV-AADC
    address                 192.168.70.28
    check_command           check_ncpa!-t '' -P 5693 -M system/agent_version
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    contacts                nagiosadmin
    notification_interval   60
    notification_period     24x7
    notifications_enabled   1
    icon_image              ncpa.png
    statusmap_image         ncpa.png
    register                1
}

define service {
    host_name               SRV-AADC
    service_description     CPU Usage
    check_command           check_ncpa!-t '' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}
define service {
    host_name               SRV-AADC
    service_description     CPU Usage
    check_command           check_ncpa!-t '' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}

define service {
    host_name               SRV-AADC
    service_description     Memory Usage
    check_command           check_ncpa!-t '' -P 5693 -M memory/virtual -w 50 -c 80 -u G
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}

define service {
    host_name               SRV-AADC
    service_description     Process Count
    check_command           check_ncpa!-t '' -P 5693 -M processes -w 150 -c 200
    max_check_attempts      5
    check_interval          5
    retry_interval          1
    check_period            24x7
    notification_interval   60
    notification_period     24x7
    contacts                nagiosadmin
    register                1
}



I had to create "commands.cfg" to /usr/local/nagios/etc/ and added :
define command {
command_name check_ncpa
command_line $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
}

This is a good command, but again I'm not sure why you didn't have the commands.cfg file in your /usr/local/nagios/etc/ folder. EIther your Nagios Core installation did not go well or you deleted some files afterwards.
On the Nagios server please run this command and show me the output:
ls -l /usr/local/nagios/etc/




wtf is a token ? where do i find it ? what is the point of this thing ? I do not specify any token and the install keep going...

You can specify a token during the NCPA isntallation. Then use the same token in the commands that you have in the /usr/local/nagios/etc/ncpa.cfg file on the nagios server. In this example, the word TOKEN is the token.
check_ncpa!-t 'TOKEN' -P 5693 -M system/agent_version


That just makes sure that other servers on the network can not access NCPA on the windows server(because they won't know the token, obviously). You don't have to specify any token, thats optional.


Did a "net stop ncpalistener && net start ncpalistener && net stop ncpapassive && net stop ncpapassive" on my sh**ty 2012 R2 server.

Just leave the active listener only, for now:
net stop ncpapassive
net start ncpalistener



Did a "service nagios restart" and here we are that's where the pain in the a** become

Error: Unexpected token or statement in file '/usr/local/ncpa/etc/ncpa.cfg' on line 12.

Your ncpa.cfg file should be in the /usr/local/nagios/etc/ folder. Please remove all changes you made to the /usr/local/ncpa/etc/ncpa.cfg file. We don't need to use it in this case at all.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
npolovenko
Support Tech
 
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Basic nagios question

Postby quandary » Tue Feb 12, 2019 2:06 am

Hi,

First of all thanks for your answer, you really help to understand, today is a new day, i gonna try to reinstall everything clean.

I used the basic tutorial from Nagios Core documentation for the install

Here was my "ls -l /usr/local/nagios/etc/"

Code: Select all
root@Nagios:~# ls -l /usr/local/nagios/etc/
total 76
-rw-rw-r-- 1 nagios nagios 13710 févr. 11 15:42 cgi.cfg
-rw-r--r-- 1 root   nagios    50 févr. 11 15:43 htpasswd.users
-rw-rw-r-- 1 nagios nagios 45928 févr. 11 16:48 nagios.cfg
drwxrwsr-x 2 nagios nagios  4096 févr. 11 17:00 objects
-rw-rw---- 1 nagios nagios  1312 févr. 11 15:42 resource.cfg


But anyway i'm gonna start back from the bottom to see if i can get commands.cfg working, and i will try what you said to me in your answer.

Again thanks for taking the time to read, really appreciate.
quandary
 
Posts: 4
Joined: Mon Feb 11, 2019 10:55 am

Re: Basic nagios question

Postby quandary » Tue Feb 12, 2019 3:45 am

Hi,

Thanks for the answer i really appreciate,

I did a fresh new install on Ubuntu server 18.04-01 LTS (Last one i was on Debian 9.6.0), and followed your advice, used the nagios core "quick install guide for ubuntu", everything was working so far, my server was into nagios as "localhost" with status : UP

I tried to follow the NCPA documentation, and again, no commands.cfg i don't know what to do, stuck at the same step.

Code: Select all
Create the check command definition

Create the check_ncpa command in your configuration files for Nagios Core, normally they are located in /usr/local/nagios/etc - you may have a commands.cfg file you will want to put this command in. The command below will allow us to pass most of the arguments in with $ARG1$, allowing it to be more dynamic.

define command {
    command_name    check_ncpa
    command_line    $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
}


So i try to follow the doc, i went into /usr/local/nagios/etc on my Ubuntu server :

Code: Select all
root@nagios:/# ls -la /usr/local/nagios/etc
total 84
drwxrwxr-x 3 nagios nagios  4096 févr. 12 08:21 .
drwxr-xr-x 8 root   root    4096 févr. 12 07:50 ..
-rw-rw-r-- 1 nagios nagios 13667 févr. 12 08:21 cgi.cfg
-rw-r--r-- 1 root   root      44 févr. 12 07:51 htpasswd.users
-rw-rw-r-- 1 nagios nagios 45843 févr. 12 07:50 nagios.cfg
drwxrwxr-x 2 nagios nagios  4096 févr. 12 07:50 objects
-rw-rw---- 1 nagios nagios  1312 févr. 12 07:50 resource.cfg


And i just noticed that the commands.cfg is in the objects folder...

Code: Select all
root@nagios:/# ls -la /usr/local/nagios/etc/objects/
total 60
drwxrwxr-x 2 nagios nagios  4096 févr. 12 07:50 .
drwxrwxr-x 3 nagios nagios  4096 févr. 12 08:21 ..
-rw-rw-r-- 1 nagios nagios  6747 févr. 12 07:50 commands.cfg
-rw-rw-r-- 1 nagios nagios  1797 févr. 12 07:50 contacts.cfg
-rw-rw-r-- 1 nagios nagios  4777 févr. 12 07:50 localhost.cfg
-rw-rw-r-- 1 nagios nagios  3001 févr. 12 07:50 printer.cfg
-rw-rw-r-- 1 nagios nagios  3484 févr. 12 07:50 switch.cfg
-rw-rw-r-- 1 nagios nagios 12533 févr. 12 07:50 templates.cfg
-rw-rw-r-- 1 nagios nagios  3512 févr. 12 07:50 timeperiods.cfg
-rw-rw-r-- 1 nagios nagios  4074 févr. 12 07:50 windows.cfg


So i don't know if this is the good one but i'm gonna make a snapshot and try like this...
quandary
 
Posts: 4
Joined: Mon Feb 11, 2019 10:55 am

Re: Basic nagios question

Postby npolovenko » Tue Feb 12, 2019 1:15 pm

@quandary, I installed Core on my Ubuntu and all configs are in the /usr/local/nagios/etc/objects/ folder(you're right), so you need to add the command to the /usr/local/nagios/etc/objects/commands.cfg file.

You can add:
define command {
command_name check_ncpa
command_line $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
}

At the bottom of the file.

Let me know how it goes.

Don't forget to create another ncpa.cfg file in the /usr/local/nagios/etc/objects/ folder and put the following definitions inside.
define host {
host_name SRV-AADC
address 192.168.70.28
check_command check_ncpa!-t '' -P 5693 -M system/agent_version
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
contacts nagiosadmin
notification_interval 60
notification_period 24x7
notifications_enabled 1
icon_image ncpa.png
statusmap_image ncpa.png
register 1
}

define service {
host_name SRV-AADC
service_description CPU Usage
check_command check_ncpa!-t '' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contacts nagiosadmin
register 1
}
define service {
host_name SRV-AADC
service_description CPU Usage
check_command check_ncpa!-t '' -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg'
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contacts nagiosadmin
register 1
}

define service {
host_name SRV-AADC
service_description Memory Usage
check_command check_ncpa!-t '' -P 5693 -M memory/virtual -w 50 -c 80 -u G
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contacts nagiosadmin
register 1
}

define service {
host_name SRV-AADC
service_description Process Count
check_command check_ncpa!-t '' -P 5693 -M processes -w 150 -c 200
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contacts nagiosadmin
register 1
}
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
npolovenko
Support Tech
 
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Basic nagios question

Postby quandary » Wed Feb 13, 2019 8:59 am

Yusss,

It works! As Apache love to say

I did what u said and more now that i have understood a bit how it works.

I discovered and tested the embedded Hyper-v Nagios XI test platform and it's way more simple, as my CEO? prefer easy things, so if i leave another guy will be able to handle... We probably gonna purchase NXI but I'm glad cuz I understood how it works and this is priceless when you get errors, also i'm curious too.

I'm really thankful for the help, my language may have shocked some apparently and i apologize if it is the case but that wasnt meant to be aggressive in any way. Not sure of my spelling tho' :x

Anyway thanks u @npolovenko for you light

PS : Again sorry if i disrespected english spelling but i learnt by talking to people and reading IT docs :3
quandary
 
Posts: 4
Joined: Mon Feb 11, 2019 10:55 am

Re: Basic nagios question

Postby npolovenko » Wed Feb 13, 2019 12:19 pm

@quandary, Allways welcome! :D I will close this thread as resolved but feel free to open a new one if something else comes up!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
npolovenko
Support Tech
 
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm


Return to Nagios Core

Who is online

Users browsing this forum: JoaoLoriato and 43 guests