Page 3 of 3

Re: check_snmp return value with performance graph

Posted: Wed Feb 06, 2019 1:54 pm
by tgriep
The letter "c" on the output of the plugin lets the system know that the data is a counter.
There is a formula that counter data gets processed through and what you are seeing is rounding errors from that formula and is causing the graph to not display correctly.

To fix the issue, you have to create a template and a new command that will use the template.

The graph template that should fix the graphing issue with monitoring counters with the check_snmp plugin is attached to the post.
Here is how to install it.

In Core Config Manager
Create a copy of the check_snmp command and call it check_snmp_gauge

Edit the Command Name to check_snmp_gauge

Code: Select all

define command {
       command_name                  		check_snmp_gauge
       command_line                  		$USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
}
Then edit the service check to use the check_snmp_gauge command like below

Code: Select all

define service {
	host_name			xxx.xxx.xxx.xxx
	service_description		Test SNMP
	check_command			check_snmp_gauge! -P 2c -C public -o  1.3.6.1.2.1.4.31.1.1.35.1 -w 100 -c 110 -l test!!!!!!!
	max_check_attempts		5
	check_interval			5
	retry_interval			1
	check_period			xi_timeperiod_24x7
	notification_interval		60
	notification_period		xi_timeperiod_24x7
	contacts			nagiosadmin
	register			1
	}
The graph template is called check_snmp_gauge.cfg and it needs to be uploaded to this folder in the XI system /usr/local/nagios/etc/pnp/check_commands/

Code: Select all

/usr/local/nagios/etc/pnp/check_commands/check_snmp_gauge.cfg

Changed the permissions of the check_snmp_gauge.cfg file to the following

Code: Select all

chown apache.nagios check_snmp_gauge.cfg
chmod 666 check_snmp_gauge.cfg
Delete the .rrd and .xml files for that service. They are in this folder under the hostname

Code: Select all

/usr/local/nagios/share/perfdata/<HostName>/
After 15 minutes, the graph should be populated with the data.

Re: check_snmp return value with performance graph

Posted: Thu Feb 07, 2019 10:50 am
by bongbi
Thanks. I take that attached file is the check_snmp_gauge.cfg file?

Re: check_snmp return value with performance graph

Posted: Thu Feb 07, 2019 1:16 pm
by tgriep
Yes, it is the cfg file, sorry about that too many similar files.

Re: check_snmp return value with performance graph

Posted: Thu Feb 07, 2019 2:11 pm
by bongbi
Thanks.

I have followed all instruction that you suggested and still facing same issue. Have I miss any step?

Code: Select all

[root@nagiosxi check_commands]# pwd
/usr/local/nagios/etc/pnp/check_commands
[root@nagiosxi check_commands]# ls -al
total 16
drwxrwxr-x 2 apache nagios 4096 Feb  7 10:22 .
drwxrwxr-x 4 apache nagios 4096 Jan  7 15:45 ..
-rw-rw-r-- 1 apache nagios  755 Feb 19  2016 check_nwstat.cfg-sample
-rw-rw-rw- 1 apache nagios  749 Feb  7 10:22 check_snmp_gauge.cfg
[root@nagiosxi check_commands]# cat check_snmp_gauge.cfg
#
# Adapt the Template if check_command should not be the PNP Template
#
# check_command check_nwstat!LOAD5!80%!90%
# ________0__________|         |    |  |
# ________1____________________|    |  |
# ________2_________________________|  |
# ________3____________________________|
#
CUSTOM_TEMPLATE = 0,1
#
# Change the RRD Datatype based on the check_command Name.
# Defaults to GAUGE.
#
# Adjust the whole RRD Database
DATATYPE = GAUGE
#
# Adjust every single DS by using a List of Datatypes.
# DATATYPE = GAUGE,GAUGE,COUNTER,COUNTER
#
# Use the MIN value for newly created RRD Databases.
# This value defaults to 0
# USE_MIN_ON_CREATE = 1
#
# Use the MAX value for newly created RRD Databases.
# This value defaults to 0
# USE_MAX_ON_CREATE = 1
[root@nagiosxi check_commands]# cat /usr/local/nagios/etc/static/services.cfg
define service {
    host_name                nutanix-traf-ahv.internal
    service_description      clusterIops
    check_command            check_snmp_gauge! -o .1.3.6.1.4.1.41263.506.0 -P 3 --seclevel=authPriv --secname=nagios --authproto=sha --authpasswd='*' --privpasswd='*' --privproto=aes!!!!!!!
    max_check_attempts       5
    check_interval           5
    retry_interval           1
    check_period             xi_timeperiod_24x7
    notification_interval    60
    notification_period      xi_timeperiod_24x7
    contact_groups           admins
    register                 1
}

Re: check_snmp return value with performance graph

Posted: Fri Feb 08, 2019 10:01 am
by tgriep
Take a look in the /usr/local/nagios/var/perfdata.log file to see if the check is using the template.

You probably have to increase the log level to see that entry so edit this file.

Code: Select all

/usr/local/nagios/etc/pnp/process_perfdata.cfg
Change the following entry to the example below.

Code: Select all

LOG_LEVEL = 2
Restart nagios and npcd on the system and let the check run a few times and then check the log file to see if it is using the pnp template.
Also, make sure you delete the .xml and .rrd file for that service so it can be rebuilt.

Re: check_snmp return value with performance graph

Posted: Mon Feb 11, 2019 10:01 am
by bongbi
Looks like it does not use template.

Code: Select all

2019-02-11 09:33:38 [109320] [1] Found Performance Data for nutanix-traf-ahv.internal / clusterIops (iso.3.6.1.4.1.41263.506.0=146c)
2019-02-11 09:33:38 [109320] [2] Adapting Template using ARG 0,1
2019-02-11 09:33:38 [109320] [2] Adapting Template to check_snmp_gauge.php (added ARG0)
2019-02-11 09:33:38 [109320] [2] Adapting Template to check_snmp_gauge_-o .1.3.6.1.4.1.41263.506.0 -P 3 --seclevel=authPriv --secname=nagios --authproto=sha --authpasswd='5p1cpUKq' --privpasswd='5p1cpUKq' --privproto=aes.php (added ARG1)
2019-02-11 09:33:38 [109320] [2] Adapting Template to check_snmp_gauge_-o .1.3.6.1.4.1.41263.506.0 -P 3 --seclevel=authPriv --secname=nagios --authproto=sha --authpasswd='5p1cpUKq' --privpasswd='5p1cpUKq' --privproto=aes.php as defined in /usr/local/nagios/etc/pnp/check_commands/check_snmp_gauge.cfg
2019-02-11 09:33:38 [109320] [2] Adapting RRD Datatype to "GAUGE" as defined in /usr/local/nagios/etc/pnp/check_commands/check_snmp_gauge.cfg with key 0
2019-02-11 09:33:38 [109320] [2] Template is check_snmp_gauge_-o .1.3.6.1.4.1.41263.506.0 -P 3 --seclevel=authPriv --secname=nagios --authproto=sha --authpasswd='5p1cpUKq' --privpasswd='5p1cpUKq' --privproto=aes.php
2019-02-11 09:33:38 [109320] [2] No Custom Template found for check_snmp_gauge_-o_.1.3.6.1.4.1.41263.506.0_-P_3_--seclevel=authPriv_--secname=nagios_--authproto=sha_--authpasswd='5p1cpUKq'_--privpasswd='5p1cpUKq'_--privproto=aes (/usr/local/nagios/etc/pnp/check_commands/check_snmp_gauge_-o_.1.3.6.1.4.1.41263.506.0_-P_3_--seclevel=authPriv_--secname=nagios_--authproto=sha_--authpasswd='5p1cpUKq'_--privpasswd='5p1cpUKq'_--privproto=aes.cfg)
2019-02-11 09:33:38 [109320] [2] Template is check_snmp_gauge_-o_.1.3.6.1.4.1.41263.506.0_-P_3_--seclevel=authPriv_--secname=nagios_--authproto=sha_--authpasswd='5p1cpUKq'_--privpasswd='5p1cpUKq'_--privproto=aes.php

Re: check_snmp return value with performance graph

Posted: Mon Feb 11, 2019 4:18 pm
by tgriep
Edit the template

Code: Select all

/usr/local/nagios/etc/pnp/check_commands/check_snmp_gauge.cfg
Change this line from

Code: Select all

CUSTOM_TEMPLATE = 0,1
to

Code: Select all

#CUSTOM_TEMPLATE = 0,1
Save it out.

Then run this to make a copy of it as a php file in the templates folder.

Code: Select all

cp /usr/local/nagios/etc/pnp/check_commands/check_snmp_gauge.cfg /usr/local/nagios/share/pnp/templates/check_snmp_gauge.php
Delete the .xml and .rrd files and see if this resolves the issue.

Re: check_snmp return value with performance graph

Posted: Fri Feb 15, 2019 9:05 am
by bongbi
Thanks! That fixed issue nicely.

Thanks for great support :)

Re: check_snmp return value with performance graph

Posted: Fri Feb 15, 2019 1:13 pm
by tgriep
I am glad it is working now. I'll close and lock the post as solved. Feel free to open a new post for any questions.