Own Custom Graphs

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
gmikhailov
Posts: 9
Joined: Wed Aug 27, 2014 4:17 am

Own Custom Graphs

Post by gmikhailov »

Hello All.
I would like to make my own custom graph based on nagios bandwidth.
What I did:
1. I created new command "testddos" - a little modified script "check_iftraffic64.pl" -
2. I did php file /usr/local/nagios/share/pnp/templates/testddos.php

Code: Select all

<?php
$opt[1] = " --vertical-label \"Traffic\" -b 1024 --title \"Interface Traffic for $hostname / $servicedesc\" ";
$def[1] .= "DEF:var1=$rrdfile:$DS[3]:AVERAGE " ;
$def[1] .= "DEF:var2=$rrdfile:$DS[4]:AVERAGE " ;
$def[1] .= "CDEF:real1=var1,1,* " ;
$def[1] .= "CDEF:real2=var2,1,* " ;
$def[1] .= "LINE1:real1#003300:\"in  \" " ;
$def[1] .= "GPRINT:real1:LAST:\"%7.2lf %Sb/s last\" " ;
$def[1] .= "GPRINT:real1:AVERAGE:\"%7.2lf %Sb/s avg\" " ;
$def[1] .= "GPRINT:real1:MAX:\"%7.2lf %Sb/s max\\n\" " ;
$def[1] .= "LINE1:real2#00ff00:\"out  \" " ;
$def[1] .= "GPRINT:real2:LAST:\"%7.2lf %Sb/s last\" " ;
$def[1] .= "GPRINT:real2:AVERAGE:\"%7.2lf %Sb/s avg\" " ;
$def[1] .= "GPRINT:real2:MAX:\"%7.2lf %Sb/s max\" " ;
?>
I want to make outgoing and incoming graph on one DS.

3. I checked rrd

Code: Select all

[root@nagiosz1s1 templates]# rrdtool fetch /usr/local/nagios/share/perfdata/Physical_Channel_MTC_DC_-_DefaultGateway/DDoS_test_check.rrd MAX -r 900 -s -40m (the service name is DDoS_test_check)
                              1                   2                   3                   4                   5                   6

1450682100: 1.1840833333e+01 3.1644833333e+01 1.4799666667e+01 3.9554000000e+01 2.2009716738e+14 7.5071175382e+14
1450682400: 1.1626777778e+01 2.9877166667e+01 1.4532666667e+01 3.7348555556e+01 2.2010230553e+14 7.5072584746e+14
1450682700: 1.2420888889e+01 3.2276000000e+01 1.5522555556e+01 4.0341444444e+01 2.2010491426e+14 7.5073275182e+14
1450683000: 1.2565333333e+01 3.2276000000e+01 1.5714666667e+01 4.0341444444e+01 2.2011028184e+14 7.5074636538e+14
1450683300: 1.4450000000e+01 3.2095555556e+01 1.8065555556e+01 4.0123333333e+01 2.2011613044e+14 7.5076022776e+14
1450683600: 1.4450000000e+01 3.2863000000e+01 1.8065555556e+01 4.1086000000e+01 2.2011905492e+14 7.5076730196e+14
1450683900: 1.4554666667e+01 3.2863000000e+01 1.8193111111e+01 4.1086000000e+01 2.2012484636e+14 7.5078098827e+14
1450684200: 1.2579166667e+01 3.1745000000e+01 1.5724166667e+01 3.9680833333e+01 2.2013035888e+14 7.5079476328e+14
1450684500: -nan -nan -nan -nan -nan -nan
It looks OK.

4. I checked xml

Code: Select all

