Skip to end of metadata
Go to start of metadata

rrd2graph installation/configuration

Workflow

The following image displays RRD2GRAPH workflow.   Download Workflow Image

edit rrd2graph.cgi and change following variables

my $conf_file = "/etc/n2rrd/n2rrd.conf";
my $debug = 0;

cp rrd2graph.cgi to your cgi-bin directory

  • cp rrd2graph.cgi /srv/www/vhosts/www.example.com/cgi-bin
  • chmod 755 /srv/www/vhosts/www.example.com/cgi-bin/rrd2graph.cgi

Edit n2rrd.conf and change the following values appropriately

DOCUMENT_ROOT = /srv/www/vhosts/www.example.com/html
CACHE_DIR = rrd_images_cache
# Thus generated graphs will be stored in directory DOCUMENT_ROOT/CACHE_DIR

Create graph templates

  • create graph template "/etc/n2rrd/templates/graph/mem.t" for "Physical memory"

    --imgformat=PNG
    --lazy
    --title="$HOSTNAME$ - Memory Usage"
    --base=1024
    --height=200
    --width=500
    --alt-autoscale-max
    --lower-limit=0
    --vertical-label=GBytes
    --slope-mode
    DEF:a="$RRD_FILENAME$":used:AVERAGE
    DEF:b="$RRD_FILENAME$":free:AVERAGE
    CDEF:cdefa=a,1024,*
    CDEF:cdefb=b,1024,*
    AREA:cdefa#FF3932:"Used"
    AREA:cdefb#35962B:"Free\n":STACK
    
  • create graph template "/etc/n2rrd/templates/graph/icmp.t" for "icmp"

    #
    # $HOSTNAME$ will be replaced with hostname being checked
    # $RRD_FILENAME$ will be replace with real rrd filename
    # well nothing is stopping you from adding values from other rrd file, then you have
    # to explicitly give the file names
    #
    
    # Title
    -t "$HOSTNAME$ - ICMP RTA"
    
    # Vertical label
    -v "Time in ms"
    
    #
    # Height and Width
    --height="120"
    --width="440"
    
    --slope-mode
    #
    # Define canvas and frame colors
    -c "BACK#00000F"
    -c "SHADEA#"
    -c "SHADEB#"
    -c "FONT#F7F7F7"
    -c "CANVAS#2E2E2E"
    -c "GRID#7F7F7F"
    -c "MGRID#B8B8B8"
    -c "FRAME#2E2E2E"
    -c "ARROW#FFFFFF"
    #
    # define atleast one DEF
    "DEF:icmp_rta=$RRD_FILENAME$:rta:AVERAGE"
    "DEF:icmp_pl=$RRD_FILENAME$:AVERAGE"
    "CDEF:icmp_pl_neg=icmp_pl,-1,*"
    "GPRINT:icmp_rta:LAST:Current\: %5.2lf ms"
    "GPRINT:icmp_rta:MIN:Min\: %5.2lf ms"
    "GPRINT:icmp_rta:MAX:Max\: %5.2lf ms"
    "GPRINT:icmp_rta:AVERAGE:Avg\: %5.2lf ms\n"
    "GPRINT:icmp_pl:LAST:Current\: %5.2lf ms"
    "GPRINT:icmp_pl:MIN:Min\: %5.2lf ms"
    "GPRINT:icmp_pl:MAX:Max\: %5.2lf ms"
    "GPRINT:icmp_pl:AVERAGE:Avg\: %5.2lf ms\n"
    "COMMENT:\n"
    "COMMENT:$CDATE"
    
    #
    # Define CDEF with grading colors, order is top down
    #
    "CDEF:g_color2=icmp_rta,0.98,*" "AREA:g_color2#00FF00:Round Trip Average Time"
    "CDEF:g_color10=icmp_rta,0.90,*" "AREA:g_color10#00FF00"
    "CDEF:g_color15=icmp_rta,0.85,*" "AREA:g_color15#00F200"
    "CDEF:g_color20=icmp_rta,0.80,*" "AREA:g_color20#00E500"
    "CDEF:g_color25=icmp_rta,0.75,*" "AREA:g_color25#00D900"
    "CDEF:g_color30=icmp_rta,0.70,*" "AREA:g_color30#00CC00"
    "CDEF:g_color35=icmp_rta,0.65,*" "AREA:g_color35#00BF00"
    "CDEF:g_color40=icmp_rta,0.60,*" "AREA:g_color40#00B200"
    "CDEF:g_color45=icmp_rta,0.55,*" "AREA:g_color45#00A600"
    "CDEF:g_color50=icmp_rta,0.50,*" "AREA:g_color50#"
    "CDEF:g_color55=icmp_rta,0.45,*" "AREA:g_color55#008C00"
    "CDEF:g_color60=icmp_rta,0.40,*" "AREA:g_color60#007F00"
    "CDEF:g_color65=icmp_rta,0.35,*" "AREA:g_color65#"
    "CDEF:g_color70=icmp_rta,0.30,*" "AREA:g_color70#"
    "CDEF:g_color75=icmp_rta,0.25,*" "AREA:g_color75#"
    "CDEF:g_color80=icmp_rta,0.20,*" "AREA:g_color80#004C00"
    "CDEF:g_color85=icmp_rta,0.15,*" "AREA:g_color85#"
    #
    # Negated packet loss
    "CDEF:g_pl_color2=icmp_pl_neg,0.98,*" "AREA:g_pl_color2#FF0000:Percent Packet Loss"
    "CDEF:g_pl_color10=icmp_pl_neg,0.90,*" "AREA:g_pl_color10#FF0000"
    "CDEF:g_pl_color15=icmp_pl_neg,0.85,*" "AREA:g_pl_color15#F20000"
    "CDEF:g_pl_color20=icmp_pl_neg,0.80,*" "AREA:g_pl_color20#E50000"
    "CDEF:g_pl_color25=icmp_pl_neg,0.75,*" "AREA:g_pl_color25#D90000"
    "CDEF:g_pl_color30=icmp_pl_neg,0.70,*" "AREA:g_pl_color30#CC0000"
    "CDEF:g_pl_color35=icmp_pl_neg,0.65,*" "AREA:g_pl_color35#BF0000"
    "CDEF:g_pl_color40=icmp_pl_neg,0.60,*" "AREA:g_pl_color40#B20000"
    "CDEF:g_pl_color45=icmp_pl_neg,0.55,*" "AREA:g_pl_color45#A60000"
    "CDEF:g_pl_color50=icmp_pl_neg,0.50,*" "AREA:g_pl_color50#"
    "CDEF:g_pl_color55=icmp_pl_neg,0.45,*" "AREA:g_pl_color55#8C0000"
    "CDEF:g_pl_color60=icmp_pl_neg,0.40,*" "AREA:g_pl_color60#7F0000"
    "CDEF:g_pl_color65=icmp_pl_neg,0.35,*" "AREA:g_pl_color65#"
    "CDEF:g_pl_color70=icmp_pl_neg,0.30,*" "AREA:g_pl_color70#"
    "CDEF:g_pl_color75=icmp_pl_neg,0.25,*" "AREA:g_pl_color75#"
    "CDEF:g_pl_color80=icmp_pl_neg,0.20,*" "AREA:g_pl_color80#4C0000"
    "CDEF:g_pl_color85=icmp_pl_neg,0.15,*" "AREA:g_pl_color85#"
    

    an Example output:

