The problem of XML file XXXX not found ing appears in pnp4nagios drawing

Keywords: Attribute sudo lsof

Write an article the other day using pnp4nagios draws for Nagios The article later found that some script images can not be drawn, the following to propose solutions.

Error phenomena:

Reasons for error:

This situation is mostly caused by the Nagios plug-ins written by ourselves. The pnp4nagios drawing must follow the specific information output format, otherwise it will not generate images.

This output format is

TEXT_OUTPUT_SEEN_ON_NAGIOS_WEB | label=value[UOM];[warn];[crit];[min];

Label = human readable name label for graphics
Value = Check the current value of the output value
UOM = unit of the Y-axis of the image
warn = Check the threshold of waring
crit = Check critical threshold
min = minimum value of image Y axis
Max = max of graph Y axis

All data after the pipeline (|) will be hidden in the Nagios Web GUI. These data are only applicable to Pnp4Nagios performance data graphics, which are not visible to Nagios Web GUI users. However, if you will run the Nagios Plugin Bash script locally from the command line on Nagios Client or Nagios Server, this data will be visible. Therefore, the alarm content output on the self-compiled plug-in should be output in accordance with this format, otherwise it will produce errors like this.

Solution:

The following is a check_open_files.sh instance script for reference

#!/bin/bash
# Nagios Plugin Bash Script - check_open_files.sh
# This script checks the number of currently opened files for the specified user with the specified WARNING and CRITICAL threshold
#
# Check for missing parameters
if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then
        echo "Missing parameters! Syntax: ./check_open_files.sh USER WARNING_THRESHOLD CRITICAL_THRESHOLD"
        exit 2
fi
# Check for number of currently opened files
ofiles=$(sudo /usr/sbin/lsof |grep $1 |grep REG |wc -l)
# Check if number of currently opened files is lower than WARNING threshold parameter
if [[ "$ofiles" -lt "$2" ]]; then
        echo "OK - Number of open files is $ofiles | NumOpenFiles=$ofiles;$2;$3;0;10000"
        exit 0
fi
# Check if number of currently opened files is greater than WARNING threshold parameter and lower than CRITICAL threshold parameter
if [[ "$ofiles" -gt "$2" ]] && [[ "$ofiles" -lt "$3" ]]; then
        echo "WARNING - Number of open files is $ofiles | NumOpenFiles=$ofiles;$2;$3;0;10000"
        exit 1
fi
# Check if number of currently opened files is greater than CRITICAL threshold parameter
if [[ "$ofiles" -gt "$3" ]]; then
        echo "CRITICAL - Number of open files is $ofiles | NumOpenFiles=$ofiles;$2;$3;0;10000"
        exit 2
fi

Posted by littlejay on Tue, 12 Feb 2019 05:27:17 -0800