Skip to end of metadata
Go to start of metadata

Workflow

The image below displays RRA create/update workflow.    Download Workflow Image

Parse Performance Data

Example plugin output string and what n2rrd extracts

  • n2rrdunderstands nagios performance data format

    label=value[UOM];[warning-range];[critical-range];[min];[max]
  • nagios-plugin check_http output :
    HTTP OK: HTTP/1.1 200 OK - 46869 bytes in 0.294 second response time | time=0.294561s;;;0 size=46869B;;;0
    Status string:

    HTTP OK: HTTP/1.1 200 OK - 46869 bytes in 0.294 second response time
    

    Performance data:

    time=0.294561s;;;0 size=46869B;;;0
  • n2rrd extracts:
    time:

    time=0.294561 UOM=s min=0

    size:

    size=46869 UOM=B min=0

    at least one pair like 'name=value' must exist.

Round Robin Archive Create/Update

RRA Template

N2RRD searches for a template to create an archive

This Page gives an example how you can configure N2RRD

we take commonly used service example
Network Ping (check_icmp).

Round Robin Archive Template

Example 1, configure service "check_icmp"

  • create an template /etc/n2rrd/templates/rra/icmp.t

    -s 300 # 5minutes
    DS:rta:GAUGE:600:0:U
    DS:pl:GAUGE:600:0:U
    RRA:AVERAGE:0.5:1:1440 #days
    RRA:AVERAGE:0.5:30:336 # weeks
    RRA:AVERAGE:0.5:120:360 # months
    RRA:AVERAGE:0.5:1440:365 # year
    RRA:MAX:0.5:1:1440
    RRA:MAX:0.5:30:336
    RRA:MAX:0.5:120:360
    RRA:MAX:0.5:1440:365
    RRA:MIN:0.5:1:1440
    RRA:MIN:0.5:30:336
    RRA:MIN:0.5:120:360
    RRA:MIN:0.5:1440:365
  • now define service check_icmp

    define service{
         use                     generic-service   ; assumed that you have define a generic template with this name
         host_name               www.example.com   ; change this to appropriate server name
         service_description     check_icmp        ; STRING can be anything, here important is '_icmp'
         check_command           check_icmp
    }

NOTE: I assume that generic-service template is defined or you are using the default one

Example 2, map service check

_Nagios service description = "Physical memory" and mapped to mem for n2rrd

  • edit service maps file "/etc/n2rrd/templates/maps/service_name_maps" and add following line:

    Physical memory: men
  • create a template "/etc/n2rrd/templates/rra/mem.t"

    -s 300 # 5minutes
    DS:used:GAUGE:600:0:U
    DS:free:GAUGE:600:0:U
    RRA:AVERAGE:0.5:1:1440   #day
    RRA:AVERAGE:0.5:30:336   #week
    RRA:AVERAGE:0.5:120:360  #month
    RRA:AVERAGE:0.5:1440:365 #year
    RRA:MAX:0.5:1:1440   #day
    RRA:MAX:0.5:30:336   #week
    RRA:MAX:0.5:120:360  #month
    RRA:MAX:0.5:1440:365 #year
    RRA:MIN:0.5:1:1440   #day
    RRA:MIN:0.5:30:336   #week
    RRA:MIN:0.5:120:360  #month
    RRA:MIN:0.5:1440:365 #year
    
  • now define service for "Physical memory"

    define service{
                use                     generic-service         ; Name of service template to use
                host_name               localhost
                service_description     Physical memory         ; maps to template '/etc/n2rrd/templates/rra/mem.t'
                check_command           check_mem!3000!1000     ; with warning and critical limits
            }
    

in case you for some reason need to use one template with different names,e.g. eth for eth0 eth1, eth2, hme0 etc_ _then just symlink it to eth

Modify non standard performance data

  • you have a possibility to evaluate this yourself and return the values in following string format

    ds_name=ds_value [ds_name=ds_value|ds_name=ds_value] ..
  • an example perl code for service "Physical memory", which as we know from above is mapped to "mem"

    my $tmp_pdata = "";
    
    #
    # the following Environment variable is passed by Nagios, see nagios Doc. for more info
    if ( $ENV{NAGIOS_SERVICEPERFDATA} ) {
    $tmp_pdata = $ENV{NAGIOS_SERVICEPERFDATA};
    }
    
    # OR you can pass performance data passed to n2rrd.pl with option \-o  "$HOSTPERFDATA$"
    if ($opt->{o}) {
          ................
          }
    
    # choice is yours
    
    ...
    # process $tmp_pdata, to create string
    # used=4096 free=1024
    #
    ...
    return $tmp_pdata;
    
  • first n2rrd looks for external code in "/etc/n2rrd/templates/code"
    by following search order in n2rrd.pl:
    1) /etc/n2rrd/templates/code/HOSTNAME_SERVICE.pl
    2) /etc/n2rrd/templates/code/SERVICE.pl

e.g service name = "mem" and hostname = "localhost"
1) /etc/n2rrd/templates/code/localhost_mem.pl
2) /etc/n2rrd/templates/code/mem.pl
if the above perl code exists, then n2rrd will not parse the string, instead expect a string from external perl code as mentioned above.

check nagios configuration

  • nagios -v /etc/nagios/nagios.cfg

reload nagios

/etc/init.d/nagios reload
   OR
kill \-HUP `cat /var/run/nagios.pid`

check logfile for progress

  • if necessary fix errors.

Example log file lines with debug mode enabled

  • system load and DS name rewrite

    Host = localhost, Service name = Current Load_load, Check result = load1=0.000;5.000;10.000;0; load5=0.000;4.000;6.000;0; load15=0.000;3.000;4.000;0;
    Filtered ds_names: load_1min:load_5min:load_15min, ds_values: 0.000:0.000:0.000
    
  • Physical memory check, with service name mapping

    Host = localhost, Service name = Physical memory, Check result = used= free=51780
    Searching map in file "/etc/nagios/templates/service_name_maps" for service "Physical memory"
    Filtered ds_names: used:free, ds_values: :51780
    

check if RRAs are generated in the right place

  • ls -l /var/log/nagios/rra (may be you have choosen another place)

template search order

if exists file
    TEMPLATES_DIR/rra/HOSTNAME_SERVICE_NAME.t
    # use it
else if exists
    TEMPLATES_DIR/rra/SERVICE_NAME.t
# use it

Tools

Parse Performance Data

  • No labels