Edit nagios configuration file serviceextinfo.cfg

  • check_icmp

    define serviceextinfo{
          host_name               www.example.com
          service_description     check_icmp
          notes_url               http://YOUR_WEBSERVER_NAME/cgi-bin/rrd2graph.cgi?hostname=$HOSTNAME$&service=$SERVICEDESC$
     }
    
  • Physical memory

    define serviceextinfo{
             host_name               localhost
             service_description     Physical memory
             notes_url               http://YOUR_WEBSERVER_NAME/cgi-bin/rrd2graph.cgi?hostname=$HOSTNAME$&service=$SERVICEDESC$
        }
    

    (3.x users)_above mentioned notes_url and action_url are part of host and service definition attributes,
    which basically means you don't have to maintain another configuration file.

Reload Nagios

  • Now you would see icons near service description, click on it to see the graph

if DYN_RRA_CREATE is enabled

  • dynamically crated RRA templates are kept under "*/templates/rra/dyn"
  • dynamically created GRAPH templates are kept under "*/template/graph/dyn"

Enable or Disable Summary All link in graphs


Use config option in n2rrd.conf GRAPH_SUMMARY_ALL_LINK = 0/1

Enable or Diable DS Summary All links in graph


Use config option in n2rrd.conf DS_SUMMARY_ALL_LINK = 0/1

Create rounded corners with CSS and RRD graph template

apart from rrd2graph.css, you need to make changes to

Sample RRD graph template entry (icmp.t)

.............
#
# Define canvas and frame colors
--color=BACK#CDCDCD
--color=SHADEA#CDCDCD
--color=SHADEB#CDCDCD
--color=FONT#585858
--color=CANVAS#F0F1F5
--color=GRID#8D8D8D
--color=MGRID#B8B8B8
--color=ARROW#FF0000
............

