Page 1 of 1

Graphing Multiple Variables from Single Plugin

Posted: Fri Mar 29, 2019 11:58 am
by eholm
Hello All,

I've been writing my own Plugins for a while.
This is the first one where I'm trying to get it to graph multiple values on the same graph.

Here is the end of my plugin... where I prep the output.

Code: Select all

#---------- Step 3 ------------------------------------------------------------
# Format Output

    performanceData=""
    performanceData=$performanceData"'connections'=$NUM_CONNECTIONS;$WARNING_THRESHOLD;$CRITICAL_THRESHOLD;0;250 "
    performanceData=$performanceData"NECC'=$NUM_NECC;;;0;250 "
    performanceData=$performanceData"'Direct'=$NUM_DCS;;;0;250 "
    echo "Connections - $NUM_CONNECTIONS"
    echo " | $performanceData"
    exit $RESULT

#-- END
If I delete the 3rd and 4th performanceData lines I can get Connections to graph by itself.
However once I add the additional metrics... nothing graphs.

I get all of the "speedometers" for each of the three metrics.
I can see that Nagios is getting performance data in the Advanced tab.

Performance Data: 'connections'=2;100;200;0;250 'NECC'=0;;;0;250 'Direct'=1;;;0;250

All my other graphs work.
And there is a MySQL plugin someone else made. It has multiple metrics being tracked and my output is in the same format as theirs. That one graphs just fine.

I reviewed the documentation for plugin output. I believe I have everything right. Especially since I can get it to work with a single metric but not multiple. Searched online for answers for a bit and I'm at the end of my rope! Any help would be appreciated.

-- Eric

Re: Graphing Multiple Variables from Single Plugin

Posted: Fri Mar 29, 2019 1:35 pm
by npolovenko
Hello, @eholm. Your performance data output looks correct, but if you add data sources to the existing service check that's going to break the RRD graph. To fix that you can either delete the corresponding RRD and XML files from the /usr/local/nagios/var/spool/perfdata folder and let Nagios automatically create a new RRD file with the modified number of data sources.
Otherwise, if deleting the existing RRD file is not an option you may follow this article to increase the number of data sources:
https://support.nagios.com/kb/article.php?id=149

Re: Graphing Multiple Variables from Single Plugin

Posted: Mon Apr 01, 2019 7:10 am
by eholm
Removing the files for each server worked like a charm.
I had a feeling it was something like this.
Just didn't know where to look.

-- Eric

Re: Graphing Multiple Variables from Single Plugin

Posted: Mon Apr 01, 2019 8:02 am
by scottwilkerson
eholm wrote:Removing the files for each server worked like a charm.
I had a feeling it was something like this.
Just didn't know where to look.

-- Eric
Great!

Locking thread