ncpa - location and parameters

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.
Locked
seapro220
Posts: 11
Joined: Mon Oct 15, 2018 1:57 pm

ncpa - location and parameters

Post by seapro220 »

Hello.
I've the latest 4.x version of nagios and ubuntu 18.04.
i've got nagios up and running - and am also have some hosts working with 'default' pings. haven't gotten all the data from them yet - but ping is a good start - then on to gather/obtaining their snmp info next.

I'm trying to move on to monitor some windows servers to see what i can get.
i've downloaded the check_ncpa.pl file and got it added to the 'default' location. can i manually on the nagios core server run it to see if it's working ? I did the default install of the ncpa client and can open/see data on the https://localhost:5693 . pretty cool to see active info. i haven't set any passwords on it yet - just kept it simple for now.

I'm editing the commands.cfg file to add the 'define commands' by following the 'ncpa getting-started' document. as i'm new the working with linux configs i've found that case-sensitive is required in alot of areas - but also am trying to understand 'where' in specific parts of the .cfg files i should add things.
in the commands.cfg file there are several sections. whenever i 'add/insert' the 'define command' does it matter - or will whenever i run the command to 'check' - will it just 'find it there' - and process?

after i get a single machine running - i'll add other servers and start capturing all their data.
next - i'd like to graph some info - similiar to the solarwinds product that i'm currently using. i'm sure i'll open another query about 'which' is the better graphing tool so if you see this ticket and can offer some advice i can research - i'd appreciate it.

As I only have about 15 servers i'm going to configure the 'checks' to be active instead of passive - at least initially. the 'getting-started' document referrences that i should 'replace -t 'mytoken' with a my own token. where or what is this from - the server or host? how do i locate this info?

thanks in advance -
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: ncpa - location and parameters

Post by lmiltchev »

can i manually on the nagios core server run it to see if it's working ?
Yes, as with any other nagios plugin, you can run the plugin manually from the command line to see if it's working. For example, you could view the usage by running:

Code: Select all

# ./check_ncpa.py -h
Usage: check_ncpa.py [options]

Options:
  -h, --help            show this help message and exit
  -H HOSTNAME, --hostname=HOSTNAME
                        The hostname to be connected to.
  -M METRIC, --metric=METRIC
                        The metric to check, this is defined on client system.
                        This would also be the plugin name in the plugins
                        directory. Do not attach arguments to it, use the -a
                        directive for that. DO NOT INCLUDE the api/
                        instruction.
  -P PORT, --port=PORT  Port to use to connect to the client.
  -w WARNING, --warning=WARNING
                        Warning value to be passed for the check.
  -c CRITICAL, --critical=CRITICAL
                        Critical value to be passed for the check.
  -u UNITS, --units=UNITS
                        The unit prefix (k, Ki, M, Mi, G, Gi, T, Ti) for b and
                        B unit types which calculates the value returned.
  -n UNIT, --unit=UNIT  Overrides the unit with whatever unit you define. Does
                        not perform calculations. This changes the unit of
                        measurement only.
  -a ARGUMENTS, --arguments=ARGUMENTS
                        Arguments for the plugin to be run. Not necessary
                        unless you're running a custom plugin. Given in the
                        same as you would call from the command line. Example:
                        -a '-w 10 -c 20 -f /usr/local'
  -t TOKEN, --token=TOKEN
                        The token for connecting.
  -T TIMEOUT, --timeout=TIMEOUT
                        Enforced timeout, will terminate plugins after this
                        amount of seconds. [60]
  -d, --delta           Signals that this check is a delta check and a local
                        state will kept.
  -l, --list            List all values under a given node. Do not perform a
                        check.
  -v, --verbose         Print more verbose error messages.
  -D, --debug           Print LOTS of error messages. Used mostly for
                        debugging.
  -V, --version         Print version number of plugin.
  -q QUERYARGS, --queryargs=QUERYARGS
                        Extra query arguments to pass in the NCPA URL.
  -s, --secure          Require successful certificate verification. Does not
                        work on Python < 2.7.9.
  -p, --performance     Print performance data even when there is none. Will
                        print data matching the return code of this script