/usr/share/nagios/stylesheets/*.css entries

also depends on web frontend you are using

grep CDCDCD stylesheets/*
stylesheets/avail.css:background-color: #CDCDCD;
stylesheets/cmd.css:background-color: #CDCDCD;
stylesheets/config.css:background-color: #CDCDCD;
stylesheets/extinfo.css:background-color: #CDCDCD;
stylesheets/histogram.css:background-color: #CDCDCD;
stylesheets/history.css:background-color: #CDCDCD;
stylesheets/notifications.css:background-color: #CDCDCD;
stylesheets/outages.css:background-color: #CDCDCD;
stylesheets/showlog.css:background-color: #CDCDCD;
stylesheets/status.css:.status { font-family: Tahoma, Arial, Sans-Serif;background-color: #CDCDCD;color: #3F3D3D;font-size: 8pt;
stylesheets/statusmap.css:background-color: #CDCDCD;
stylesheets/summary.css:background-color: #CDCDCD;
stylesheets/tac.css:background-color: #CDCDCD;
stylesheets/trends.css:background-color: #CDCDCD;

Other hints

  • In Nagios 3.x you can disable EPN through configuration enable_embedded_perl=<0/1>

TIPS

  1. starting 1.4.0, if you eable option DYN_RRD_CREATE, then you can avoid creating RRA/GRAPH templates and once you see all performance data are created, then you can decide if you like to create custome RRA/GRAPH templates.
  2. I use two different generic templates for services, this way you can avoid maintaining seperate file for notes_url.

    # without perfomace data
    define service{
        name                            generic-service-no-perf ; no performance data gathered or required
        active_checks_enabled           1       ; Active service checks are enabled
        passive_checks_enabled          1       ; Passive service checks are enabled/accepted
        obsess_over_service             1       ; We should obsess over this service (if necessary)
        check_freshness                 0       ; Default is to NOT check service 'freshness'
        notifications_enabled           1       ; Service notifications are enabled
        event_handler_enabled           1       ; Service event handler is enabled
        flap_detection_enabled          1       ; Flap detection is enabled
        failure_prediction_enabled      1       ; Failure prediction is enabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    1       ; Retain non-status information across program restarts
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }
    
    #
    # with perfomace data
    define service{
        name                            generic-service ; If performance data is gathered
        active_checks_enabled           1       ; Active service checks are enabled
        passive_checks_enabled          1       ; Passive service checks are enabled/accepted
        obsess_over_service             1       ; We should obsess over this service (if necessary)
        check_freshness                 0       ; Default is to NOT check service 'freshness'
        notifications_enabled           1       ; Service notifications are enabled
        event_handler_enabled           1       ; Service event handler is enabled
        flap_detection_enabled          1       ; Flap detection is enabled
        failure_prediction_enabled      1       ; Failure prediction is enabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    1       ; Retain non-status information across program restarts
        notes_url               /perl/rrd2graph.cgi?hostname=$HOSTNAME$&service=$SERVICEDESC$
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }
    

Known problems/issues

  • check n2rrd.pl and rrd2graph.cgi if they complain
    • perl -cw PATH/n2rrd.pl
    • perl -cw PATH/rrd2graph.cgi
  • check for file permissions
    • n2rdd.plruns with nagios user permissions:
      • can read/write RRA templates directory (normally under /etc/n2rrd/templates/rra)
      • can read status.log
      • can write to n2rrd.log
    • rrd2graph.cgiruns with webserver user permissions:
      • check that it can write to CACHE_DIR
      • can read status.log
      • can write to n2rrd.log
      • can read/write template/graph directory (normally under /etc/n2rrd/templates/graph)
  • In case you are not seeing Nagios environment variables, then could be that nagios is compiled with EPN (Embeded Perl)
    • Diable EPN see Nagios docs for details on EPN
    • In nagios 3.x a comment # nagios: -epn in your script should disable EPN.
  • n2rdd.pl/rrd2graph.cgi leaves deleted service files, which needs to be removed manually
    • alternatively you can add a cronjobto automatically remove unused rra files and cached images

      # assume
      # RRA_DIR = /var/log/n2rrd
      #
      # DOCUMENT_ROOT = /var/www/html
      # CACHE_DIR = n2rrd_images_cache
      # find RRA_DIR DOCUMENT_ROOT/CACHE_DIR -type f -mtime +30 -exec rm -f '{}' \;
      # mtime = is modification time
      # +30   = older than 30 days, change to what suits you
      find /var/log/n2rrd /var/www/html/n2rrd_images_cache -type f -mtime +30 -exec rm -f '{}' \;
      

comments to

monitoring @ diglinks.com

  • No labels