====== 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 [[http://git.nagiosprojects.org/?p=ndo2fs.git|git.nagiosprojects.org]].
\\
[[http://git.nagiosprojects.org/?p=ndo2fs.git;a=snapshot;h=0.2.1|GIT Snapshot ndo2fs-0.2.1]]\\
[[http://git.nagiosprojects.org/?p=ndo2fs.git;a=snapshot;h=refs/heads/master|GIT Snapshot Head]]\\
\\
The [[http://www.nagvis.org|NagVis]] developers Lars Michelsen and Michael Lübben as well as the [[http://www.my-plugin.de/wiki/de/projects/check_multi/start|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 [[http://packages.debian.org/de/lenny/libjson-xs-perl|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 "[[http://www.json.org|JavaScript Object Notation]]" but don't panic, there are enough easy to use parsers.
Example using PHP5:
===== 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 will be used.
==== VOLATILE ====
Below of VOLATILE/default/ there will be the data of the instance .
* **default**
* **HOSTS** # directory for host/service state and config
* **** # directory per host
* //CONFIG// # config
* //STATUS// # current state
* **** # directory per service
* //CONFIG// # config
* //STATUS// # state
* **HOSTGROUPS**
* ****
* //META// # meta information regarding the hostgroup
* **SERVICEGROUPS**
* ****
* //META//
* **CONTACTGROUPS**
* ****
* //META// # meta information regarding the contactgroup
* ____ # a symlink to the appropriate contact for each member of the group
* **CONTACTS**
* //// # one file per contact
* **HOSTAUTH**
* //// # Array of services a contact is authorized for.
* **SERVICEAUTH**
* //// # Array of host and services a contact is authorized for.
* **HOSTSTATE**
* **** # directory per state ( UP,DOWN,UNREACHABLE )
* ****
* __STATUS__ # symlink on the STATE file of the host
* **SERVICESTATE**
* **** # directory per state ( OK,WARNING,CRITICAL,UNKNOWN )
* ****
* ****
* __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
* //// # each downtime in a separate file. The file name is the downtime ID
* **COMMENTS**
* //// # each comment in a separate file. The file name is the comment ID
* //::// # each comment in a separate file. The file name consists of host name and service description
* **LOGS**
* //YYYYMMDD.log// # One logfile per day.