ndo2fs

WORK IN PROGRESS

ndo2fs originated as a debugger for ndomod.o. It takes data from ndomod.o either via a TCP or a UNIX socket. The aim of ndo2fs is to save the nagios data in a structured way using the file system. We kept in mind that the data has to be processed in an easy way.

In addition I'm working on a PHP class to access the data of ndo2fs. For more information read ndo2fs-php.

Mode of operation

ndo2fs works like ndo2db but in contrast to ndo2db it is written in Perl and saves the data on the file system. That's about all.

Download

The current version can be found in the GIT Repository under git.nagiosprojects.org.

Current GIT Repository Snapshots:


The NagVis developers Lars Michelsen and Michael Lübben as well as the check_multi developer Matthias Flacke provide valuable input right now.

In case of questions please send a mail to pitchfork@pnp4nagios.org

Installation

None yet! It's just a single Perl script.

Since version 0.1.13 the Perl module JSON::XS is needed to create the JSON files. Unfortunately the module is available as a package starting with Debian Lenny. Users of Debian Etch have to install it via CPAN typing

perl -MCPAN -e install JSON::XS

ndomod data_processing_options

The data processed by ndomod can be minimized using the directive “data_processing_options” defined in ndomod.cfg as ndo2fs will only use a part of the data.

              PROCESS_PROCESS_DATA  1
        PROCESS_SERVICE_CHECK_DATA  64
           PROCESS_HOST_CHECK_DATA  128
              PROCESS_COMMENT_DATA  256
             PROCESS_DOWNTIME_DATA  512
       PROCESS_PROGRAM_STATUS_DATA  2048
          PROCESS_HOST_STATUS_DATA  4096
       PROCESS_SERVICE_STATUS_DATA  8192
        PROCESS_OBJECT_CONFIG_DATA  262144
          PROCESS_MAIN_CONFIG_DATA  524288
            PROCESS_RETENTION_DATA  2097152
      PROCESS_ACKNOWLEDGEMENT_DATA  4194304
          PROCESS_STATECHANGE_DATA  8388608
       PROCESS_CONTACT_STATUS_DATA  16777216

which adds up to

          data_processing_options = 32259009

TODO

  • Daemon Code
  • Checks
  • Code cleanup

Performance

1.4m lines equate to 10 min on my production system

 wc -l ndo.dat 
 1406535 ndo.dat

This data I passed to ndo2fs via NetCat

time cat ndo.dat | nc -q1 -n 127.0.0.1 5668

real	0m19.561s
user	0m0.004s
sys	0m0.064s

This results in 67 MB of data in the ndo2fs directory

du -s -h /tmp/ndo2fs
67M	/tmp/ndo2fs

The measurements were taken from a Debian 4 VM on my Macbook Pro.

Data format

The data is stored in JSON format on the file system. JSON is short for ”JavaScript Object Notation” but don't panic, there are enough easy to use parsers.

Example using PHP5:

<?php
$in = '/tmp/ndo2fs/VOLATILE/HOSTS/localhost/http/STATUS';
$data = file_get_contents($in);
$out = json_decode($data);
var_dump($out);
?>

Data structure

Taking /tmp/ndo2fs as a base directory you'll find two sub directories after the start of ndo2fs.

  • ndo2fs
    • VOLATILE
    • PERSISTENT

The directory VOLATILE contains (what a surprise) volatile data which is created at the start of nagios. That means that VOLATILE can be stored on a TMPFS. PERSISTENT contains data which is created during runtime of nagios and will be kept across restarts.

The nagios instance forms the next level. For each nagios instance there will be a directory with the appropriate name. In the following the instance <default> will be used.

VOLATILE

Below of VOLATILE/default/ there will be the data of the instance <default>.

  • default
    • HOSTS # directory for host/service state and config
      • <hostname> # directory per host
        • CONFIG # config
        • STATUS # current state
        • <servicedesc> # directory per service
          • CONFIG # config
          • STATUS # state
    • HOSTGROUPS
      • <hostgroupname>
        • META # meta information regarding the hostgroup
    • SERVICEGROUPS
      • <servicegroupname>
        • META
    • CONTACTGROUPS
      • <contactgroupname>
        • META # meta information regarding the contactgroup
        • <contact> # a symlink to the appropriate contact for each member of the group
    • CONTACTS
      • <contactname> # one file per contact
    • HOSTAUTH
      • <contact> # Array of services a contact is authorized for.
    • SERVICEAUTH
      • <contact> # Array of host and services a contact is authorized for.
  • HOSTSTATE
    • <state> # directory per state ( UP,DOWN,UNREACHABLE )
      • <hostname>
        • STATUS # symlink on the STATE file of the host
  • SERVICESTATE
    • <state> # directory per state ( OK,WARNING,CRITICAL,UNKNOWN )
      • <hostname>
        • <servicedesc>
          • STATUS # symlink on the STATE file of the service
  • VIEWS
    • HOSTLIST # list of all hosts
    • SERVICELIST # list of all services
    • PARENTLIST # list of the parent relations between hosts

PERSISTENT

Below of PERSISTENT/default/ there will be data which is collected during nagios runtime and kept across restarts

  • default
    • DOWNTIMES # directory for each host/service state and config
      • <downtimeid> # each downtime in a separate file. The file name is the downtime ID
    • COMMENTS
      • <commentid> # each comment in a separate file. The file name is the comment ID
      • <host>::<service> # each comment in a separate file. The file name consists of host name and service description
    • LOGS
      • YYYYMMDD.log # One logfile per day.
ndo2fs/start.txt · Last modified: 2009/04/23 18:01 by linge
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0