[root@nagiosz1s1 Physical_Channel_MTC_DC_-_DefaultGateway]# cat DDoS_test_check.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<NAGIOS>
  <DATASOURCE>
    <TEMPLATE>testddos</TEMPLATE>
    <IS_MULTI>0</IS_MULTI>
    <DS>1</DS>
    <NAME>inUsage</NAME>
    <UNIT>%%</UNIT>
    <ACT>13.94</ACT>
    <WARN>50</WARN>
    <WARN_MIN></WARN_MIN>
    <WARN_MAX></WARN_MAX>
    <WARN_RANGE_TYPE></WARN_RANGE_TYPE>
    <CRIT>70</CRIT>
    <CRIT_MIN></CRIT_MIN>
    <CRIT_MAX></CRIT_MAX>
    <CRIT_RANGE_TYPE></CRIT_RANGE_TYPE>
    <MIN></MIN>
    <MAX></MAX>
  </DATASOURCE>
  <DATASOURCE>
    <TEMPLATE>testddos</TEMPLATE>
    <IS_MULTI>0</IS_MULTI>
    <DS>2</DS>
    <NAME>outUsage</NAME>
    <UNIT>%%</UNIT>
    <ACT>32.49</ACT>
    <WARN>58</WARN>
    <WARN_MIN></WARN_MIN>
    <WARN_MAX></WARN_MAX>
    <WARN_RANGE_TYPE></WARN_RANGE_TYPE>
    <CRIT>60</CRIT>
    <CRIT_MIN></CRIT_MIN>
    <CRIT_MAX></CRIT_MAX>
    <CRIT_RANGE_TYPE></CRIT_RANGE_TYPE>
    <MIN></MIN>
    <MAX></MAX>
  </DATASOURCE>
  <DATASOURCE>
    <TEMPLATE>testddos</TEMPLATE>
    <IS_MULTI>0</IS_MULTI>
    <DS>3</DS>
    <NAME>inBandwidth</NAME>
    <UNIT>MBs</UNIT>
    <ACT>17.43</ACT>
    <WARN></WARN>
    <WARN_MIN></WARN_MIN>
    <WARN_MAX></WARN_MAX>
    <WARN_RANGE_TYPE></WARN_RANGE_TYPE>
    <CRIT></CRIT>
    <CRIT_MIN></CRIT_MIN>
    <CRIT_MAX></CRIT_MAX>
    <CRIT_RANGE_TYPE></CRIT_RANGE_TYPE>
    <MIN></MIN>
    <MAX></MAX>
  </DATASOURCE>
  <DATASOURCE>
    <TEMPLATE>testddos</TEMPLATE>
    <IS_MULTI>0</IS_MULTI>
    <DS>4</DS>
    <NAME>outBandwidth</NAME>
    <UNIT>MBs</UNIT>
    <ACT>40.61</ACT>
    <WARN></WARN>
    <WARN_MIN></WARN_MIN>
    <WARN_MAX></WARN_MAX>
    <WARN_RANGE_TYPE></WARN_RANGE_TYPE>
    <CRIT></CRIT>
    <CRIT_MIN></CRIT_MIN>
    <CRIT_MAX></CRIT_MAX>
    <CRIT_RANGE_TYPE></CRIT_RANGE_TYPE>
    <MIN></MIN>
    <MAX></MAX>
  </DATASOURCE>
  <DATASOURCE>
    <TEMPLATE>testddos</TEMPLATE>
    <IS_MULTI>0</IS_MULTI>
    <DS>5</DS>
    <NAME>inAbsolut</NAME>
    <UNIT>B</UNIT>
    <ACT>220145553418137</ACT>
    <WARN></WARN>
    <WARN_MIN></WARN_MIN>
    <WARN_MAX></WARN_MAX>
    <WARN_RANGE_TYPE></WARN_RANGE_TYPE>
    <CRIT></CRIT>
    <CRIT_MIN></CRIT_MIN>
    <CRIT_MAX></CRIT_MAX>
    <CRIT_RANGE_TYPE></CRIT_RANGE_TYPE>
    <MIN></MIN>
    <MAX></MAX>
  </DATASOURCE>
  <DATASOURCE>
    <TEMPLATE>testddos</TEMPLATE>
    <IS_MULTI>0</IS_MULTI>
    <DS>6</DS>
    <NAME>outAbsolut</NAME>
    <UNIT>B</UNIT>
    <ACT>750831769447502</ACT>
    <WARN></WARN>
    <WARN_MIN></WARN_MIN>
    <WARN_MAX></WARN_MAX>
    <WARN_RANGE_TYPE></WARN_RANGE_TYPE>
    <CRIT></CRIT>
    <CRIT_MIN></CRIT_MIN>
    <CRIT_MAX></CRIT_MAX>
    <CRIT_RANGE_TYPE></CRIT_RANGE_TYPE>
    <MIN></MIN>
    <MAX></MAX>
  </DATASOURCE>
  <RRD>
    <RC>0</RC>
    <TXT>successful updated</TXT>
  </RRD>
  <NAGIOS_CHECK_COMMAND>testddos!!!!!!!!</NAGIOS_CHECK_COMMAND>
  <NAGIOS_DATATYPE>SERVICEPERFDATA</NAGIOS_DATATYPE>
  <NAGIOS_DISP_HOSTNAME>Physical Channel MTC DC - DefaultGateway</NAGIOS_DISP_HOSTNAME>
  <NAGIOS_DISP_SERVICEDESC>DDoS test check</NAGIOS_DISP_SERVICEDESC>
  <NAGIOS_HOSTNAME>Physical_Channel_MTC_DC_-_DefaultGateway</NAGIOS_HOSTNAME>
  <NAGIOS_HOSTSTATE>UP</NAGIOS_HOSTSTATE>
  <NAGIOS_HOSTSTATETYPE>HARD</NAGIOS_HOSTSTATETYPE>
  <NAGIOS_MULTI_PARENT></NAGIOS_MULTI_PARENT>
  <NAGIOS_PERFDATA>inUsage=13.94%;50;70 outUsage=32.49%;58;60 inBandwidth=17.43MBs outBandwidth=40.61MBs inAbsolut=220145553418137B outAbsolut=750831769447502B </NAGIOS_PERFDATA>
  <NAGIOS_RRDFILE>/usr/local/nagios/share/perfdata/Physical_Channel_MTC_DC_-_DefaultGateway/DDoS_test_check.rrd</NAGIOS_RRDFILE>
  <NAGIOS_SERVICECHECKCOMMAND>testddos!!!!!!!!</NAGIOS_SERVICECHECKCOMMAND>
  <NAGIOS_SERVICEDESC>DDoS_test_check</NAGIOS_SERVICEDESC>
  <NAGIOS_SERVICEOUTPUT>OK - Average IN: 17.43MBs (13.94%), Average OUT: 40.61MBs (32.49%)%3cbr%3eTotal RX: 220145.55GBytes, Total TX: 750831.77GBytes</NAGIOS_SERVICEOUTPUT>
  <NAGIOS_SERVICEPERFDATA>inUsage=13.94%;50;70 outUsage=32.49%;58;60 inBandwidth=17.43MBs outBandwidth=40.61MBs inAbsolut=220145553418137B outAbsolut=750831769447502B</NAGIOS_SERVICEPERFDATA>
  <NAGIOS_SERVICESTATE>OK</NAGIOS_SERVICESTATE>
  <NAGIOS_SERVICESTATETYPE>HARD</NAGIOS_SERVICESTATETYPE>
  <NAGIOS_TIMET>1450685224</NAGIOS_TIMET>
  <NAGIOS_XMLFILE>/usr/local/nagios/share/perfdata/Physical_Channel_MTC_DC_-_DefaultGateway/DDoS_test_check.xml</NAGIOS_XMLFILE>
</NAGIOS>
It looks fine too.

But graph doesn`t draw (screenshot in attachment).

Please write, where I made mistake.
Thank You.
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Own Custom Graphs

Post by rkennedy »

Can you also post a screenshot of the 'Advanced' tab for us to take a look at as well?
Former Nagios Employee
gmikhailov
Posts: 9
Joined: Wed Aug 27, 2014 4:17 am

Re: Own Custom Graphs

Post by gmikhailov »

Hi, rkennedy
The screenshot of the 'Advanced' tab in attachment.
I would like to combine 2 graphs in one - inBandwidth and outBandwidth. ([3] [4] in php file).
You do not have the required permissions to view the files attached to this post.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Own Custom Graphs

Post by Box293 »

From my experience, this can be frustrating to diagnose.

The problem is most likely in your template file.

I would do two things:
1)

Code: Select all

tail -f /var/log/httpd/error_log
This should report any coding errors.

2)
Make the php template as basic as possible. Start off with just the heading line and comment everything else out.
Once doing that, does it work?
If yes, then uncomment the next line and repeat.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
gmikhailov
Posts: 9
Joined: Wed Aug 27, 2014 4:17 am

Re: Own Custom Graphs

Post by gmikhailov »

@ Box293
1. There are no any mistakes in log file.
2. Of course the mistake in template. I think, that my template is very simple and it must work.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Own Custom Graphs

Post by Box293 »

gmikhailov wrote:2. Of course the mistake in template. I think, that my template is very simple and it must work.
I understand, but 1 line is more simple than 13. It just takes one mistake to make it break.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
gmikhailov
Posts: 9
Joined: Wed Aug 27, 2014 4:17 am

Re: Own Custom Graphs

Post by gmikhailov »

Box293 wrote: I understand, but 1 line is more simple than 13. It just takes one mistake to make it break.
OK, I`ll try to check template by your recommendation.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Own Custom Graphs

Post by rkennedy »

Sounds good, let us know if you need further assistance.
Former Nagios Employee
gmikhailov
Posts: 9
Joined: Wed Aug 27, 2014 4:17 am

Re: Own Custom Graphs

Post by gmikhailov »

Hello all.
I have solved this problem.
Of course, mistake was in syntax of php file.
Thanx to all for help.
Merry Christmas.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Own Custom Graphs

Post by tmcdonald »

I'll be closing this thread now, but feel free to open another if you need anything in the future!
Former Nagios employee
Locked