Page 1 of 1

Nagios core 3.4.1 and pnp4nagios 0.6

Posted: Fri Jun 12, 2015 6:41 am
by 00_kl250
Hi All,

I was up late last night trying to get nagios to work with pnp4nagios 0.6 in sync mode. I'm stuck at a dead end and need some help.

I have a debian 7.3 box that I installed nagios from package. Agt-get nagios3 install, etc, and pnp4nagios from package too. Nagios web interface is up and running and all looks well but when I click on the graph button I get the following error:


"PNP4Nagios Version 0.6.16
Please check the documentation for information about the following error.

perfdata directory "/var/lib/pnp4nagios/perfdata/localhost" for host "localhost" does not exist. Read FAQ online

file [line]:

application/models/data.php [148]:

back"

Here is the perl check script:

PNP4Nagios Version 0.6.16
Please check the documentation for information about the following error.

perfdata directory "/var/lib/pnp4nagios/perfdata/localhost" for host "localhost" does not exist. Read FAQ online

file [line]:

application/models/data.php [148]:

back

***Note that nagios and pnp4nagios are install in the /etc/nagios3 and /etc/pnp4nagios because installing from package and not the standard /usr/local/nagios when compiled and installed from source.

Here is my perl check script:

root@centreon-test:/tmp# perl verify_pnp_config --mode sync --config=/etc/nagios3/nagios.cfg --pnpcfg=/etc/pnp4nagios

[INFO] ========== Starting Environment Checks ============
[INFO] My version is: verify_pnp_config-0.6.25-R.40
[INFO] Start Options: verify_pnp_config --mode sync --config=/etc/nagios3/nagios.cfg --pnpcfg=/etc/pnp4nagios
[INFO] Reading /etc/nagios3/nagios.cfg
[OK ] Running product is 'nagios'
[OK ] object_cache_file is defined
[OK ] object_cache_file=/var/cache/nagios3/objects.cache
[INFO] Reading /var/cache/nagios3/objects.cache
[OK ] resource_file is defined
[OK ] resource_file=/etc/nagios3/resource.cfg
[INFO] Reading /etc/nagios3/resource.cfg
[INFO] Reading /etc/pnp4nagios/process_perfdata.cfg
[INFO] Reading /etc/pnp4nagios/pnp4nagios_release
[OK ] Found PNP4Nagios version "0.6.16"
[OK ] Effective User is 'nagios'
[OK ] User nagios exists with ID '104'
[OK ] Effective group is 'nagios'
[OK ] Group nagios exists with ID '106'
[INFO] ========== Checking Sync Mode Config ============
[OK ] process_performance_data is 1 compared with '/1/'
[OK ] enable_environment_macros is 1 compared with '/1/'
[CRIT] service_perfdata_command is not defined
[CRIT] host_perfdata_command is not defined
[HINT] Needed config options are missing. (2)

I thought I've updated my commands.cfg file correctly:

################################################################################
# NOTIFICATION COMMANDS
################################################################################


# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}


################### added by AK for pnp4nagios#######################

define command{
command_name process-host-perfdata-file
command_line /usr/bin/perl /usr/lib/pnp4nagios/libexec/process_perfdata.pl
}
define command{
command_name process-service-perfdata-file
command_line /usr/bin/perl /usr/lib/pnp4nagios/libexec/process_perfdata.pl
}


################################################################################
# HOST CHECK COMMANDS
################################################################################

# On Debian, check-host-alive is being defined from within the
# nagios-plugins-basic package

################################################################################
# PERFORMANCE DATA COMMANDS
################################################################################


# 'process-host-perfdata' command definition
define command{
command_name process-host-perfdata
command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /var/lib/pnp4nagios/host-perfdata.out
}


# 'process-service-perfdata' command definition
define command{
command_name process-service-perfdata
command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /var/lib/pnp4nagios/service-perfdata.out
}

Any help would be greatly appreciated!

Re: Nagios core 3.4.1 and pnp4nagios 0.6

Posted: Fri Jun 12, 2015 9:20 am
by 00_kl250
So in my nagios.cfg file I made the following changes:

uncommented the following lines:

host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata


Now i run my perl check and get:


root@centreon-test:/tmp# perl verify_pnp_config --mode sync --config=/etc/nagios3/nagios.cfg --pnpcfg=/etc/pnp4nagios
[INFO] ========== Starting Environment Checks ============
[INFO] My version is: verify_pnp_config-0.6.25-R.40
[INFO] Start Options: verify_pnp_config --mode sync --config=/etc/nagios3/nagios.cfg --pnpcfg=/etc/pnp4nagios
[INFO] Reading /etc/nagios3/nagios.cfg
[OK ] Running product is 'nagios'
[OK ] object_cache_file is defined
[OK ] object_cache_file=/var/cache/nagios3/objects.cache
[INFO] Reading /var/cache/nagios3/objects.cache
[OK ] resource_file is defined
[OK ] resource_file=/etc/nagios3/resource.cfg
[INFO] Reading /etc/nagios3/resource.cfg
[INFO] Reading /etc/pnp4nagios/process_perfdata.cfg
[INFO] Reading /etc/pnp4nagios/pnp4nagios_release
[OK ] Found PNP4Nagios version "0.6.16"
[OK ] Effective User is 'nagios'
[OK ] User nagios exists with ID '104'
[OK ] Effective group is 'nagios'
[OK ] Group nagios exists with ID '106'
[INFO] ========== Checking Sync Mode Config ============
[OK ] process_performance_data is 1 compared with '/1/'
[OK ] enable_environment_macros is 1 compared with '/1/'
[OK ] service_perfdata_command is defined
[OK ] service_perfdata_command=process-service-perfdata
[OK ] host_perfdata_command is defined
[OK ] host_perfdata_command=process-host-perfdata
[CRIT] service_perfdata_file is defined (service_perfdata_file=/var/lib/pnp4nagios/service-perfdata)
[CRIT] service_perfdata_file is not allowed in mode 'sync'
[CRIT] service_perfdata_file_template is defined (service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXEC UTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SE RVICEPERFDATA$)
[CRIT] service_perfdata_file_template is not allowed in mode 'sync'
[CRIT] service_perfdata_file_mode is defined (service_perfdata_file_mode=a)
[CRIT] service_perfdata_file_mode is not allowed in mode 'sync'
[CRIT] service_perfdata_file_processing_interval is defined (service_perfdata_file_processing_interval=0)
[CRIT] service_perfdata_file_processing_interval is not allowed in mode 'sync'
[CRIT] service_perfdata_file_processing_command is defined (service_perfdata_file_processing_command=process-service-perfdata-file)
[CRIT] service_perfdata_file_processing_command is not allowed in mode 'sync'
[CRIT] host_perfdata_file is defined (host_perfdata_file=/var/lib/pnp4nagios/host-perfdata)
[CRIT] host_perfdata_file is not allowed in mode 'sync'
[CRIT] host_perfdata_file_template is defined (host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTO UTPUT$\t$HOSTPERFDATA$)
[CRIT] host_perfdata_file_template is not allowed in mode 'sync'
[CRIT] host_perfdata_file_mode is defined (host_perfdata_file_mode=a)
[CRIT] host_perfdata_file_mode is not allowed in mode 'sync'
[CRIT] host_perfdata_file_processing_interval is defined (host_perfdata_file_processing_interval=0)
[CRIT] host_perfdata_file_processing_interval is not allowed in mode 'sync'
[CRIT] host_perfdata_file_processing_command is defined (host_perfdata_file_processing_command=process-host-perfdata-file)
[CRIT] host_perfdata_file_processing_command is not allowed in mode 'sync'
[HINT] Config options are not allowed in sync mode. http://docs.pnp4nagios.org (10)

Re: Nagios core 3.4.1 and pnp4nagios 0.6

Posted: Fri Jun 12, 2015 9:51 am
by 00_kl250
Ok made some changes to my nagios.cfg file:

now when i run my check script

root@centreon-test:/tmp# perl verify_pnp_config --mode sync --config=/etc/nagios3/nagios.cfg --pnpcfg=/etc/pnp4nagios
[INFO] ========== Starting Environment Checks ============
[INFO] My version is: verify_pnp_config-0.6.25-R.40
[INFO] Start Options: verify_pnp_config --mode sync --config=/etc/nagios3/nagios.cfg --pnpcfg=/etc/pnp4nagios
[INFO] Reading /etc/nagios3/nagios.cfg
[OK ] Running product is 'nagios'
[OK ] object_cache_file is defined
[OK ] object_cache_file=/var/cache/nagios3/objects.cache
[INFO] Reading /var/cache/nagios3/objects.cache
[OK ] resource_file is defined
[OK ] resource_file=/etc/nagios3/resource.cfg
[INFO] Reading /etc/nagios3/resource.cfg
[INFO] Reading /etc/pnp4nagios/process_perfdata.cfg
[INFO] Reading /etc/pnp4nagios/pnp4nagios_release
[OK ] Found PNP4Nagios version "0.6.16"
[OK ] Effective User is 'nagios'
[OK ] User nagios exists with ID '104'
[OK ] Effective group is 'nagios'
[OK ] Group nagios exists with ID '106'
[INFO] ========== Checking Sync Mode Config ============
[OK ] process_performance_data is 1 compared with '/1/'
[OK ] enable_environment_macros is 1 compared with '/1/'
[OK ] service_perfdata_command is defined
[OK ] service_perfdata_command=process-service-perfdata
[OK ] host_perfdata_command is defined
[OK ] host_perfdata_command=process-host-perfdata
[INFO] Nagios config looks good so far
[INFO] ========== Checking config values ============
service_perfdata_command at verify_pnp_config line 462.
[CRIT] Command process-service-perfdata is not defined

Re: Nagios core 3.4.1 and pnp4nagios 0.6

Posted: Fri Jun 12, 2015 10:47 am
by lmiltchev
Have you modified the "process-host-perfdata" and "process-service-perfdata" commands according to the pnp4nagios documentation?

https://docs.pnp4nagios.org/pnp-0.6/config

Code: Select all

define command {
       command_name    process-service-perfdata
       command_line    /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl
}

define command {
       command_name    process-host-perfdata
       command_line    /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
FYI, I saw "root@centreon-test" in your posts... Are you using "Centreon"? This is a Nagios support forum. If you are using "Centreon", you will have to post your question on their support forum.

Re: Nagios core 3.4.1 and pnp4nagios 0.6

Posted: Tue Jun 16, 2015 2:59 pm
by 00_kl250
Thanks, yes centreon is just the name of my machine. I was testing centreon but have decided to go straight on with just nagios.

I'm good to go now but thanks for the response. Now the fun part of getting my monitored data into graphs :)

Re: Nagios core 3.4.1 and pnp4nagios 0.6

Posted: Tue Jun 16, 2015 3:11 pm
by abrist
Great! Locking thread. Have a good one!