...whenever i 'add/insert' the 'define command' does it matter - or will whenever i run the command to 'check' - will it just 'find it there' - and process?
The order in which you enter the commands in the commands.cfg file doesn't really matter. As long as you have valid definitions, they will be all processed. Here's an example of a check_ncpa command that is defined in the commands.cfg file:

Code: Select all

define command {
    command_name    check_ncpa
    command_line    $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$
}
Your command may vary, depending on how you configure your stuff. This is just an example.
...the 'getting-started' document referrences that i should 'replace -t 'mytoken' with a my own token. where or what is this from - the server or host? how do i locate this info?
I am not sure where is the 'getting-started' document you are referring to, but here's the official NCPA documentation:

https://www.nagios.org/ncpa/help.php

The token is configured in the ncpa.cfg file on the client (remote machine), so you would need to modify it there:

Code: Select all

community_string = xxx
and restart the NCPA listener and passive services, so that changes can take effect.
Be sure to check out our Knowledgebase for helpful articles and solutions!
seapro220
Posts: 11
Joined: Mon Oct 15, 2018 1:57 pm

Re: ncpa - location and parameters

Post by seapro220 »

Thanks - I'll start reading and testing more.

I noticed that whenever I 'run' the ncpa.exe on my windows machine it brings up info asking about 'tokens'. I've looked at the documentation - https://www.nagios.org/ncpa/getting-started.php#windows which also talks about it but am not understanding if I'm supposed to enter something here - that is specific to the machine, or 'generic' across all my machines. If I do enter something there - and not leave it blank am I supposed to configure on the core side - something to 'match' that token?

I'm following the steps you mentioned above - but am having permission issues. i tried chown nagios:nagios check_ncpa.py and the user has ownership as well as group - but seems like the file is still not working. permissions for that file are -rw-w--r-- 1 other files there are -rwxr-xr-x 1 .

apologies but not really up to the whole chown and permissions yet. how to i fix this issue - chown 777 check_napa.py ??

----got the chown command done. chmod 746 check_ncpa.py fixed it for me. I'll continue on.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: ncpa - location and parameters

Post by lmiltchev »

When you are installing the NCPA agent on the client (remote machine), and you are asked about a token, you can enter whatever you want. A "token" is like a password. You will use it later, when you run your checks from the nagios server. For example, if you configured the agent with token = "welcome", you could run a check as such:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H x.x.x.x -P 5693 -t 'welcome' -M 'system/uptime'
OK: Uptime was 43 days 19 hours 44 minutes 37 seconds | 'uptime'=3786277.00s;;;
Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
seapro220
Posts: 11
Joined: Mon Oct 15, 2018 1:57 pm

Re: ncpa - location and parameters

Post by seapro220 »

ok - strange things here ..

i run this command -

/usr/local/nagios/libexec/check_ncpa.py -H x.x.x.x -P 5693 -t 'password' -M 'system/uptime' -v
i get results - days hours etc as being up.

i run the same command -

/usr/local/nagios/libexec/check_ncpa.py -H x.x.x.x -P 5693 -t 'password' -M 'memory/virtual' -v .... and get this error
connecting to host x.x.x.x/api/memory/virtual/?token=&check=1
error: incorrect credentials given.

same ip - password just a different parameter.

thoughts/suggestions? i'm looking at a windows server -
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: ncpa - location and parameters

Post by lmiltchev »

What did you mean by:
same ip - password just a different parameter.
- did you change the token?

If you change the token, you need to restart the NCPA Listener and NCPA Passive service on the Windows machine, so that changes can take effect...

It just doesn't make sense one check to work, and the other one - not work with the SAME token...
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked