Localhost Settings
-
nickanderson1982
- Posts: 72
- Joined: Wed Feb 06, 2019 3:22 pm
Localhost Settings
I can setup for all my servers except for local nagios server. How would I monitor the following items on the local server?
define host {
host_name XXXXXX
address 172.24.x.x
check_command check_ncpa!-t xxxxx -P 5693 -M system/agent_version
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
contact_groups admins communication
notification_interval 60
notification_period 24x7
notifications_enabled 1
icon_image ncpa.png
statusmap_image ncpa.png
register 1
}
define service {
host_name xxxxxxxx
service_description CPU Usage
check_command check_ncpa!-t xxxxxxx -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
contact_groups admins communication
register 1
}
define service {
host_name xxxxxxx
service_description Memory Usage
check_command check_ncpa!-t xxxxxxxx -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
contact_groups admins communication
register 1
}
define service {
host_name xxxxxxxxxxx
service_description Event Processor [Test]
check_command check_ncpa!-t xxxxxx -P 5693 -M 'services' -q 'service=Event Processor [Test],status=running'
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contact_groups admins
register 1
}
define host {
host_name XXXXXX
address 172.24.x.x
check_command check_ncpa!-t xxxxx -P 5693 -M system/agent_version
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
contact_groups admins communication
notification_interval 60
notification_period 24x7
notifications_enabled 1
icon_image ncpa.png
statusmap_image ncpa.png
register 1
}
define service {
host_name xxxxxxxx
service_description CPU Usage
check_command check_ncpa!-t xxxxxxx -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
contact_groups admins communication
register 1
}
define service {
host_name xxxxxxx
service_description Memory Usage
check_command check_ncpa!-t xxxxxxxx -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
contact_groups admins communication
register 1
}
define service {
host_name xxxxxxxxxxx
service_description Event Processor [Test]
check_command check_ncpa!-t xxxxxx -P 5693 -M 'services' -q 'service=Event Processor [Test],status=running'
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contact_groups admins
register 1
}
Re: Localhost Settings
What isn't working exactly? I imported the config and besides having to make sure that the host_name in all the definitions are the same and configuring the address line to use localhost instead of 172.24.x.x , this loaded okay for me. Is NCPA installed on the localhost?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
nickanderson1982
- Posts: 72
- Joined: Wed Feb 06, 2019 3:22 pm
Re: Localhost Settings
I tested out the following:
define service {
host_name localhost
service_description CPU Usage
check_command check_ncpa!-t xxxxxxx -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
contact_groups admins communication
register 1
}
In the Nagios GUI I get the following:
UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
What would I need to change to make the cpu check work?
define service {
host_name localhost
service_description CPU Usage
check_command check_ncpa!-t xxxxxxx -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
contact_groups admins communication
register 1
}
In the Nagios GUI I get the following:
UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
What would I need to change to make the cpu check work?
Re: Localhost Settings
That definition looks good. Is NCPA installed and running on the system that is running Nagios? Does the NCPA interface come up when you browse to https://<IPAddress>:5693
What do you get when you go to the command line and run,
What do you get when you go to the command line and run,
Code: Select all
/usr/local/nagios/libexec/check_ncpa.py -H <IPAddress> -t <NCPAToken> -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg' -vAs 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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
nickanderson1982
- Posts: 72
- Joined: Wed Feb 06, 2019 3:22 pm
Re: Localhost Settings
So you have to install NCPA on the local host that is running Nagios?
-
nickanderson1982
- Posts: 72
- Joined: Wed Feb 06, 2019 3:22 pm
Re: Localhost Settings
I went and installed NCPA on the localhost that runs Nagios.
rpm -Uvh https://repo.nagios.com/nagios/8/nagios ... noarch.rpm
yum install ncpa -y
Edit the NCPA Configuration
/usr/local/ncpa/etc/ncpa.cfg
change the community_string = xxxxx (used our token)
After saving the change, restart the NCPA listener service:
/etc/init.d/ncpa_listener restart
Added the following edit to the localhost.cfg:
define service {
host_name localhost
service_description CPU Usage
check_command check_ncpa!-t xxxxxxx -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
contact_groups admins communication
register 1
}
define service {
host_name localhost
service_description Memory Usage
check_command check_ncpa!-t xxxxxx -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
contact_groups admins communication
register 1
}
define service {
host_name localhost
service_description Wazuh
check_command check_ncpa!-t xxxxxxx -P 5693 -M 'services' -q 'service=wazuh-agent.service,status=running'
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contact_groups admins
register 1
}
------------
The results were not good.
All the new services are unknown: UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
/usr/local/nagios/libexec/check_ncpa.py -H 172.24.xx.xx -t xxxxxxx -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg' -v
Connecting to: https://172.24.xx.xx:5693/api/cpu/perce ... regate=avg
An error occurred:<urlopen error [Errno 111] Connection refused>
Shouldn't I be editing the localhost.cfg in a different manner? How would I check for cpu, memory and disk? I'm confused as to what to do for the localhost running nagios
rpm -Uvh https://repo.nagios.com/nagios/8/nagios ... noarch.rpm
yum install ncpa -y
Edit the NCPA Configuration
/usr/local/ncpa/etc/ncpa.cfg
change the community_string = xxxxx (used our token)
After saving the change, restart the NCPA listener service:
/etc/init.d/ncpa_listener restart
Added the following edit to the localhost.cfg:
define service {
host_name localhost
service_description CPU Usage
check_command check_ncpa!-t xxxxxxx -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
contact_groups admins communication
register 1
}
define service {
host_name localhost
service_description Memory Usage
check_command check_ncpa!-t xxxxxx -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
contact_groups admins communication
register 1
}
define service {
host_name localhost
service_description Wazuh
check_command check_ncpa!-t xxxxxxx -P 5693 -M 'services' -q 'service=wazuh-agent.service,status=running'
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contact_groups admins
register 1
}
------------
The results were not good.
All the new services are unknown: UNKNOWN: Error occurred while running the plugin. Use the verbose flag for more details.
/usr/local/nagios/libexec/check_ncpa.py -H 172.24.xx.xx -t xxxxxxx -P 5693 -M cpu/percent -w 20 -c 40 -q 'aggregate=avg' -v
Connecting to: https://172.24.xx.xx:5693/api/cpu/perce ... regate=avg
An error occurred:<urlopen error [Errno 111] Connection refused>
Shouldn't I be editing the localhost.cfg in a different manner? How would I check for cpu, memory and disk? I'm confused as to what to do for the localhost running nagios
-
nickanderson1982
- Posts: 72
- Joined: Wed Feb 06, 2019 3:22 pm
Re: Localhost Settings
Does anyone know how I am supposed to configure the localhost file for the linux server that runs nagios? What would be the syntax to monitor the cpu, mem and harddrive locally?
Re: Localhost Settings
Apologies for the delay in response.
Okay, so there was a misunderstanding. I didn't see that the host you were trying to monitor was the localhost that runs Nagios. NCPA is an agent that allows Nagios to talk to a remote server.
To monitor the machine that is running Nagios, you can use the plugins that are already installed locally. If you check the /usr/local/nagios/etc/objects/commands.cfg file, you should see some commands defined, and the definition shows you how to use them in your localhost.cfg file. For example,
commands.cfg
localhost.cfg
The check_command launches the check_ping command defined in commands.cfg, and then we have 2 arguments separated by !. Looking at the commands.cfg definition, you can see that the argument 100.0,20% is used for the -w flag (in almost every plugin, this will be your warning threshold flag), and then 500.0,60% is used for the -c flag (in almost every plugin, this is the critical threshold flag).
If you want to know what potential values or flags could be used, you can find all of the plugins at /usr/local/nagios/libexec/. So you can run /usr/local/nagios/libexec/check_ping --help and find out how to use the plugin.
More information can be had at the following link. I highly recommend keeping this link handy, especially the Object Definitions section, as Nagios configuration files can be pretty overwhelming.
https://assets.nagios.com/downloads/nag ... n/toc.html
Okay, so there was a misunderstanding. I didn't see that the host you were trying to monitor was the localhost that runs Nagios. NCPA is an agent that allows Nagios to talk to a remote server.
To monitor the machine that is running Nagios, you can use the plugins that are already installed locally. If you check the /usr/local/nagios/etc/objects/commands.cfg file, you should see some commands defined, and the definition shows you how to use them in your localhost.cfg file. For example,
commands.cfg
Code: Select all
define command {
command_name check_ping
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}Code: Select all
define service {
host_name localhost
service_description PING
use local-service
check_command check_ping!100.0,20%!500.0,60%
register 1
}If you want to know what potential values or flags could be used, you can find all of the plugins at /usr/local/nagios/libexec/. So you can run /usr/local/nagios/libexec/check_ping --help and find out how to use the plugin.
More information can be had at the following link. I highly recommend keeping this link handy, especially the Object Definitions section, as Nagios configuration files can be pretty overwhelming.
https://assets.nagios.com/downloads/nag ... n/toc.html
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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
nickanderson1982
- Posts: 72
- Joined: Wed Feb 06, 2019 3:22 pm
Re: Localhost Settings
I just reviewed the file. Nothing stands out for me to setup memory, cpu and hard drive checks. How would I manually set those up in the commands.cfg?
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Localhost Settings
Just taking a step backwards. There's nothing wrong with using NCPA installed on the Nagios Server to monitor it, doing it this way saves re-inventing the wheel.
https://assets.nagios.com/downloads/ncp ... g-NCPA.pdf
I suspect you simply need to add a firewall rule to your Nagios server to allow 5693 to connect, even though it is a local connection. Check page 15 of this guide that has firewall port opening commands:nickanderson1982 wrote:An error occurred:<urlopen error [Errno 111] Connection refused>
https://assets.nagios.com/downloads/ncp ... g-NCPA.pdf
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.