Nagios-Object-0.21.20000755001750001750 012220262237 15451 5ustar00dfergusondferguson000000000000Nagios-Object-0.21.20/META.yml000444001750001750 341712220262237 17064 0ustar00dfergusondferguson000000000000--- abstract: 'Nagios::Object - Nagios object configuration parsing.' author: - 'Duncan Ferguson ' build_requires: Data::Dumper: 0.01 List::Compare: 0.37 Module::Build: 0.26 Scalar::Util: 0.01 Test::Exception: 0.01 Test::More: 0.01 Test::NoWarnings: 0.08 configure_requires: Module::Build: 0.40 dynamic_config: 1 generated_by: 'Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921' license: open_source meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Nagios-Object provides: Nagios::Config: file: lib/Nagios/Config.pm version: 36 Nagios::Config::File: file: lib/Nagios/Config/File.pm version: 35 Nagios::Host: file: lib/Nagios/Object.pm version: 0 Nagios::Host::Status: file: lib/Nagios/StatusLog.pm version: 0.1 Nagios::HostGroup: file: lib/Nagios/Object.pm version: 0 Nagios::Info::Status: file: lib/Nagios/StatusLog.pm version: 0.1 Nagios::Object: file: lib/Nagios/Object.pm version: 47 Nagios::Object::Config: file: lib/Nagios/Object/Config.pm version: 41 Nagios::Program::Status: file: lib/Nagios/StatusLog.pm version: 0.1 Nagios::Service: file: lib/Nagios/Object.pm version: 0 Nagios::Service::Status: file: lib/Nagios/StatusLog.pm version: 0.1 Nagios::ServiceGroup: file: lib/Nagios/Object.pm version: 0 Nagios::StatusLog: file: lib/Nagios/StatusLog.pm version: 45 requires: perl: v5.6.1 resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Nagios-Object homepage: http://github.com/duncs/perl-nagios-object license: http://www.gnu.org/licenses/old-licenses/gpl-1.0.txt repository: http://github.com/duncs/perl-nagios-object version: v0.21.20 Nagios-Object-0.21.20/META.json000444001750001750 550512220262237 17234 0ustar00dfergusondferguson000000000000{ "abstract" : "Nagios::Object - Nagios object configuration parsing.", "author" : [ "Duncan Ferguson " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921", "license" : [ "open_source" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Nagios-Object", "prereqs" : { "build" : { "requires" : { "Data::Dumper" : "0.01", "List::Compare" : "0.37", "Module::Build" : "0.26", "Scalar::Util" : "0.01", "Test::Exception" : "0.01", "Test::More" : "0.01", "Test::NoWarnings" : "0.08" } }, "configure" : { "requires" : { "Module::Build" : "0.40" } }, "runtime" : { "requires" : { "perl" : "v5.6.1" } } }, "provides" : { "Nagios::Config" : { "file" : "lib/Nagios/Config.pm", "version" : "36" }, "Nagios::Config::File" : { "file" : "lib/Nagios/Config/File.pm", "version" : "35" }, "Nagios::Host" : { "file" : "lib/Nagios/Object.pm", "version" : 0 }, "Nagios::Host::Status" : { "file" : "lib/Nagios/StatusLog.pm", "version" : "0.1" }, "Nagios::HostGroup" : { "file" : "lib/Nagios/Object.pm", "version" : 0 }, "Nagios::Info::Status" : { "file" : "lib/Nagios/StatusLog.pm", "version" : "0.1" }, "Nagios::Object" : { "file" : "lib/Nagios/Object.pm", "version" : "47" }, "Nagios::Object::Config" : { "file" : "lib/Nagios/Object/Config.pm", "version" : "41" }, "Nagios::Program::Status" : { "file" : "lib/Nagios/StatusLog.pm", "version" : "0.1" }, "Nagios::Service" : { "file" : "lib/Nagios/Object.pm", "version" : 0 }, "Nagios::Service::Status" : { "file" : "lib/Nagios/StatusLog.pm", "version" : "0.1" }, "Nagios::ServiceGroup" : { "file" : "lib/Nagios/Object.pm", "version" : 0 }, "Nagios::StatusLog" : { "file" : "lib/Nagios/StatusLog.pm", "version" : "45" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Nagios-Object" }, "homepage" : "http://github.com/duncs/perl-nagios-object", "license" : [ "http://www.gnu.org/licenses/old-licenses/gpl-1.0.txt" ], "repository" : { "url" : "http://github.com/duncs/perl-nagios-object" } }, "version" : "v0.21.20" } Nagios-Object-0.21.20/ChangeLog000444001750001750 1730112220262237 17402 0ustar00dfergusondferguson0000000000000.01 - initial release 0.03 - same as 0.01, but with higher version number to trump Nagios::Config on CPAN. 0.04 - a bunch of internal updates, nothing really new on the API side yet 0.05 - Lots of stuff all over. A bunch of bugs were fixed and I started looking at performance. I'm actually writing some serious apps using these modules now, so the "dogfood test" is really starting to kick in. Thanks to the following people for patches/bug reports: David J. Mark Akihiro Sagawa Bjornar Bjorgum Larsen 0.06 - Big reorganization of Nagios/Object.pm which should help towards making extending and overloading easier. - !!!!!!!!!! new() now require named arguments !!!!!!!!!!!! - added prelimary Nagios 2.0 support - this is mostly untested *** please send me tests *** - started putting in support for a "fast mode" to skip parts of object resolution and registration for speed - being an experimental feature, it currently breaks stuff when enabled, but shows where the real performance problems are - the flags for the big hash in Object.pm now use a single integer and bit shifting - there is a mini program in the bin directory of this distribution for encoding/decoding what they mean - also in the bin directory is a mini program for parsing configs for quick testing "perldoc bin/parse.pl" 0.07 - Fix fatal bugs added a patch from Deomid Ryabkov to fix a couple fatal bugs I missed 0.07a - Fix a couple more fixed a couple other bugs reported that I found in my Inbox right after posting 0.07 to CPAN 0.07b - fixed minor bugs reported via email or rt.cpan.org new() named parameter support was missing from StatusLog.pm config_status_demo.pl needed it's use of new() constructors updated 0.07c - added missing hostgroup_name to service dependencies 0.07d - fixed some bugs reported via email with tests and parsing 0.08 should be coming soon, since I've got a good start on the Nagios::Test:: modules I'm forcing myself to write for it. Once those modules are functioning, I'll be able to do some real testing on the performance of various pieces and start to replace those pesky linear (or worse) searches. ... fill this in from CVS later 0.09 (beta) - added support for Nagios 2.x status.dat files in StatusLog.pm - applied patch from Székelyi Szabolcs that fixed a bunch of bugs - added wildcard/regular expression support 0.09 (final) - fixed remaining bug with servicegroups - reported by Jörg Stelzle (who helped a ton with testing this release) 0.10 - added 'allow_missing_files' option to Nagios::Config to skip files specified in the nagios.cfg that don't exist (fixes RT #20924) - requested by Andrew Ruthven 0.11 - add check_freshness/freshness_threshold to Nagios::Host 0.12 - added check_interval to Nagios::Host (pointed out by Nenad Noveljic) 0.13 - Added status() method for Nagios 2.x logs in StatusLog.pm * added more tests for StatusLog.pm * added test v2 logfile for statuslog.t 0.14 - added some missing fields 0.15 - fixed hostgroup/hostgroups methods * put in first attempt at actually fixing multi-fields (takes two types of objects to create them) 0.16 - fix tests that failed when not run inside the 't' directory 0.17 - fix up dump() and the mess I made of hostgroups (SVN commit 25) * thanks to Drex Evans for loaning me a config * 0.18 will have better code for handling hostgroups/servicegroups which are currently a hack 0.18 - add tests for dump() then make them pass * fixed bug with template values not being returned (this looks like it was broken for ages) * added the template() method which will return the template object even if register_objects() hasn't been called yet * use() is now hand-coded rather than autogenerated * various cleanups * bug fixes for bugs reported by Edward Sabol and Duane Toler 0.19 - updated fix for last status in the statuslog file * added $VERSION to all modules * added tags to test and bin files 0.20 - mostly cosmetic bugfixes 0.21 - Nagios v3 support and AUTOLOAD support for unrecognized object attributes * internally dropped attribute indirection through subref's - it was silly and confusing and is now gone * v3 support, added v3 example configs to the test suite - support for the new timeperiod stuff is still incomplete - statuslog still needs work - might just switch to the AUTOLOAD model completely for that * unrecognized attributes are accepted by default now - see Nagios::Object::Config for how to enable strict_mode * support disabling strict_mode in parse.pl and test_configuration.pl * cleanups for switching to git for revision control * updated flags on the setup hash * deleted attribute_allows_undef() method * improved dump() - it takes an optional true/false argument to tell it to flatten out inheritance - the default is to preserve inheritance, calling $obj->dump(1) will flatten * light test cleaning 0.21.1 - slight amendment of version numbers to allow uploading to CPAN 0.21.2 - Fix version numbers missed from 0.21.1 and reinitialise them where possible 0.21.3 - Apply 'whatis' patch from Ryan52 - Cope with Nagios 3 status.dat file better - Apply Nagios 3 stanza patch from Shadih Rahman 0.21.4 - Apply patch from Neil Katin - RT#43890 - Apply patch from Jason Smith - RT#46480 - Apply patch from Jason Smith - RT#46487 - Apply patch from Jason Smith - RT#46493 - Apply patch from Jason Smith - RT#46495 - Apply patch from Jason Smith - RT#46497 0.21.5 - Rerelease to pick up missing test files 0.21.6 - Apply patch from 'PAYERLE' - RT#47781 0.21.7 - Apply patch from PJNewman - RT#47912 - Apply patch from Neil Katin - RT#48282 - Run 'perltidy -pbp' across all perl code 0.21.8 - Apply speedup patch for v2 to v3 from PJNewman's patch (RT#47912) - Apply patch from Stephen Gran to add in more missing methods (RT#49411) 0.21.9 - Fixed speedup patch using logic similar to Nagios' for parsing status.dat - Added more comprehensive test for parsing status file 0.21.10 - Fixed test failure on Perl 5.11 (RT #54464) 0.21.11 - Added repository, bugtracker and homepage resources 0.21.12 - Fixed continuation line handling - Thanks to payerle (RT#58906) 0.21.13 - Fixed parsing of ServiceEscalation, ServiceDependency and HostEscalation types. Thanks to PIRZYK (RT#63802) - Fixed host_name and hostgroup_name methods in various objects. Thanks to PIRZYK (RT#63805) - Improve find_object performance. Thanks to PIRZYK (RT#63803) - Allow for nested group membership. Thanks to PIRZYK (RT#63804) - Ensure host membership lists are consistent. Thanks to PIRZYK (RT#63808) - Allow for name() method to not be unique on service objects. Thanks to PIRZYK (RT#63806) 0.21.14 - Re-release to include extra test files missed previously 0.21.15 - Fixed timeperiod in host type should not be an Array. Thanks to PIRZYK (RT#66347) - Fixed notes field does not support having a ';' in it. Thanks to PIRZYK (RT#66348) 0.21.16 - Fixed undefined variable when parsing service comments - Ensure 'ref' is used as a function call correctly. Thanks to Patrik Mueller - Cater for recursive includes in configuration files. Thanks to Michael Fladischer (RT#71017) 0.21.17 - New 'list_hostdowntime' method. Thanks to Michael Clay - Fixed 'uninitialised value' error 0.21.18 - Rerelease due to repository conflicts 0.21.19 - Fix parsing of configuration when objects mistakenly try to access hostgroup info 0.21.20 - Added new serviceproblems() method. Thanks to Deppy. Nagios-Object-0.21.20/README000444001750001750 276012220262237 16473 0ustar00dfergusondferguson000000000000This is the README. READ IT! Nagios::Object is a group of modules for parsing a Nagios configuration and representing it as objects in perl. Inheriting from templates is supported, encoraged, and kept intact within the perl representation(s). This is still a very early release, so not all of the methods you'll need are implemented yet. Coming soon to a CPAN mirror near you. Send me your ideas and it may happen sooner. Installation: If you don't have Module::Build installed, you'll have to install it before you can use this module's installer. That is the only dependency in this module. No, I won't add Make::MakeMaker support. The easiest way to install Module::Build is to do "perl -MCPAN -e 'install Module::Build'". perl Build.PL ./Build ./Build test ./Build install Bug Reports: Please report all bugs via the CPAN bugs RT system: https://rt.cpan.org/Public/Dist/Display.html?Name=Nagios-Object In any bug report, include a short description of your problem and a copy of the output from "Build test." The more diagnostic information you send, the better. Providing a test script/offending code will probably get your issue fixed fastest and as a bonus, help prevent me from breaking it again in the future. Notes: Module maintenance was taken over by in January 2009. The source has been placed into a git repository at: git://github.com/duncs/perl-nagios-object.git See also: http://github.com/duncs/perl-nagios-object/ Nagios-Object-0.21.20/MANIFEST000444001750001750 513112220262237 16737 0ustar00dfergusondferguson000000000000bin/config_status_demo.pl bin/decode_flags.pl bin/parse.pl bin/statusdat_demo.pl bin/test_configuration.pl Build.PL ChangeLog lib/Nagios/Config.pm lib/Nagios/Config/File.pm lib/Nagios/Object.pm lib/Nagios/Object/Config.pm lib/Nagios/StatusLog.pm MANIFEST MANIFEST.SKIP META.yml README t/00object.t t/01object-inheritance.t t/05object_config.t t/10config_file.t t/50config.t t/51config-wildcards.t t/54dump.t t/60flexible-attributes.t t/60flexible-attributes1.cfg t/60flexible-attributes2.cfg t/70status.dat t/70status.t t/98nagios-sample-config.t t/99config-extend.t t/continuation_lines.t t/find_object-template.cfg t/find_object-template.t t/group_membership.cfg t/group_membership.t t/hostgroup_hostgroups.cfg t/hostgroup_hostgroups.t t/jfrancois.cfg t/jfrancois.pl t/multi_type_entries.cfg t/multi_type_entries.t t/nagios-missing-file.cfg t/nagios.cfg t/nagios2config.t t/nagios3config.t t/nestedtemplates.cfg t/nestedtemplates.t t/sample-config-bigger.cfg t/sample-config-minimal.cfg t/sample-config-v3.cfg t/service_escalation.cfg t/service_escalation.t t/status.log t/statuslog.t t/testconfig.cfg t/testconfig2.cfg t/testconfig3.cfg t/v2_config/cgi.cfg t/v2_config/checkcommands.cfg t/v2_config/contactgroups.cfg t/v2_config/contacts.cfg t/v2_config/dependencies.cfg t/v2_config/escalations.cfg t/v2_config/hostextinfo.cfg t/v2_config/hostgroups.cfg t/v2_config/hosts.cfg t/v2_config/minimal.cfg t/v2_config/misccommands.cfg t/v2_config/nagios.cfg t/v2_config/resource.cfg t/v2_config/serviceextinfo.cfg t/v2_config/servicegroups.cfg t/v2_config/services.cfg t/v2_config/timeperiods.cfg t/v2_wildcards.cfg t/v2log.dat t/v3_config/cgi.cfg t/v3_config/cgi.cfg.in t/v3_config/httpd.conf t/v3_config/httpd.conf.in t/v3_config/mrtg.cfg t/v3_config/mrtg.cfg.in t/v3_config/nagios.cfg t/v3_config/nagios.cfg.in t/v3_config/README t/v3_config/resource.cfg t/v3_config/resource.cfg.in t/v3_config/template-object/.cvsignore t/v3_config/template-object/commands.cfg t/v3_config/template-object/commands.cfg.in t/v3_config/template-object/contacts.cfg t/v3_config/template-object/contacts.cfg.in t/v3_config/template-object/localhost.cfg t/v3_config/template-object/localhost.cfg.in t/v3_config/template-object/printer.cfg t/v3_config/template-object/printer.cfg.in t/v3_config/template-object/README t/v3_config/template-object/switch.cfg t/v3_config/template-object/switch.cfg.in t/v3_config/template-object/templates.cfg t/v3_config/template-object/templates.cfg.in t/v3_config/template-object/timeperiods.cfg t/v3_config/template-object/timeperiods.cfg.in t/v3_config/template-object/windows.cfg t/v3_config/template-object/windows.cfg.in META.json Nagios-Object-0.21.20/MANIFEST.SKIP000444001750001750 17712220262237 17471 0ustar00dfergusondferguson000000000000^MYMETA.yml$ ^MYMETA.json$ ^\.git\/ ^Nagios-Object-\d+.\d+.\d+.tar.gz$ ^blib\/ ^_build\/ ^\.gitignore$ ^Build$ ^MANIFEST\.bak$ Nagios-Object-0.21.20/Build.PL000555001750001750 175112220262237 17111 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl -w use strict; use Module::Build; my $build = Module::Build->new( meta_merge => { resources => { repository => 'http://github.com/duncs/perl-nagios-object', bugtracker => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Nagios-Object', homepage => 'http://github.com/duncs/perl-nagios-object', }, }, dist_name => 'Nagios-Object', dist_version => "0.21.20", dist_author => 'Duncan Ferguson ', dist_abstract => 'Nagios::Object - Nagios object configuration parsing.', license => 'gpl', requires => { perl => '5.6.1' }, build_requires => { 'Test::More' => 0.01, 'Test::Exception' => 0.01, 'Module::Build' => 0.26, 'Data::Dumper' => 0.01, 'Scalar::Util' => 0.01, 'Test::NoWarnings' => 0.08, 'List::Compare' => 0.37, } ); $build->create_build_script(); Nagios-Object-0.21.20/t000755001750001750 012220262237 15714 5ustar00dfergusondferguson000000000000Nagios-Object-0.21.20/t/statuslog.t000444001750001750 367012220262237 20271 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl -w use strict; use Test::More; use Test::NoWarnings; use lib qw( ../lib ./lib ); BEGIN { plan tests => 26 } eval { chdir('t') }; use_ok('Nagios::StatusLog'); my $config = 'status.log'; ok( my $log = Nagios::StatusLog->new($config), "new()" ); ok( $log->update(), "update()" ); ok( my $host = $log->host('spaceghost'), "->host()" ); ok( my $svc = $log->service( 'localhost', 'SSH' ), "->service()" ); ok( my $pgm = $log->program(), "->program()" ); is( $host->host_name(), 'spaceghost', "\$host->host_name() returns correct value" ); is( $svc->description(), 'SSH', "\$svc->description() returns correct value" ); my $v2logfile = 'v2log.dat'; ok( my $v2log = Nagios::StatusLog->new( Filename => $v2logfile, Version => '2.4' ), "new()" ); can_ok( $v2log, qw(host service program info) ); ok( my $i = $v2log->info, "info()" ); ok( my @services = $v2log->list_services(), "list_services()" ); ok( @services > 0, "More then 0 services." ); ok( my $h = $v2log->host('localhost'), "host()" ); ok( my $s = $v2log->service( 'localhost', $services[0] ), "service()" ); # bug reported by Edward J. Sabol ok( grep( /^The Last Service$/, @services ), "Got the last service in the file" ); # bug reported by Duane Toler (included patch) ok( my $s1 = $v2log->service( 'localhost', 'PENDING_OK_CHECK_PEND' ), "get PENDING_OK_CHECK_PEND service for next test" ); is( $s1->has_been_checked, 0, "has_been_checked=0" ); is( $s1->status, 'PENDING', "Status is PENDING" ); ok( my $s2 = $v2log->service( 'localhost', 'PENDING_OK_CHECK_OK' ), "get PENDING_OK_CHECK_OK service for next two tests" ); is( $s2->has_been_checked, 1, "has_been_checked=1" ); is( $s2->status, 'OK', "Status is OK" ); # spot check can_ok( $h, qw( host_name status check_command ) ); ok( $h->status, "status returns a non-null value" ); can_ok( $s, qw( host_name service_description last_time_ok ) ); exit 0; Nagios-Object-0.21.20/t/51config-wildcards.t000444001750001750 206512220262237 21626 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl use strict; use Test::More qw(no_plan); use Test::NoWarnings; use lib qw( ./lib ../lib ); use Data::Dumper; #BEGIN { plan tests => 7; } eval { chdir('t') }; use_ok('Nagios::Object::Config'); ok( my $cf = Nagios::Object::Config->new( Version => 2.0, true_regexp_matching => 1 ), "Nagios::Object::Config->new()" ); $cf->parse('v2_wildcards.cfg'); ok( $cf->resolve_objects, "Run resolve_objects method." ); ok( $cf->register_objects, "Run register_objects method." ); ok( my @cgs = $cf->list_contactgroups, "List contact groups" ); is( scalar(@cgs), 1, "There should be only 1 contactgroup." ); my $cg = $cgs[0]; my $contacts = $cg->members; is( scalar(@$contacts), 2, "Wildcard should have matched exactly two contacts." ); my @hgs = $cf->list_hostgroups; my $printer_hg; foreach (@hgs) { if ( $_->name eq 'printers' ) { $printer_hg = $_; } } my $printers = $printer_hg->members; is( scalar(@$printers), 3, "\"prin\" should have matched all three printers." ); # add more tests .... Nagios-Object-0.21.20/t/v2_wildcards.cfg000444001750001750 1067012220262237 21141 0ustar00dfergusondferguson000000000000define contactgroup{ contactgroup_name ITMailgroup alias IT E-Mail members .*_IT_Mail } The corresponding contacts configuration is like this: define contact{ contact_name Dilbert_IT_Mail alias Dilbert use mailcontact email dilbert@dilbert.com } define contact{ contact_name Wally_IT_Mail alias Wally use mailcontact email wally@dilbert.com } define contact { contact_name Intern alias Asok use mailcontact email asok@dilbert.com } define host { name generic-host notifications_enabled 1 event_handler_enabled 1 flap_detection_enabled 1 process_perf_data 1 retain_status_information 1 retain_nonstatus_information 1 register 0 } # 'switch1' host definition define host{ use generic-host ; Name of host template to use host_name switch1 alias Switch #1 address 192.168.1.230 check_command check-host-alive max_check_attempts 10 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups ITMailgroup } # 'switch2' host definition define host{ use generic-host ; Name of host template to use host_name switch2 alias Switch #2 address 192.168.1.231 check_command check-host-alive max_check_attempts 10 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups ITMailgroup } # 'switch3' host definition define host{ use generic-host ; Name of host template to use host_name switch3 alias Switch #3 address 192.168.1.232 check_command check-host-alive max_check_attempts 10 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups ITMailgroup } # 'switch4' host definition define host{ use generic-host ; Name of host template to use host_name switch4 alias Switch #4 address 192.168.1.233 check_command check-host-alive max_check_attempts 10 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups ITMailgroup } # 'switch5' host definition define host{ use generic-host ; Name of host template to use host_name switch5 alias Switch #5 address 192.168.1.234 check_command check-host-alive max_check_attempts 10 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups ITMailgroup } # 'router1' host definition define host{ use generic-host ; Name of host template to use host_name router1 alias Router #1 address 192.168.1.254 check_command check-host-alive max_check_attempts 20 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups ITMailgroup } # 'printer1' host definition define host{ use generic-host host_name printer1 alias Printer #1 address 192.168.1.100 check_command check-host-alive max_check_attempts 10 notification_interval 480 notification_period 24x7 contact_groups ITMailgroup } # 'printer2' host definition define host{ use generic-host host_name printer2 alias Printer #2 address 192.168.1.101 check_command check-host-alive max_check_attempts 10 notification_interval 480 notification_period 24x7 contact_groups ITMailgroup } # 'printer3' host definition define host{ use generic-host host_name printer3 alias Printer #3 address 192.168.1.102 check_command check-host-alive max_check_attempts 10 notification_interval 480 notification_period 24x7 contact_groups ITMailgroup } # 'switches' host group definition define hostgroup{ hostgroup_name switches alias Switches members switch? } # 'routers' host group definition define hostgroup{ hostgroup_name routers alias Routers members router* } # 'printers' host group definition define hostgroup{ hostgroup_name printers alias Printers members prin } # '24x7' timeperiod definition define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } Nagios-Object-0.21.20/t/54dump.t000444001750001750 544512220262237 17364 0ustar00dfergusondferguson000000000000#!/usr/bin/perl use strict; use Test::More qw(no_plan); use Test::NoWarnings; use File::Temp qw(tempfile); use Data::Dumper; use Scalar::Util qw(blessed); use lib qw( ./lib ../lib ); eval { chdir('t') }; $Data::Dumper::Deparse = 1; use_ok('Nagios::Object'); my %test_host = ( host_name => 'localhost', alias => 'localhost', address => '127.0.0.1', check_command => 'check-host-alive', max_check_attempts => 3, checks_enabled => 1, event_handler => 'command_name', event_handler_enabled => 0, low_flap_threshold => 0, high_flap_threshold => 0, flap_detection_enabled => 0, process_perf_data => 1, retain_status_information => 1, retain_nonstatus_information => 1, notification_interval => 120, notification_options => [qw(d u r)], notifications_enabled => 1, stalking_options => [qw(o d u)] ); diag("create a test Nagios::Host object") if ( $ENV{TEST_VERBOSE} ); my $host = Nagios::Host->new(%test_host); ok( my $dump1 = $host->dump, "call dump()" ); is( $dump1, $host->dump, "output is consistent across calls to dump()" ); is( $host->name, $test_host{host_name}, "name() method works as expected" ); use_ok("Nagios::Object::Config"); # write the dumped config out to a file my ( $fh, $filename ) = tempfile(); print $fh $dump1; close $fh; #warn $dump1; my $config = Nagios::Object::Config->new(); $config->parse($filename); #warn Dumper($config); ok( my $file_host = $config->find_object( $test_host{host_name} ), "Retrieve the object from the parsed configuration." ); isnt( "$host", "$file_host", "parsed object is not a copy" ); foreach my $key ( sort keys %test_host ) { is_deeply( $host->$key, $file_host->$key, "$key matches" ); } # test for rt#17945 my $some_command = "foo"; my $timeperiod = 5; my $generic_host = Nagios::Host->new( register => 0, parents => undef, check_command => $some_command, max_check_attempts => 3, checks_enabled => 1, event_handler => $some_command, event_handler_enabled => 0, low_flap_threshold => 0, high_flap_threshold => 0, flap_detection_enabled => 0, process_perf_data => 1, retain_status_information => 1, retain_nonstatus_information => 1, notification_interval => $timeperiod, notification_options => [qw(d u r)], notifications_enabled => 1, stalking_options => [qw(o d u)] ); isa_ok( $generic_host, 'Nagios::Host' ); ok( $generic_host->dump(), "rt#17945 - dump ok" ); Nagios-Object-0.21.20/t/50config.t000444001750001750 272312220262237 17654 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl use strict; use Test::More qw(no_plan); use Test::NoWarnings; use Test::Exception; use lib qw( ./lib ../lib ); #BEGIN { plan tests => 7; } eval { chdir('t') }; use_ok('Nagios::Config'); ok( my $cf = Nagios::Config->new( Filename => "nagios.cfg" ), "Nagios::Config->new()" ); diag("run tests to make sure inherited Nagios::Config::File methods work") if ( $ENV{TEST_VERBOSE} ); is( $cf->get('command_check_interval'), '15s', "get('command_check_interval') returns 15s" ); is( $cf->get('downtime_file'), $cf->get_attr('downtime_file'), "make sure get_attr from v0.02 still works" ); ok( my $list = $cf->get('cfg_file'), "get('cfg_file')" ); is( ref($list), 'ARRAY', "getting an attribute that allows multiples returns an arrayref" ); ok( @$list > 2, "arrayref from previous test has more than two elements" ); diag("run tests to make sure inherited Nagios::Config::Object methods work") if ( $ENV{TEST_VERBOSE} ); ok( $cf->resolve_objects, "\$parser->resolve_objects should be ok to call multiple times" ); ok( $cf->register_objects, "\$parser->register_objects should be ok to call multiple times" ); ok( my @hosts = $cf->list_hosts(), "\$parser->list_hosts()" ); lives_ok( sub { my $mf_cf = Nagios::Config->new( Filename => 'nagios-missing-file.cfg', allow_missing_files => 1 ); }, "parameter allow_missing_files lets new() live through missing files" ); Nagios-Object-0.21.20/t/nestedtemplates.cfg000444001750001750 2077512220262237 21766 0ustar00dfergusondferguson000000000000################################################################################ # Generic host definition template define host { name generic-host ; The name of this host template notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host event handler is enabled flap_detection_enabled 1 ; Flap detection is enabled process_perf_data 0 ; Process performance data retain_status_information 1 ; Retain status information retain_nonstatus_information 1 ; Retain non-status information register 0 ; it's just a template max_check_attempts 10 alias HOST check_command check-host-alive } # ---------------------------------------------------------------------------- # # generic/global service definition template define service { name generic-service max_check_attempts 3 ; check at least 3 times normal_check_interval 5 ; check every 5 minutes retry_check_interval 5 ; retry every minute active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled parallelize_check 1 ; parallelize service checks obsess_over_service 1 ; obsess over this service check_freshness 0 ; check service 'freshness' default 0 notifications_enabled 1 ; Service notifications are enabled event_handler_enabled 1 ; Service event handler is enabled flap_detection_enabled 1 ; Flap detection is enabled process_perf_data 1 ; Process performance data retain_status_information 1 ; Retain status information retain_nonstatus_information 1 ; Retain non-status information max_check_attempts 3 ; check up to 3 times is_volatile 0 notification_interval 120 ; renotify every 2 hours notification_period 24x7; notify 24x7 check_period 24x7; monitor 24x7 register 0 ; this is only a template } # ---------------------------------------------------------------------------- # # THE contact template define contact { name generic-contact service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,c,r ; only "r" for SMW, w,c,r otherwise host_notification_options d,u,r ; only "r" for SMW, d,u,r otherwise service_notification_commands notify-by-email host_notification_commands host-notify-by-email register 0 } # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # define host { use generic-host name generic-production-host notification_interval 60 notification_period 24x7 notification_options d,u,r register 0 } define host { use generic-host name generic-development-host notification_interval 360 notification_period 24x7 notification_options d,u,r register 0 } define host { use generic-production-host name dmz-host parents firewall register 0 } define host { use generic-production-host name unix-host register 0 } define host { use generic-production-host name linux-host register 0 } define host { use generic-production-host name firewall-host register 0 } define host { use generic-production-host name san-host register 0 } define host { use generic-production-host name env-mon-device register 0 } define host { use generic-development-host name development-host register 0 } define host { use generic-production-host name security-host register 0 } define host { use generic-production-host name lan-host register 0 } # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # define service { use generic-service name generic-prod-service contact_groups admins ; tell the admins notification_options w,c,r ; Warnings,Critical,Recoverd,Unknown register 0 } define service { use generic-service name generic-dev-service max_check_attempts 5 ; check at least 3 times normal_check_interval 10 ; check every 10 minutes is_volatile 0 ; service should not be volatile contact_groups admins ; tell the admins notification_interval 240 ; only notify every 4 hours notification_period wakinghours ; I only care when I'm awake check_period 24x7 ; monitor service 24x7 notification_options n ; Warnings,Critical,Recoverd,Unknown,None register 0 } define service { use generic-service name passive-prod-service contact_groups admins ; tell the admins active_checks_enabled 1 check_period none passive_checks_enabled 1 check_freshness 1 freshness_threshold 600 notification_interval 120 ; renotify every 2 hours notification_period 24x7 ; notify 24x7 notification_options w,c,r ; Warnings,Critical,Recoverd,Unknown register 0 } define service { use generic-prod-service name insensitive-prod-service max_check_attempts 6 ; retry at least 5 times register 0 } define service { use generic-prod-service name waking-prod-service notification_period wakinghours ; I only care when I'm awake register 0 } define service { use generic-prod-service name do-not-disturb-service normal_check_interval 60 ; check once an hour notification_period donotdisturb ; Never send a notification register 0 } define service { use generic-dev-service name perfdata-only max_check_attempts 5 event_handler_enabled 0 retain_status_information 0 retain_nonstatus_information 0 flap_detection_enabled 0 obsess_over_service 0 notification_options n register 0 } # ---------------------------------------------------------------------------- # # Define DBA groups # ---------------------------------------------------------------------------- # define service { use generic-service name dba-prod-service contact_groups dba notification_options w,c,r register 0 } define service { use generic-service name dba-dev-service max_check_attempts 5 normal_check_interval 10 is_volatile 0 contact_groups dba notification_interval 240 notification_period wakinghours check_period 24x7 notification_options w,c,r register 0 } # ---------------------------------------------------------------------------- # # Define DBA groups # ---------------------------------------------------------------------------- # define service { use generic-service name web-prod-service contact_groups webmasters notification_options w,c,r register 0 } define service { use generic-service name web-dev-service max_check_attempts 5 normal_check_interval 10 is_volatile 0 contact_groups webmasters notification_interval 240 notification_period wakinghours check_period 24x7 notification_options w,c,r register 0 } Nagios-Object-0.21.20/t/hostgroup_hostgroups.t000444001750001750 157312220262237 22573 0ustar00dfergusondferguson000000000000#!/usr/bin/perl use strict; use warnings; use lib qw( ./lib ../lib ); use Test::More 'no_plan'; use Test::NoWarnings; use Data::Dumper; use Test::Exception; use Nagios::Object::Config; use Nagios::Object; eval { chdir('t'); }; my $cfile = 'hostgroup_hostgroups.cfg'; my $c; lives_ok( sub { $c = Nagios::Object::Config->new( Version => 2.5 ); }, "new()" ); lives_ok( sub { $c->parse($cfile); }, "Config parse() succeeded for '$cfile'" ); $c->resolve_objects; $c->register_objects; ok( my $service = $c->find_object('Current Load'), "Get a service object to work with" ); ok( my $host = $c->find_object('anotherhost'), "Get a host to work with" ); my $host_multi = $host->parents; #print Dumper($host_multi); #use B::Deparse; #my $dp = B::Deparse->new(); #print $dp->coderef2text( \&Nagios::Service::servicegroups ); my $list = $service->servicegroups; Nagios-Object-0.21.20/t/group_membership.cfg000444001750001750 73212220262237 22063 0ustar00dfergusondferguson000000000000define host{ host_name host1 address 192.168.0.1 hostgroups HOSTGROUP1 } define host{ host_name host2 address 192.168.0.2 hostgroups HOSTGROUP1 } define host host_name host3 address 192.168.0.3 hostgroups HOSTGROUP1 } define host{ host_name host4 address 192.168.0.4 hostgroups HOSTGROUP1 } define hostgroup{ hostgroup_name HOSTGROUP1 } define hostgroup{ hostgroup_name HOSTGROUP2 members host1,host2,host3,host4 } Nagios-Object-0.21.20/t/99config-extend.t000444001750001750 132712220262237 21155 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl -w use strict; use Test::More qw(no_plan); use Test::NoWarnings; use lib qw( ../lib ./lib ); eval { chdir('t') }; use_ok('Nagios::Object'); package Nagios::Host; sub foobar { shift->{foobar} || 'public' } sub set_foobar { my $self = shift; if ( !exists( $self->{foobar} ) ) { $self->{foobar} = 'public'; } $self->_set( 'foobar', @_ ); } package main; can_ok( 'Nagios::Host', 'foobar' ); can_ok( 'Nagios::Host', 'set_foobar' ); my $host = Nagios::Host->new(); can_ok( $host, 'foobar' ); can_ok( $host, 'set_foobar' ); ok( $host->set_foobar("guessme"), "newly created set_foobar method works" ); is( $host->foobar, 'guessme', "use getter method to verify previous test" ); Nagios-Object-0.21.20/t/testconfig.cfg000444001750001750 1215312220262237 20721 0ustar00dfergusondferguson000000000000define command { command_name check_tcp command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ } define command { command_name check-host-alive command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 4000.0,90% -c 6000.0,100% -p 5 } # '24x7' timeperiod definition define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } define command { command_name notify-by-email command_line /usr/bin/printf "%b" "***** NAGIOS *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTNAME$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $DATETIME$\n\nAdditional Info:\n\n$OUTPUT$" | /bin/mail -s "[nagios] $NOTIFICATIONTYPE$ alert - $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$" $CONTACTEMAIL$ } # 'host-notify-by-email' command definition define command { command_name host-notify-by-email command_line /usr/bin/printf "%b" "***** NAGIOS ******\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $OUTPUT$\n\nDate/Time: $DATETIME$\n" | /bin/mail -s "[nagios] $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$ } define host { name generic-host ; The name of this host template notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host event handler is enabled flap_detection_enabled 1 ; Flap detection is enabled process_perf_data 0 ; Process performance data retain_status_information 1 ; Retain status information retain_nonstatus_information 1 ; Retain non-status information max_check_attempts 10 alias HOST check_command check-host-alive notification_interval 60 notification_period 24x7 notification_options d,u,r register 0 ; it's just a template } # ---------------------------------------------------------------------------- # # generic/global service definition template define service { name generic-service active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled parallelize_check 1 ; parallelize service checks obsess_over_service 1 ; obsess over this service check_freshness 0 ; check service 'freshness' default 0 notifications_enabled 1 ; Service notifications are enabled event_handler_enabled 1 ; Service event handler is enabled flap_detection_enabled 1 ; Flap detection is enabled process_perf_data 1 ; Process performance data retain_status_information 1 ; Retain status information retain_nonstatus_information 1 ; Retain non-status information retry_check_interval 2 ; retry every 2 minutes is_volatile 0 max_check_attempts 3 ; check at least 3 times normal_check_interval 5 ; check every 5 minutes retry_check_interval 1 ; retry every minute contact_groups testcontacts ; tell the unix team notification_interval 120 ; renotify every 2 hours notification_period 24x7 ; notify 24x7 check_period 24x7 ; monitor 24x7 notification_options w,c,r ; Warnings,Critical,Recoverd,Unknown register 0 ; this is only a template } # ---------------------------------------------------------------------------- # # THE contact template define contact { name generic-contact service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,c,r host_notification_options d,u,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email register 0 } define contact { use generic-contact contact_name testuser1 alias The Test User email root@localhost pager 5555555555 } define contactgroup { contactgroup_name testcontacts alias Some Test Contacts members testuser1 } define contactgroup { contactgroup_name otherusers alias Another Contact Group For Testing members testuser1 } define host { use generic-host host_name localhost address 127.0.0.1 } define host { use generic-host host_name tsohlacol address 127.0.0.1 } define hostgroup{ hostgroup_name local_hosts alias Local Hosts contact_groups testcontacts members localhost } define service { use generic-service hostgroup_name local_hosts host_name tsohlacol service_description telnet check_command check_tcp!21 } define serviceescalation { host_name localhost service_description telnet first_notification 2 last_notification 6 contact_groups otherusers notification_interval 0 } Nagios-Object-0.21.20/t/nestedtemplates.t000444001750001750 275312220262237 21446 0ustar00dfergusondferguson000000000000#!/usr/bin/perl -w use strict; use Test::More qw(no_plan); use Test::NoWarnings; use Scalar::Util qw(blessed); use lib qw( ../lib ./lib ); use Data::Dumper; #$Data::Dumper::Maxdepth = 2; #$Data::Dumper::Deparse = 1; eval { chdir('t') }; use Nagios::Config; my $config = Nagios::Object::Config->new(); $config->parse('nestedtemplates.cfg'); # this test verifies that the correct template name is being returned foreach my $template ( $config->list_hosts ) { # get the names of the template and its parent for diagnostic output my $tname = $template->name; my $pname = $template->use || 'undefined'; $pname = $pname->name if ( blessed $tname ); my $message = "$pname isn't $tname (template name/object name)"; # test! isnt( $template->use, $template->name, $message ); } # now verify that object values are being returned properly with and # without inheritance # Note: these tests rely on the exact data in nestedtemplates.cfg my $generic = $config->find_object( 'generic-service', 'Nagios::Service' ); my $perfdata = $config->find_object( 'perfdata-only', 'Nagios::Service' ); isnt( $generic->name, $perfdata->name, "check template names" ); isnt( $generic->flap_detection_enabled, $perfdata->flap_detection_enabled, "check a value that should not be inherited" ); is( $perfdata->retry_check_interval, $generic->retry_check_interval, "check a value that should be inherited" ); #warn Dumper( $perfdata ); #warn $generic->dump; #warn $perfdata->dump; Nagios-Object-0.21.20/t/service_escalation.t000444001750001750 334612220262237 22106 0ustar00dfergusondferguson000000000000#!/usr/bin/perl use strict; use warnings; use Test::More; use lib qw( ../lib ./lib ); BEGIN { plan tests => 2 } use Nagios::Object::Config; use List::Compare; #use Data::Dumper; #$Data::Dumper::Maxdepth = 3; my $file = 'service_escalation.cfg'; eval { chdir('t'); }; sub _host_list { my ($self, $method, $h) = @_; if ( $self->can($method) ) { if ( ref $self->$method eq 'ARRAY' ) { map { if ( ref $_ eq '' ) { $h->{$_}++; } else { $h->{$_->host_name}++; } } @{$self->$method}; } elsif ( defined $self->$method ) { $h->{ $self->$method }++; } } } sub get_host_list { my ($self, $obj) = @_; my %h; &_host_list($self, 'host_name', \%h); if ( $self->can('hostgroup_name') ) { if ( ref $self->hostgroup_name eq 'ARRAY' ) { foreach my $hg ( @{$self->hostgroup_name} ) { my $hg2 = ( ref $hg eq '' ? $obj->find_object($hg, 'Nagios::HostGroup') : $hg); &_host_list($hg2, 'members', \%h); } } elsif ( defined $self->hostgroup_name ) { my $hg2 = ( ref $self->hostgroup_name eq '' ? $obj->find_object($self->hostgroup_name, 'Nagios::HostGroup') : $self->hostgroup_name); &_host_list($hg2, 'members', \%h); } } return keys %h; } my $obj = Nagios::Object::Config->new(); $obj->parse($file) || die "Could not parse object file ($file)\n"; $obj->resolve_objects(); $obj->register_objects(); foreach my $esc ( @{$obj->list_serviceescalations()} ) { my $svc = $esc->service_description; my @esc_hosts = &get_host_list($esc, $obj); my @svc_hosts = &get_host_list($svc, $obj); my ($lc) = List::Compare->new(\@esc_hosts, \@svc_hosts); ok( scalar @esc_hosts && scalar @svc_hosts && $lc->is_LequivalentR(), "Matching host lists between a service and serviceescalation"); } exit 0; Nagios-Object-0.21.20/t/70status.t000444001750001750 1445312220262237 17757 0ustar00dfergusondferguson000000000000#!/usr/bin/perl use strict; use warnings; use Test::More tests => 8; use Test::NoWarnings; use Test::Exception; use lib qw( ../lib ./lib ); use Nagios::StatusLog; ( my $filename = $0 ) =~ s/t$/dat/; my $log = Nagios::StatusLog->new( Filename => $filename, Version => 3, ); isa_ok( $log, 'Nagios::StatusLog' ); my $admin_contact = $log->contact("admin"); isa_ok( $admin_contact, "Nagios::Contact::Status" ); is_deeply( $admin_contact, { contact_name => "admin", host_notification_period => "24x7", host_notifications_enabled => 1, last_host_notification => 0, last_service_notification => 0, modified_attributes => 0, modified_host_attributes => 0, modified_service_attributes => 0, service_notification_period => "24x7", service_notifications_enabled => 1, }, "Attributes for admin right" ); my $admin2 = $log->contact("admin2"); isa_ok( $admin2, "Nagios::Contact::Status"); is_deeply( $admin2, { contact_name => "admin2", host_notification_period => "24x7", host_notifications_enabled => 1, last_host_notification => 1, last_service_notification => 0, modified_attributes => 0, modified_host_attributes => 0, modified_service_attributes => 0, service_notification_period => "24x7", service_notifications_enabled => 1, }, "Attributes for admin right" ); my $host = $log->host("doesnt_exist_1"); my $hostattrs = attributes_hash($host); is_deeply( $hostattrs, { 'acknowledgement_type' => 0, 'active_checks_enabled' => 1, 'check_command' => 'check_host_15!-H $HOSTADDRESS$ -t 3 -w 500.0,80% -c 1000.0,100%', 'check_execution_time' => 3.186, 'check_interval' => "0.000000", 'check_latency' => 0.067, 'check_options' => 0, 'check_period' => '', 'check_type' => 0, 'current_attempt' => 1, 'current_event_id' => 31, 'current_notification_id' => 553, 'current_notification_number' => 46, 'current_problem_id' => 18, 'current_state' => 2, 'event_handler' => '', 'event_handler_enabled' => 0, 'failure_prediction_enabled' => 1, 'flap_detection_enabled' => 1, 'has_been_checked' => 1, 'host_name' => 'doesnt_exist_1', 'is_flapping' => 0, 'last_check' => 1233216743, 'last_event_id' => 24, 'last_hard_state' => 2, 'last_hard_state_change' => 1233216701, 'last_notification' => 1233911011, 'last_problem_id' => 0, 'last_state_change' => 1233216701, 'last_time_down' => 1231947569, 'last_time_unreachable' => 1231947633, 'last_time_up' => 1231947413, 'last_update' => 1233914050, 'long_plugin_output' => '', 'max_attempts' => 2, 'modified_attributes' => 1, 'next_check' => 0, 'next_notification' => 1233914611, 'no_more_notifications' => 0, 'notification_period' => '24x7', 'notifications_enabled' => 1, 'obsess_over_host' => 0, 'passive_checks_enabled' => 1, 'percent_state_change' => "0.00", 'performance_data' => 'rta=0.000ms;500.000;1000.000;0; pl=100%;80;100;;', 'plugin_output' => 'CRITICAL - 192.168.50.10: rta nan, lost 100% with {}', 'problem_has_been_acknowledged' => 0, 'process_performance_data' => 1, 'retry_interval' => "1.000000", 'scheduled_downtime_depth' => 0, 'should_be_scheduled' => 0, 'state_type' => 1, }, "Host attributes correct" ); my $service = $log->service( "doesnt_exist_1", "TCP/IP" ); my $serviceattrs = attributes_hash( $service ); is_deeply( $serviceattrs, { 'acknowledgement_type' => 0, 'active_checks_enabled' => 1, 'check_command' => 'check_icmp!-H $HOSTADDRESS$ -w 100.0,20% -c 500.0,60%', 'check_execution_time' => 3.677, 'check_interval' => "5.000000", 'check_latency' => 0.218, 'check_options' => 0, 'check_period' => '24x7', 'check_type' => 0, 'current_attempt' => 1, 'current_event_id' => 23, 'current_notification_id' => 0, 'current_notification_number' => 0, 'current_problem_id' => 17, 'current_state' => 2, 'event_handler' => '', 'event_handler_enabled' => 1, 'failure_prediction_enabled' => 1, 'flap_detection_enabled' => 1, 'has_been_checked' => 1, 'host_name' => 'doesnt_exist_1', 'is_flapping' => 0, 'last_check' => 1233914007, 'last_event_id' => 0, 'last_hard_state' => 2, 'last_hard_state_change' => 1233216735, 'last_notification' => 0, 'last_problem_id' => 0, 'last_state_change' => 1233216735, 'last_time_critical' => 1233914007, 'last_time_ok' => 1231947411, 'last_time_unknown' => 0, 'last_time_warning' => 0, 'last_update' => 1233914050, 'long_plugin_output' => 'IOS (tm) 7200 Software (C7200-P-M), Version 12.2(14)S5, EARLY DEPLOYMENT RELEASE SOFTWARE (fc2) \nTAC Support: http://www.cisco.com/tac \nCopyright (c) 1986-2003 by cisco Systems, Inc. \nCompiled Fri 26-Sep-03 1\n', 'max_attempts' => 3, 'modified_attributes' => 1, 'next_check' => 1233914307, 'next_notification' => 0, 'no_more_notifications' => 0, 'notification_period' => '24x7', 'notifications_enabled' => 1, 'obsess_over_service' => 0, 'passive_checks_enabled' => 1, 'percent_state_change' => "0.00", 'performance_data' => 'rta=0.000ms;100.000;500.000;0; pl=100%;20;60;;', 'plugin_output' => 'CRITICAL - 192.168.50.10: rta nan, lost 100%', 'problem_has_been_acknowledged' => 0, 'process_performance_data' => 1, 'retry_interval' => "1.000000", 'scheduled_downtime_depth' => 0, 'service_description' => 'TCP/IP', 'should_be_scheduled' => 1, 'state_type' => 1, }, "service attributes okay" ); sub attributes_hash { my $host = shift; my %attrs = %$host; delete $attrs{__parent}; \%attrs; } Nagios-Object-0.21.20/t/nagios-missing-file.cfg000444001750001750 4362412220262237 22427 0ustar00dfergusondferguson000000000000log_file=/var/opt/nagios/nagios.log cfg_file=testconfig.cfg cfg_file=testconfig2.cfg cfg_file=testconfig3.cfg cfg_file=testconfig_abc_123_neener_neener.cfg resource_file=/etc/opt/nagios/resource.cfg status_file=/var/opt/nagios/status.log nagios_user=nms nagios_group=nobody # EXTERNAL COMMAND OPTION # This option allows you to specify whether or not Nagios should check # for external commands (in the command file defined below). By default # Nagios will *not* check for external commands, just to be on the # cautious side. If you want to be able to use the CGI command interface # you will have to enable this. Setting this value to 0 disables command # checking (the default), other values enable it. check_external_commands=1 # EXTERNAL COMMAND CHECK INTERVAL # This is the interval at which Nagios should check for external commands. # This value works of the interval_length you specify later. If you leave # that at its default value of 60 (seconds), a value of 1 here will cause # Nagios to check for external commands every minute. If you specify a # number followed by an "s" (i.e. 15s), this will be interpreted to mean # actual seconds rather than a multiple of the interval_length variable. # Note: In addition to reading the external command file at regularly # scheduled intervals, Nagios will also check for external commands after # event handlers are executed. # NOTE: Setting this value to -1 causes Nagios to check the external # command file as often as possible. command_check_interval=15s # EXTERNAL COMMAND FILE # This is the file that Nagios checks for external command requests. # It is also where the command CGI will write commands that are submitted # by users, so it must be writeable by the user that the web server # is running as (usually 'nobody'). Permissions should be set at the # directory level instead of on the file, as the file is deleted every # time its contents are processed. command_file=/var/opt/nagios/rw/nagios.cmd # COMMENT FILE # This is the file that Nagios will use for storing host and service # comments. comment_file=/var/opt/nagios/comment.log # DOWNTIME FILE # This is the file that Nagios will use for storing host and service # downtime data. downtime_file=/var/opt/nagios/downtime.log # LOCK FILE # This is the lockfile that Nagios will use to store its PID number # in when it is running in daemon mode. lock_file=/var/opt/nagios/.lockfile # TEMP FILE # This is a temporary file that is used as scratch space when Nagios # updates the status log, cleans the comment file, etc. This file # is created, used, and deleted throughout the time that Nagios is # running. temp_file=/var/opt/nagios/nagios.tmp # LOG ROTATION METHOD # This is the log rotation method that Nagios should use to rotate # the main log file. Values are as follows.. # n = None - don't rotate the log # h = Hourly rotation (top of the hour) # d = Daily rotation (midnight every day) # w = Weekly rotation (midnight on Saturday evening) # m = Monthly rotation (midnight last day of month) log_rotation_method=d # LOG ARCHIVE PATH # This is the directory where archived (rotated) log files should be # placed (assuming you've chosen to do log rotation). log_archive_path=/var/opt/nagios/archives # LOGGING OPTIONS # If you want messages logged to the syslog facility, as well as the # NetAlarm log file set this option to 1. If not, set it to 0. use_syslog=1 # NOTIFICATION LOGGING OPTION # If you don't want notifications to be logged, set this value to 0. # If notifications should be logged, set the value to 1. log_notifications=1 # SERVICE RETRY LOGGING OPTION # If you don't want service check retries to be logged, set this value # to 0. If retries should be logged, set the value to 1. log_service_retries=1 # HOST RETRY LOGGING OPTION # If you don't want host check retries to be logged, set this value to # 0. If retries should be logged, set the value to 1. log_host_retries=1 # EVENT HANDLER LOGGING OPTION # If you don't want host and service event handlers to be logged, set # this value to 0. If event handlers should be logged, set the value # to 1. log_event_handlers=1 # INITIAL STATES LOGGING OPTION # If you want Nagios to log all initial host and service states to # the main log file (the first time the service or host is checked) # you can enable this option by setting this value to 1. If you # are not using an external application that does long term state # statistics reporting, you do not need to enable this option. In # this case, set the value to 0. log_initial_states=0 # EXTERNAL COMMANDS LOGGING OPTION # If you don't want Nagios to log external commands, set this value # to 0. If external commands should be logged, set this value to 1. # Note: This option does not include logging of passive service # checks - see the option below for controlling whether or not # passive checks are logged. log_external_commands=1 # PASSIVE SERVICE CHECKS LOGGING OPTION # If you don't want Nagios to log passive service checks, set this # value to 0. If passive service checks should be logged, set this # value to 1. log_passive_service_checks=1 # GLOBAL HOST AND SERVICE EVENT HANDLERS # These options allow you to specify a host and service event handler # command that is to be run for every host or service state change. # The global event handler is executed immediately prior to the event # handler that you have optionally specified in each host or # service definition. The command argument is the short name of a # command definition that you define in your host configuration file. # Read the HTML docs for more information. #global_host_event_handler=somecommand #global_service_event_handler=somecommand # INTER-CHECK DELAY METHOD # This is the method that Nagios should use when initially # "spreading out" service checks when it starts monitoring. The # default is to use smart delay calculation, which will try to # space all service checks out evenly to minimize CPU load. # Using the dumb setting will cause all checks to be scheduled # at the same time (with no delay between them)! This is not a # good thing for production, but is useful when testing the # parallelization functionality. # n = None - don't use any delay between checks # d = Use a "dumb" delay of 1 second between checks # s = Use "smart" inter-check delay calculation # x.xx = Use an inter-check delay of x.xx seconds inter_check_delay_method=s # SERVICE CHECK INTERLEAVE FACTOR # This variable determines how service checks are interleaved. # Interleaving the service checks allows for a more even # distribution of service checks and reduced load on remote # hosts. Setting this value to 1 is equivalent to how versions # of Nagios previous to 0.0.5 did service checks. Set this # value to s (smart) for automatic calculation of the interleave # factor unless you have a specific reason to change it. # s = Use "smart" interleave factor calculation # x = Use an interleave factor of x, where x is a # number greater than or equal to 1. service_interleave_factor=s # MAXIMUM CONCURRENT SERVICE CHECKS # This option allows you to specify the maximum number of # service checks that can be run in parallel at any given time. # Specifying a value of 1 for this variable essentially prevents # any service checks from being parallelized. A value of 0 # will not restrict the number of concurrent checks that are # being executed. max_concurrent_checks=0 # SERVICE CHECK REAPER FREQUENCY # This is the frequency (in seconds!) that Nagios will process # the results of services that have been checked. service_reaper_frequency=10 # SLEEP TIME # This is the number of seconds to sleep between checking for system # events and service checks that need to be run. I would recommend # *not* changing this from its default value of 1 second. sleep_time=1 # TIMEOUT VALUES # These options control how much time Nagios will allow various # types of commands to execute before killing them off. Options # are available for controlling maximum time allotted for # service checks, host checks, event handlers, notifications, the # ocsp command, and performance data commands. All values are in # seconds. service_check_timeout=60 host_check_timeout=30 event_handler_timeout=30 notification_timeout=30 ocsp_timeout=5 perfdata_timeout=5 # RETAIN STATE INFORMATION # This setting determines whether or not Nagios will save state # information for services and hosts before it shuts down. Upon # startup Nagios will reload all saved service and host state # information before starting to monitor. This is useful for # maintaining long-term data on state statistics, etc, but will # slow Nagios down a bit when it (re)starts. Since its only # a one-time penalty, I think its well worth the additional # startup delay. retain_state_information=1 # STATE RETENTION FILE # This is the file that Nagios should use to store host and # service state information before it shuts down. The state # information in this file is also read immediately prior to # starting to monitor the network when Nagios is restarted. # This file is used only if the preserve_state_information # variable is set to 1. state_retention_file=/var/opt/nagios/status.sav # RETENTION DATA UPDATE INTERVAL # This setting determines how often (in minutes) that Nagios # will automatically save retention data during normal operation. # If you set this value to 0, Nagios will not save retention # data at regular interval, but it will still save retention # data before shutting down or restarting. If you have disabled # state retention, this option has no effect. retention_update_interval=60 # USE RETAINED PROGRAM STATE # This setting determines whether or not Nagios will set # program status variables based on the values saved in the # retention file. If you want to use retained program status # information, set this value to 1. If not, set this value # to 0. use_retained_program_state=0 # INTERVAL LENGTH # This is the seconds per unit interval as used in the # host/contact/service configuration files. Setting this to 60 means # that each interval is one minute long (60 seconds). Other settings # have not been tested much, so your mileage is likely to vary... interval_length=60 # AGRESSIVE HOST CHECKING OPTION # If you don't want to turn on agressive host checking features, set # this value to 0 (the default). Otherwise set this value to 1 to # enable the agressive check option. Read the docs for more info # on what agressive host check is or check out the source code in # base/checks.c use_agressive_host_checking=0 # SERVICE CHECK EXECUTION OPTION # This determines whether or not Nagios will actively execute # service checks when it initially starts. If this option is # disabled, checks are not actively made, but Nagios can still # receive and process passive check results that come in. Unless # you're implementing redundant hosts or have a special need for # disabling the execution of service checks, leave this enabled! # Values: 1 = enable checks, 0 = disable checks execute_service_checks=1 # PASSIVE CHECK ACCEPTANCE OPTION # This determines whether or not Nagios will accept passive # service checks results when it initially (re)starts. # Values: 1 = accept passive checks, 0 = reject passive checks accept_passive_service_checks=1 # NOTIFICATIONS OPTION # This determines whether or not Nagios will sent out any host or # service notifications when it is initially (re)started. # Values: 1 = enable notifications, 0 = disable notifications enable_notifications=1 # EVENT HANDLER USE OPTION # This determines whether or not Nagios will run any host or # service event handlers when it is initially (re)started. Unless # you're implementing redundant hosts, leave this option enabled. # Values: 1 = enable event handlers, 0 = disable event handlers enable_event_handlers=1 # PROCESS PERFORMANCE DATA OPTION # This determines whether or not Nagios will process performance # data returned from service and host checks. If this option is # enabled, host performance data will be processed using the # host_perfdata_command (defined below) and service performance # data will be processed using the service_perfdata_command (also # defined below). Read the HTML docs for more information on # performance data. # Values: 1 = process performance data, 0 = do not process performance data process_performance_data=1 # HOST AND SERVICE PERFORMANCE DATA PROCESSING COMMANDS # These commands are run after every host and service check is # performed. These commands are executed only if the # enable_performance_data option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on performance data. host_perfdata_command=process-host-perfdata service_perfdata_command=process-service-perfdata # OBSESS OVER SERVICE CHECKS OPTION # This determines whether or not Nagios will obsess over service # checks and run the ocsp_command defined below. Unless you're # planning on implementing distributed monitoring, do not enable # this option. Read the HTML docs for more information on # implementing distributed monitoring. # Values: 1 = obsess over services, 0 = do not obsess (default) obsess_over_services=0 # OBSESSIVE COMPULSIVE SERVICE PROCESSOR COMMAND # This is the command that is run for every service check that is # processed by Nagios. This command is executed only if the # obsess_over_service option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on implementing distributed monitoring. #ocsp_command=somecommand # ORPHANED SERVICE CHECK OPTION # This determines whether or not Nagios will periodically # check for orphaned services. Since service checks are not # rescheduled until the results of their previous execution # instance are processed, there exists a possibility that some # checks may never get rescheduled. This seems to be a rare # problem and should not happen under normal circumstances. # If you have problems with service checks never getting # rescheduled, you might want to try enabling this option. # Values: 1 = enable checks, 0 = disable checks check_for_orphaned_services=0 # SERVICE FRESHNESS CHECK OPTION # This option determines whether or not Nagios will periodically # check the "freshness" of service results. Enabling this option # is useful for ensuring passive checks are received in a timely # manner. # Values: 1 = enabled freshness checking, 0 = disable freshness checking check_service_freshness=1 # FRESHNESS CHECK INTERVAL # This setting determines how often (in seconds) Nagios will # check the "freshness" of service check results. If you have # disabled service freshness checking, this option has no effect. freshness_check_interval=60 # AGGREGATED STATUS UPDATES # This option determines whether or not Nagios will # aggregate updates of host, service, and program status # data. Normally, status data is updated immediately when # a change occurs. This can result in high CPU loads if # you are monitoring a lot of services. If you want Nagios # to only refresh status data every few seconds, disable # this option. # Values: 1 = enable aggregate updates, 0 = disable aggregate updates aggregate_status_updates=1 # AGGREGATED STATUS UPDATE INTERVAL # Combined with the aggregate_status_updates option, # this option determines the frequency (in seconds!) that # Nagios will periodically dump program, host, and # service status data. If you are not using aggregated # status data updates, this option has no effect. status_update_interval=15 # FLAP DETECTION OPTION # This option determines whether or not Nagios will try # and detect hosts and services that are "flapping". # Flapping occurs when a host or service changes between # states too frequently. When Nagios detects that a # host or service is flapping, it will temporarily supress # notifications for that host/service until it stops # flapping. Flap detection is very experimental, so read # the HTML documentation before enabling this feature! # Values: 1 = enable flap detection # 0 = disable flap detection (default) enable_flap_detection=1 # FLAP DETECTION THRESHOLDS FOR HOSTS AND SERVICES # Read the HTML documentation on flap detection for # an explanation of what this option does. This option # has no effect if flap detection is disabled. low_service_flap_threshold=5.0 high_service_flap_threshold=20.0 low_host_flap_threshold=5.0 high_host_flap_threshold=20.0 # DATE FORMAT OPTION # This option determines how short dates are displayed. Valid options # include: # us (MM-DD-YYYY HH:MM:SS) # euro (DD-MM-YYYY HH:MM:SS) # iso8601 (YYYY-MM-DD HH:MM:SS) # strict-iso8601 (YYYY-MM-DDTHH:MM:SS) # date_format=us # ILLEGAL OBJECT NAME CHARACTERS # This options allows you to specify illegal characters that cannot # be used in host names, service descriptions, or names of other # object types. illegal_object_name_chars=`~!$%^&*|'"<>?,()= # ILLEGAL MACRO OUTPUT CHARACTERS # This options allows you to specify illegal characters that are # stripped from macros before being used in notifications, event # handlers, etc. This DOES NOT affect macros used in service or # host check commands. # The following macros are stripped of the characters you specify: # $OUTPUT$, $PERFDATA$ illegal_macro_output_chars=`~$&|'"<> # ADMINISTRATOR EMAIL ADDRESS # The email address of the administrator of *this* machine (the one # doing the monitoring). Nagios never uses this value itself, but # you can access this value by using the $ADMINEMAIL$ macro in your # notification commands. admin_email=emailroot # ADMINISTRATOR PAGER NUMBER/ADDRESS # The pager number/address for the administrator of *this* machine. # Nagios never uses this value itself, but you can access this # value by using the $ADMINPAGER$ macro in your notification # commands. admin_pager=pageroot # EOF (End of file) Nagios-Object-0.21.20/t/v2log.dat000444001750001750 4253512220262237 17625 0ustar00dfergusondferguson000000000000######################################## # NAGIOS STATE RETENTION FILE # # THIS FILE IS AUTOMATICALLY GENERATED # BY NAGIOS. DO NOT MODIFY THIS FILE! ######################################## # Nagios-Object $LastChangedDate$ # Nagios-Object $Revision$ info { created=1151397753 version=2.4 } program { modified_host_attributes=0 modified_service_attributes=0 enable_notifications=0 active_service_checks_enabled=1 passive_service_checks_enabled=1 active_host_checks_enabled=1 passive_host_checks_enabled=1 enable_event_handlers=1 obsess_over_services=0 obsess_over_hosts=0 check_service_freshness=1 check_host_freshness=1 enable_flap_detection=1 enable_failure_prediction=1 process_performance_data=0 global_host_event_handler= global_service_event_handler= } host { host_name=localhost modified_attributes=0 check_command=check-host-alive event_handler= has_been_checked=1 check_execution_time=0.026 check_latency=0.000 check_type=0 current_state=0 last_state=0 last_hard_state=0 plugin_output=PING OK - Packet loss = 0%, RTA = 0.07 ms performance_data= last_check=1151061282 next_check=0 current_attempt=1 max_attempts=2 normal_check_interval=0 state_type=1 last_state_change=1151045252 last_hard_state_change=1151045252 last_time_up=1151061282 last_time_down=0 last_time_unreachable=0 notified_on_down=0 notified_on_unreachable=0 last_notification=0 current_notification_number=0 notifications_enabled=1 problem_has_been_acknowledged=0 acknowledgement_type=0 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=1 flap_detection_enabled=1 failure_prediction_enabled=1 process_performance_data=1 obsess_over_host=1 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } service { host_name=localhost service_description=Another Service modified_attributes=0 check_command=check_tripwire event_handler= has_been_checked=1 check_execution_time=0.023 check_latency=0.090 check_type=0 current_state=0 last_state=0 last_hard_state=0 current_attempt=1 max_attempts=3 normal_check_interval=5 retry_check_interval=1 state_type=1 last_state_change=1151045644 last_hard_state_change=1151045644 last_time_ok=1151397461 last_time_warning=0 last_time_unknown=0 last_time_critical=0 plugin_output=TCP OK - 0.004 second response time on port 1169 performance_data=time=0.003881s;0.000000;0.000000;0.000000;10.000000 last_check=1151397461 next_check=1151397761 notified_on_unknown=0 notified_on_warning=0 notified_on_critical=0 current_notification_number=0 last_notification=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=0 failure_prediction_enabled=1 process_performance_data=0 obsess_over_service=0 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } service { host_name=localhost service_description=Blahblahblah modified_attributes=0 check_command=check_serv_local.pl!nsrexecd event_handler= has_been_checked=1 check_execution_time=0.189 check_latency=0.407 check_type=0 current_state=0 last_state=0 last_hard_state=0 current_attempt=1 max_attempts=3 normal_check_interval=5 retry_check_interval=1 state_type=1 last_state_change=1151045723 last_hard_state_change=1151045723 last_time_ok=1151397550 last_time_warning=0 last_time_unknown=0 last_time_critical=0 plugin_output=El servicio esta en marcha (4 procs) performance_data= last_check=1151397550 next_check=1151397850 notified_on_unknown=0 notified_on_warning=0 notified_on_critical=0 current_notification_number=0 last_notification=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=0 failure_prediction_enabled=1 process_performance_data=0 obsess_over_service=0 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } service { host_name=localhost service_description=Cricket modified_attributes=0 check_command=check_cricket event_handler= has_been_checked=1 check_execution_time=0.071 check_latency=0.174 check_type=0 current_state=0 last_state=0 last_hard_state=0 current_attempt=1 max_attempts=3 normal_check_interval=5 retry_check_interval=1 state_type=1 last_state_change=1151045801 last_hard_state_change=1151045801 last_time_ok=1151397618 last_time_warning=0 last_time_unknown=0 last_time_critical=0 plugin_output=OK - Antiguedad fichero 3 (segundos) performance_data= last_check=1151397618 next_check=1151397918 notified_on_unknown=0 notified_on_warning=0 notified_on_critical=0 current_notification_number=0 last_notification=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=0 failure_prediction_enabled=1 process_performance_data=0 obsess_over_service=0 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } service { host_name=localhost service_description=Cricket_logs modified_attributes=0 check_command=check_cricket_logs event_handler= has_been_checked=1 check_execution_time=0.192 check_latency=0.257 check_type=0 current_state=0 last_state=0 last_hard_state=0 current_attempt=1 max_attempts=3 normal_check_interval=5 retry_check_interval=1 state_type=1 last_state_change=1151061572 last_hard_state_change=1151061572 last_time_ok=1151397669 last_time_warning=0 last_time_unknown=0 last_time_critical=1151061272 plugin_output=OK - No matches found. performance_data= last_check=1151397669 next_check=1151397969 notified_on_unknown=0 notified_on_warning=0 notified_on_critical=0 current_notification_number=0 last_notification=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=0 failure_prediction_enabled=1 process_performance_data=0 obsess_over_service=0 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } service { host_name=localhost service_description=IPtables modified_attributes=0 check_command=check_firewall event_handler= has_been_checked=1 check_execution_time=3.022 check_latency=0.184 check_type=0 current_state=0 last_state=0 last_hard_state=0 current_attempt=1 max_attempts=3 normal_check_interval=5 retry_check_interval=1 state_type=1 last_state_change=1151045331 last_hard_state_change=1151045331 last_time_ok=1151397448 last_time_warning=0 last_time_unknown=0 last_time_critical=0 plugin_output=Connection REJECT or timed out performance_data= last_check=1151397448 next_check=1151397748 notified_on_unknown=0 notified_on_warning=0 notified_on_critical=0 current_notification_number=0 last_notification=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=0 failure_prediction_enabled=1 process_performance_data=0 obsess_over_service=0 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } service { host_name=localhost service_description=Mailgraph modified_attributes=0 check_command=check_serv_local_n.pl!mailgraph.pl!6 event_handler= has_been_checked=1 check_execution_time=0.200 check_latency=0.067 check_type=0 current_state=0 last_state=0 last_hard_state=0 current_attempt=1 max_attempts=3 normal_check_interval=5 retry_check_interval=1 state_type=1 last_state_change=1151045409 last_hard_state_change=1151045409 last_time_ok=1151397526 last_time_warning=0 last_time_unknown=0 last_time_critical=0 plugin_output=El servicio esta en marcha (6 procs) performance_data= last_check=1151397526 next_check=1151397826 notified_on_unknown=0 notified_on_warning=0 notified_on_critical=0 current_notification_number=0 last_notification=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=0 failure_prediction_enabled=1 process_performance_data=0 obsess_over_service=0 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } service { host_name=localhost service_description=A service {} with () weird '" characters ~!@$%^&*(()__# {}{}{ info } modified_attributes=0 check_command=check_serv_local.pl!saimon event_handler= has_been_checked=1 check_execution_time=0.071 check_latency=0.222 check_type=0 current_state=0 last_state=0 last_hard_state=0 current_attempt=1 max_attempts=3 normal_check_interval=5 retry_check_interval=1 state_type=1 last_state_change=1151045488 last_hard_state_change=1151045488 last_time_ok=1151397605 last_time_warning=0 last_time_unknown=0 last_time_critical=0 plugin_output=El servicio esta en marcha (1 procs) performance_data= last_check=1151397605 next_check=1151397905 notified_on_unknown=0 notified_on_warning=0 notified_on_critical=0 current_notification_number=0 last_notification=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=0 failure_prediction_enabled=1 process_performance_data=0 obsess_over_service=0 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } service { host_name=localhost service_description=Postfix modified_attributes=0 check_command=check_serv_local.pl!/home/soft/postfix/libexec/master event_handler= has_been_checked=1 check_execution_time=0.070 check_latency=0.032 check_type=0 current_state=0 last_state=0 last_hard_state=0 current_attempt=1 max_attempts=3 normal_check_interval=5 retry_check_interval=1 state_type=1 last_state_change=1151045566 last_hard_state_change=1151045566 last_time_ok=1151397683 last_time_warning=0 last_time_unknown=0 last_time_critical=0 plugin_output=El servicio esta en marcha (1 procs) performance_data= last_check=1151397683 next_check=1151397983 notified_on_unknown=0 notified_on_warning=0 notified_on_critical=0 current_notification_number=0 last_notification=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=0 failure_prediction_enabled=1 process_performance_data=0 obsess_over_service=0 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } service { host_name=localhost service_description=PENDING_OK_CHECK_PEND modified_attributes=0 check_command=reset_alarm event_handler= has_been_checked=0 check_execution_time=0.020 check_latency=0.174 check_type=0 current_state=0 last_state=0 last_hard_state=0 current_attempt=1 max_attempts=1 normal_check_interval=60 retry_check_interval=1 state_type=1 last_state_change=1151045645 last_hard_state_change=1151045645 last_time_ok=1151395662 last_time_warning=0 last_time_unknown=0 last_time_critical=0 plugin_output=OK - Sin incidencias performance_data= last_check=1151395662 next_check=1151399262 notified_on_unknown=0 notified_on_warning=0 notified_on_critical=0 current_notification_number=0 last_notification=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=0 failure_prediction_enabled=1 process_performance_data=0 obsess_over_service=0 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } service { host_name=localhost service_description=PENDING_OK_CHECK_OK modified_attributes=0 check_command=reset_alarm event_handler= has_been_checked=1 check_execution_time=0.020 check_latency=0.174 check_type=0 current_state=0 last_state=0 last_hard_state=0 current_attempt=1 max_attempts=1 normal_check_interval=60 retry_check_interval=1 state_type=1 last_state_change=1151045645 last_hard_state_change=1151045645 last_time_ok=1151395662 last_time_warning=0 last_time_unknown=0 last_time_critical=0 plugin_output=OK - Sin incidencias performance_data= last_check=1151395662 next_check=1151399262 notified_on_unknown=0 notified_on_warning=0 notified_on_critical=0 current_notification_number=0 last_notification=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=0 failure_prediction_enabled=1 process_performance_data=0 obsess_over_service=0 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } service { host_name=localhost service_description=The Last Service modified_attributes=0 check_command=reset_alarm event_handler= has_been_checked=1 check_execution_time=0.020 check_latency=0.174 check_type=0 current_state=0 last_state=0 last_hard_state=0 current_attempt=1 max_attempts=1 normal_check_interval=60 retry_check_interval=1 state_type=1 last_state_change=1151045645 last_hard_state_change=1151045645 last_time_ok=1151395662 last_time_warning=0 last_time_unknown=0 last_time_critical=0 plugin_output=OK - Sin incidencias performance_data= last_check=1151395662 next_check=1151399262 notified_on_unknown=0 notified_on_warning=0 notified_on_critical=0 current_notification_number=0 last_notification=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=0 failure_prediction_enabled=1 process_performance_data=0 obsess_over_service=0 is_flapping=0 percent_state_change=0.00 state_history=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } Nagios-Object-0.21.20/t/hostgroup_hostgroups.cfg000444001750001750 2542712220262237 23113 0ustar00dfergusondferguson000000000000 define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } define command{ command_name notify-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ } define command{ command_name host-notify-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$ } define command{ command_name check-host-alive command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 99,99% -c 100,100% -p 1 } define command{ command_name check_ping command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5 } define command{ command_name check_local_disk command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ } define command{ command_name check_local_users command_line $USER1$/check_users -w $ARG1$ -c $ARG2$ } define command{ command_name check_local_procs command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ } define command{ command_name check_local_load command_line $USER1$/check_load -w $ARG1$ -c $ARG2$ } define contact{ contact_name nagios-admin alias Nagios Admin service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email email nagios-admin@localhost } define contact{ contact_name another-admin alias Another Admin service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email email another-admin@localhost } define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagios-admin } define contactgroup { contactgroup_name admindude alias THE Admin Dude members another-admin } define host{ name generic-host ; The name of this host template notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host 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 HOST, JUST A TEMPLATE! } define host{ use generic-host host_name localhost alias localhost address 127.0.0.1 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,r contact_groups admins } define host{ use generic-host host_name otherhost alias otherhost address 127.0.0.2 hostgroup TestHostGroup2 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,r contact_groups admins } define host{ use generic-host host_name anotherhost alias anotherhost address 127.0.0.3 hostgroups TestHostGroup2,TestHostGroup1 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,r contact_groups admins parents otherhost, localhost } define hostgroup{ hostgroup_name test alias Test Servers members localhost } define service{ name generic-service ; The 'name' of this service template active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled/accepted parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) 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! } define service{ use generic-service ; Name of service template to use host_name localhost service_description PING is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_ping!100.0,20%!500.0,60% } define service{ use generic-service ; Name of service template to use host_name localhost service_description Root Partition is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_disk!20%!10%!/ } define service{ use generic-service ; Name of service template to use host_name localhost service_description Current Users is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_users!20!50 } define service{ use generic-service ; Name of service template to use host_name localhost servicegroups THE_SERVICE_GROUP service_description Total Processes is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_procs!250!400 } define service{ use generic-service ; Name of service template to use host_name localhost servicegroups THE_SERVICE_GROUP service_description Current Load is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 } define servicegroup { servicegroup_name THE_SERVICE_GROUP alias THE Service Group } define hostgroup { hostgroup_name testhostgroup1 alias Test Host Group } define hostgroup { hostgroup_name testhostgroup2 alias Test Host Group } define serviceescalation { host_name localhost hostgroup_name testhostgroup2, testhostgroup2 service_description Current Load contact_groups admindude first_notification 3 last_notification 5 notification_interval 600 escalation_period 24x7 escalation_options w,u } define hostgroup { hostgroup_name TestHostGroup1 alias Test Hostgroup Number 1 members localhost } define hostgroup { hostgroup_name TestHostGroup2 alias Another Test Hostgroup } Nagios-Object-0.21.20/t/testconfig2.cfg000444001750001750 126312220262237 20763 0ustar00dfergusondferguson000000000000define command { command_name check_load ; same-line comment command_line $USER1$/check_load } ; comment on a line by itself define contact { use generic-contact contact_name testuser2 alias Another Test User email nobody@localhost ; email ; next line is pager ... this comment could end up in the wrong place pager 1234567890 ; previous line was pager ... what will happen to this comment? } define contactgroup { contactgroup_name morecontacts alias More Test Contacts members testuser1,testuser2 } ; I hope this doesn't get lost Nagios-Object-0.21.20/t/nagios3config.t000444001750001750 512312220262237 20770 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl use strict; use Test::More; use Test::NoWarnings; use lib qw( ./lib ../lib ); BEGIN { plan tests => 25; } eval { chdir('t') }; use_ok('Nagios::Config'); ok( my $cf = Nagios::Config->new( Filename => "v2_config/nagios.cfg", Version => 2 ), "Nagios::Config->new()" ); diag("run tests to make sure inherited Nagios::Config::File methods work") if ( $ENV{TEST_VERBOSE} ); is( $cf->get('command_check_interval'), '-1', "get('command_check_interval') returns -1" ); is( $cf->get('downtime_file'), $cf->get_attr('downtime_file'), "make sure get_attr from v0.02 still works" ); ok( my $list = $cf->get('cfg_file'), "get('cfg_file')" ); is( ref($list), 'ARRAY', "getting an attribute that allows multiples returns an arrayref" ); ok( @$list > 2, "arrayref from previous test has more than two elements" ); diag("run tests to make sure inherited Nagios::Config::Object methods work") if ( $ENV{TEST_VERBOSE} ); ok( $cf->resolve_objects, "\$parser->resolve_objects should be ok to call multiple times" ); ok( $cf->register_objects, "\$parser->register_objects should be ok to call multiple times" ); ok( my @hosts = $cf->list_hosts(), "\$parser->list_hosts()" ); ok( my @services = $cf->list_hosts(), "\$parser->list_services()" ); ok( my @hostgroups = $cf->list_hostgroups(), "\$parser->list_hostgroups()" ); my @servicegroups = $cf->list_servicegroups(); ok( @servicegroups, "\$parser->list_servicegroups()" ); # diag ("service groups: " . join(', ', map { $_->servicegroup_name } @servicegroups)); my $svcgroup1 = ( grep { $_->servicegroup_name eq 'svcgroup1' } @servicegroups )[0]; ok( defined($svcgroup1), "Found servicegroup1 in configuration" ); # make sure svcgroup1 has 3 members, each of which is a host/service pair my $svc_members = $svcgroup1->members(); ok( scalar(@$svc_members) == 3, "Servicegroup1 should have 3 members" ); # diag ("svcgroup1 members: " . join(', ', map { "[" . join(", ", @{$_} ) . "]" } @$svc_members)); { sub checkelement { my $element = shift; my $msg = shift; ok( scalar(@$element) == 2, $msg . " did not have 2 entries" ); ok( ref( $element->[0] ) eq 'Nagios::Host', $msg . " index 0 was not a Nagios::Host" ); ok( ref( $element->[1] ) eq 'Nagios::Service', $msg . " index 1 was not a Nagios::Host" ); } checkelement( $svc_members->[0], "Servicegroup1 first entry" ); checkelement( $svc_members->[1], "Servicegroup1 second entry" ); checkelement( $svc_members->[2], "Servicegroup1 third entry" ); } Nagios-Object-0.21.20/t/jfrancois.cfg000444001750001750 325712220262237 20517 0ustar00dfergusondferguson000000000000 ; copied from testconfig.cfg define host { name generic-host-ext notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host event handler is enabled flap_detection_enabled 1 ; Flap detection is enabled process_perf_data 0 ; Process performance data retain_status_information 1 ; Retain status information retain_nonstatus_information 1 ; Retain non-status information max_check_attempts 10 alias HOST check_command check-host-alive notification_interval 60 notification_period 24x7 notification_options d,u,r register 0 ; it's just a template } define timeperiod{ timeperiod_name workhours alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } define command { command_name check-host-alive command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 4000.0,90% -c 6000.0,100% -p 5 } ; invented define host { use generic-host-ext host_name PC0534 alias Example address 127.0.0.1 notification_period workhours } ; submitted by user define host{ use generic-host-ext host_name debian-master alias Debian Master parents PC0534 address 127.0.0.1 notification_period workhours } Nagios-Object-0.21.20/t/05object_config.t000444001750001750 155312220262237 21202 0ustar00dfergusondferguson000000000000#!/usr/bin/perl -w use strict; use Test::More qw(no_plan); use Test::NoWarnings; use Data::Dumper; use lib qw( ../lib ./lib ); eval { chdir('t') }; use_ok('Nagios::Object::Config'); ok( my $parser = Nagios::Object::Config->new(), "\$parser = Nagios::Object::Config->new()" ); ok( $parser->parse('testconfig.cfg'), "\$parser->parse( 'testconfig.cfg' )" ); ok( $parser->resolve_objects, "\$parser->resolve_objects" ); ok( $parser->register_objects, "\$parser->register_objects" ); ok( $parser->resolve_objects, "\$parser->resolve_objects should be ok to call multiple times" ); ok( $parser->register_objects, "\$parser->register_objects should be ok to call multiple times" ); ok( my @hosts = $parser->list_hosts(), "\$parser->list_hosts()" ); ok( my @contacts = $parser->list_contacts(), "\$parser->list_contacts()" ); #warn Dumper(\@contacts); # Nagios-Object-0.21.20/t/nagios2config.t000444001750001750 512312220262237 20767 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl use strict; use Test::More; use Test::NoWarnings; use lib qw( ./lib ../lib ); BEGIN { plan tests => 25; } eval { chdir('t') }; use_ok('Nagios::Config'); ok( my $cf = Nagios::Config->new( Filename => "v2_config/nagios.cfg", Version => 2 ), "Nagios::Config->new()" ); diag("run tests to make sure inherited Nagios::Config::File methods work") if ( $ENV{TEST_VERBOSE} ); is( $cf->get('command_check_interval'), '-1', "get('command_check_interval') returns -1" ); is( $cf->get('downtime_file'), $cf->get_attr('downtime_file'), "make sure get_attr from v0.02 still works" ); ok( my $list = $cf->get('cfg_file'), "get('cfg_file')" ); is( ref($list), 'ARRAY', "getting an attribute that allows multiples returns an arrayref" ); ok( @$list > 2, "arrayref from previous test has more than two elements" ); diag("run tests to make sure inherited Nagios::Config::Object methods work") if ( $ENV{TEST_VERBOSE} ); ok( $cf->resolve_objects, "\$parser->resolve_objects should be ok to call multiple times" ); ok( $cf->register_objects, "\$parser->register_objects should be ok to call multiple times" ); ok( my @hosts = $cf->list_hosts(), "\$parser->list_hosts()" ); ok( my @services = $cf->list_hosts(), "\$parser->list_services()" ); ok( my @hostgroups = $cf->list_hostgroups(), "\$parser->list_hostgroups()" ); my @servicegroups = $cf->list_servicegroups(); ok( @servicegroups, "\$parser->list_servicegroups()" ); # diag ("service groups: " . join(', ', map { $_->servicegroup_name } @servicegroups)); my $svcgroup1 = ( grep { $_->servicegroup_name eq 'svcgroup1' } @servicegroups )[0]; ok( defined($svcgroup1), "Found servicegroup1 in configuration" ); # make sure svcgroup1 has 3 members, each of which is a host/service pair my $svc_members = $svcgroup1->members(); ok( scalar(@$svc_members) == 3, "Servicegroup1 should have 3 members" ); # diag ("svcgroup1 members: " . join(', ', map { "[" . join(", ", @{$_} ) . "]" } @$svc_members)); { sub checkelement { my $element = shift; my $msg = shift; ok( scalar(@$element) == 2, $msg . " did not have 2 entries" ); ok( ref( $element->[0] ) eq 'Nagios::Host', $msg . " index 0 was not a Nagios::Host" ); ok( ref( $element->[1] ) eq 'Nagios::Service', $msg . " index 1 was not a Nagios::Host" ); } checkelement( $svc_members->[0], "Servicegroup1 first entry" ); checkelement( $svc_members->[1], "Servicegroup1 second entry" ); checkelement( $svc_members->[2], "Servicegroup1 third entry" ); } Nagios-Object-0.21.20/t/70status.dat000444001750001750 1206312220262237 20257 0ustar00dfergusondferguson000000000000######################################## # NAGIOS STATUS FILE # # THIS FILE IS AUTOMATICALLY GENERATED # BY NAGIOS. DO NOT MODIFY THIS FILE! ######################################## info { created=1233914050 version=3.0.6 } programstatus { modified_host_attributes=0 modified_service_attributes=0 nagios_pid=11378 daemon_mode=1 program_start=1233854797 last_command_check=1233914049 last_log_rotation=1233878400 enable_notifications=1 active_service_checks_enabled=1 passive_service_checks_enabled=1 active_host_checks_enabled=1 passive_host_checks_enabled=1 enable_event_handlers=1 obsess_over_services=0 obsess_over_hosts=0 check_service_freshness=1 check_host_freshness=1 enable_flap_detection=1 enable_failure_prediction=1 process_performance_data=1 global_host_event_handler= global_service_event_handler= next_comment_id=469 next_downtime_id=469 next_event_id=135 next_problem_id=89 next_notification_id=564 total_external_command_buffer_slots=10000 used_external_command_buffer_slots=0 high_external_command_buffer_slots=0 active_scheduled_host_check_stats=0,0,0 active_ondemand_host_check_stats=3,10,31 passive_host_check_stats=0,0,0 active_scheduled_service_check_stats=8,48,146 active_ondemand_service_check_stats=0,0,0 passive_service_check_stats=0,0,0 cached_host_check_stats=2,9,27 cached_service_check_stats=0,0,0 external_command_stats=0,0,0 parallel_host_check_stats=1,1,3 serial_host_check_stats=0,0,0 } hoststatus { host_name=doesnt_exist_1 modified_attributes=1 check_command=check_host_15!-H $HOSTADDRESS$ -t 3 -w 500.0,80% -c 1000.0,100% check_period= notification_period=24x7 check_interval=0.000000 retry_interval=1.000000 event_handler= has_been_checked=1 should_be_scheduled=0 check_execution_time=3.186 check_latency=0.067 check_type=0 current_state=2 last_hard_state=2 last_event_id=24 current_event_id=31 current_problem_id=18 last_problem_id=0 plugin_output=CRITICAL - 192.168.50.10: rta nan, lost 100% with {} long_plugin_output= performance_data=rta=0.000ms;500.000;1000.000;0; pl=100%;80;100;; last_check=1233216743 next_check=0 check_options=0 current_attempt=1 max_attempts=2 current_event_id=31 last_event_id=24 state_type=1 last_state_change=1233216701 last_hard_state_change=1233216701 last_time_up=1231947413 last_time_down=1231947569 last_time_unreachable=1231947633 last_notification=1233911011 next_notification=1233914611 no_more_notifications=0 current_notification_number=46 current_notification_id=553 notifications_enabled=1 problem_has_been_acknowledged=0 acknowledgement_type=0 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=0 flap_detection_enabled=1 failure_prediction_enabled=1 process_performance_data=1 obsess_over_host=0 last_update=1233914050 is_flapping=0 percent_state_change=0.00 scheduled_downtime_depth=0 } servicestatus { host_name=doesnt_exist_1 service_description=TCP/IP modified_attributes=1 check_command=check_icmp!-H $HOSTADDRESS$ -w 100.0,20% -c 500.0,60% check_period=24x7 notification_period=24x7 check_interval=5.000000 retry_interval=1.000000 event_handler= has_been_checked=1 should_be_scheduled=1 check_execution_time=3.677 check_latency=0.218 check_type=0 current_state=2 last_hard_state=2 last_event_id=0 current_event_id=23 current_problem_id=17 last_problem_id=0 current_attempt=1 max_attempts=3 current_event_id=23 last_event_id=0 state_type=1 last_state_change=1233216735 last_hard_state_change=1233216735 last_time_ok=1231947411 last_time_warning=0 last_time_unknown=0 last_time_critical=1233914007 plugin_output=CRITICAL - 192.168.50.10: rta nan, lost 100% long_plugin_output=IOS (tm) 7200 Software (C7200-P-M), Version 12.2(14)S5, EARLY DEPLOYMENT RELEASE SOFTWARE (fc2) \nTAC Support: http://www.cisco.com/tac \nCopyright (c) 1986-2003 by cisco Systems, Inc. \nCompiled Fri 26-Sep-03 1\n performance_data=rta=0.000ms;100.000;500.000;0; pl=100%;20;60;; last_check=1233914007 next_check=1233914307 check_options=0 current_notification_number=0 current_notification_id=0 last_notification=0 next_notification=0 no_more_notifications=0 notifications_enabled=1 active_checks_enabled=1 passive_checks_enabled=1 event_handler_enabled=1 problem_has_been_acknowledged=0 acknowledgement_type=0 flap_detection_enabled=1 failure_prediction_enabled=1 process_performance_data=1 obsess_over_service=0 last_update=1233914050 is_flapping=0 percent_state_change=0.00 scheduled_downtime_depth=0 } contactstatus { contact_name=admin modified_attributes=0 modified_host_attributes=0 modified_service_attributes=0 host_notification_period=24x7 service_notification_period=24x7 last_host_notification=0 last_service_notification=0 host_notifications_enabled=1 service_notifications_enabled=1 } contactstatus { contact_name=admin2 modified_attributes=0 modified_host_attributes=0 modified_service_attributes=0 host_notification_period=24x7 service_notification_period=24x7 last_host_notification=1 last_service_notification=0 host_notifications_enabled=1 service_notifications_enabled=1 } Nagios-Object-0.21.20/t/jfrancois.pl000444001750001750 636412220262237 20375 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl =pod Hi ! I'm trying to use the Nagios::Config module, but I am obviously doing something wrong as I cannot get any result with the find_object( ) method - despite the fact that the host exist in my config files. ========================= =cut use lib qw( ../lib ./lib ); use Nagios::Object; use Nagios::Object::Config; use Nagios::Config; use Text::CSV; use strict; my $conffile = "jfrancois.cfg"; print "Test 1:\n"; my $nagios = Nagios::Config->new( Filename => $conffile, Version => 1 ); $nagios->parse($conffile); use Data::Dumper; # Parse existing Nagios configuration files #my $nagios= Nagios::Config->new( Version => 1.2 ); $nagios->resolve_objects(); $nagios->register_objects(); # Get an existing host my $test_host = $nagios->find_object( "debian-master", 'Nagios::Host' ); if ($test_host) { my $name = $test_host->host_name; my $address = $test_host->address; print "\tmy name is $name\n"; print "\tmy address is $address\n"; print "\tDumping ... (\$test_host->dump())\n\n"; print $test_host->dump(); } =pod ========================= The print above yeld the following result : my name is my address is define host { } The host "debian-master" definition is as follow : Define host{ use generic-host-ext host_name debian-master alias Debian Master parents PC0534 address notification_period workhours } Where generic-host-ext is a template extended from generic-host. The Nagios setup is working correctly The parsing of the nagios.cfg file seems ok, as it takes some time to process. I also tried using Nagios::Object::Config directly, with equal result. I tried to register and resolve $test_host, but it doesn't seems to change anything. If you would like to know the bigger picture, I'm building a script which use Nagios::Config and Text::CVS to parse existing Nagios configuration files and a CSV file. The CSV file contains basic information about the host we want to monitor (IP address, SNMP community, service we want to be monitored etc.). The script would make / update the existing nagios configuration file automatically, provided a correct CSV file. It would dramaticaly help the integration process in a production environment - indeed it's the latest step before I put Nagios servers in. I googled a lot to find working examples of Nagios::Config, but not find anything apart cpan doc. If you have some URL / mailing list / forum which can help me with this problem, I would be gratefull : ) Thanks for your help Jean François =cut =pod MASURE Jean-Francois to me More options 7/13/05 Thanks for your time. I can proceed without find_object() with this small workaround : ======== =cut print "\n\nTest2:\n"; my $host = undef; my @hostlist = $nagios->list_hosts(); foreach my $h (@hostlist) { if ( $h->name() eq "debian-master" ) { $host = $h; last; # found it, abort foreach {} } } if ( $host = undef ) { print "cannot found debian-master\n"; } else { print "found debian-master: $host\n"; } =pod ======== It might be less effective than a find_object ( O(n) ) but it gets the job done ;) =cut Nagios-Object-0.21.20/t/continuation_lines.t000444001750001750 213212220262237 22140 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl use strict; use warnings; use Test::More tests => 9; use Test::NoWarnings; use File::Temp; use lib qw( ../lib ./lib ); use_ok('Nagios::Object::Config'); my $cfg_file = File::Temp->new( UNLINK => 0, ); # NOTE: there are spaces and tabs in the following section print $cfg_file <<'EOF'; define command { command_name long-command command_line /usr/bin/longcommand \ -options=many \ -uses=continuation-lines } EOF $cfg_file->close; my $parser = Nagios::Object::Config->new( Version => 2, regexp_matching => 1 ); isa_ok( $parser, 'Nagios::Object::Config' ); ok( $parser->parse( $cfg_file->filename ), 'parse ran OK' ); my $cmds = $parser->list_commands; ok( $cmds, 'non-null list_commands' ); is( ref($cmds), 'ARRAY', 'Got expected arrayref' ); is( scalar( @{$cmds} ), 1, 'Got correct array count' ); is( $cmds->[0]->command_name, 'long-command', 'command_name set correctly' ); is( $cmds->[0]->command_line, '/usr/bin/longcommand -options=many -uses=continuation-lines', 'command_line set correctly' ); unlink( $cfg_file->filename ); Nagios-Object-0.21.20/t/find_object-template.t000444001750001750 162312220262237 22317 0ustar00dfergusondferguson000000000000#!/usr/bin/perl use strict; use warnings; use Test::More; use lib qw( ../lib ./lib ); BEGIN { plan tests => 3 } use Nagios::Object::Config; my $err = 0; my $file = 'find_object-template.cfg'; my @types = qw/Nagios::ServiceEscalation Nagios::HostEscalation Nagios::ServiceDependency/; my @methods = qw/list_serviceescalations list_hostescalations list_servicedependencies/; eval { chdir('t'); }; my $obj = Nagios::Object::Config->new(); $obj->parse($file) || die "Could not parse object file ($file)\n"; $obj->resolve_objects(); for (my $i = 0; $i < scalar @types; $i++) { my $method = $methods[$i]; foreach my $o ( @{$obj->$method()} ) { # If we have use a template, find that object. if ( exists $o->{'use'} && defined $o->{'use'} ) { my $res = $obj->find_object($o->{'use'}, $types[$i]); my $ref = ref $res; ok( $ref eq $types[$i], "Looking for a $types[$i] object" ); } } } exit $err; Nagios-Object-0.21.20/t/01object-inheritance.t000444001750001750 160612220262237 22137 0ustar00dfergusondferguson000000000000#!/usr/bin/perl -w use lib qw( ../lib ./lib ); use Test::More qw(no_plan); use Test::NoWarnings; use_ok('Nagios::Object'); diag("creating an object ...") if ( $ENV{TEST_VERBOSE} ); my $tp = Nagios::TimePeriod->new( timeperiod_name => '24x7', alias => '24x7', sunday => '00:00-24:00', monday => '00:00-12:00,12:00-24:00', tuesday => '00:00-24:00', wednesday => '00:00-24:00', thursday => '00:00-24:00', friday => '00:00-24:00', saturday => '00:00-24:00' ); isa_ok( $tp, 'Nagios::Object' ); is( $tp->use, undef, "use() should return undef for top-level objects" ); my $next = $tp->new( timeperiod_name => 'child', alias => 'child', sunday => '00:01-23:01' ); is( $next->use, '24x7', "child object should know its parent's name" ); isa_ok( $next, 'Nagios::Object' ); Nagios-Object-0.21.20/t/multi_type_entries.cfg000444001750001750 2441112220262237 22500 0ustar00dfergusondferguson000000000000 define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } define command{ command_name notify-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ } define command{ command_name host-notify-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$ } define command{ command_name check-host-alive command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 99,99% -c 100,100% -p 1 } define command{ command_name check_ping command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5 } define command{ command_name check_local_disk command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ } define command{ command_name check_local_users command_line $USER1$/check_users -w $ARG1$ -c $ARG2$ } define command{ command_name check_local_procs command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ } define command{ command_name check_local_load command_line $USER1$/check_load -w $ARG1$ -c $ARG2$ } define contact{ contact_name nagios-admin alias Nagios Admin service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email email nagios-admin@localhost } define contact{ contact_name another-admin alias Another Admin service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email email another-admin@localhost } define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagios-admin } define contactgroup { contactgroup_name admindude alias THE Admin Dude members another-admin } define host{ name generic-host ; The name of this host template notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host 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 HOST, JUST A TEMPLATE! } define host{ use generic-host host_name localhost alias localhost address 127.0.0.1 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,r contact_groups admins } define host{ use generic-host host_name otherhost alias otherhost address 127.0.0.2 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,r contact_groups admins } define host{ use generic-host host_name anotherhost alias anotherhost address 127.0.0.3 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,r contact_groups admins parents otherhost, localhost } define hostgroup{ hostgroup_name test alias Test Servers members localhost } define service{ name generic-service ; The 'name' of this service template active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled/accepted parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) 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! } define service{ use generic-service ; Name of service template to use host_name localhost service_description PING is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_ping!100.0,20%!500.0,60% } define service{ use generic-service ; Name of service template to use host_name localhost service_description Root Partition is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_disk!20%!10%!/ } define service{ use generic-service ; Name of service template to use host_name localhost service_description Current Users is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_users!20!50 } define service{ use generic-service ; Name of service template to use host_name localhost servicegroups THE_SERVICE_GROUP service_description Total Processes is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_procs!250!400 } define service{ use generic-service ; Name of service template to use host_name localhost servicegroups THE_SERVICE_GROUP service_description Current Load is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 } define servicegroup { servicegroup_name THE_SERVICE_GROUP alias THE Service Group } define serviceescalation { host_name localhost service_description Current Load contact_groups admindude first_notification 3 last_notification 5 notification_interval 600 escalation_period 24x7 escalation_options w,u } Nagios-Object-0.21.20/t/60flexible-attributes2.cfg000444001750001750 135512220262237 22744 0ustar00dfergusondferguson000000000000define command { command_name check_load ; same-line comment command_line $USER1$/check_load } ; comment on a line by itself define contact { use generic-contact contact_name testuser2 alias Another Test User email nobody@localhost ; email ; next line is pager ... this comment could end up in the wrong place pager 1234567890 ; previous line was pager ... what will happen to this comment? random_four 1 random_five a,b,c random_six 89 } define contactgroup { contactgroup_name morecontacts alias More Test Contacts members testuser1,testuser2 } ; I hope this doesn't get lost Nagios-Object-0.21.20/t/group_membership.t000444001750001750 162412220262237 21610 0ustar00dfergusondferguson000000000000#!/usr/bin/perl use strict; use warnings; use Test::More; use lib qw( ../lib ./lib ); BEGIN { plan tests => 6 } use List::Compare; use Nagios::Object::Config; my $err = 0; my $file = 'group_membership.cfg'; eval { chdir('t'); }; my $obj = Nagios::Object::Config->new(); $obj->parse($file) || die "Could not parse object file ($file)\n"; $obj->resolve_objects(); $obj->register_objects(); my @hostgroups = @{$obj->list_hostgroups()}; my @hosts = @{$obj->list_hosts()}; foreach my $h ( @hosts ) { my (@hgs) = @{$h->hostgroups}; my ($lc) = List::Compare->new(\@hostgroups, \@hgs); ok( $lc->is_LequivalentR(), "Host " . $h->host_name . " is not listed as a member of all hostgroups."); } foreach my $hg ( @hostgroups ) { my ($h) = $hg->members; my ($lc) = List::Compare->new(\@hosts, $h); ok( $lc->is_LequivalentR(), "Hostgroup " . $hg->hostgroup_name . " does not have all hosts listed."); } exit $err; Nagios-Object-0.21.20/t/sample-config-v3.cfg000444001750001750 11563412220262237 21656 0ustar00dfergusondferguson000000000000# # Created with the the sample configs from the Nagios source # with cat *.cfg > sample-config-v3.cfg # ############################################################################### # COMMANDS.CFG - SAMPLE COMMAND DEFINITIONS FOR NAGIOS 3.0rc2 # # Last Modified: 05-31-2007 # # NOTES: This config file provides you with some example command definitions # that you can reference in host, service, and contact definitions. # # You don't need to keep commands in a separate file from your other # object definitions. This has been done just to make things easier to # understand. # ############################################################################### ################################################################################ # # SAMPLE NOTIFICATION COMMANDS # # These are some example notification commands. They may or may not work on # your system without modification. As an example, some systems will require # you to use "/usr/bin/mailx" instead of "/usr/bin/mail" in the commands below. # ################################################################################ # 'notify-host-by-email' command definition define command{ command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ } # 'notify-service-by-email' command definition define command{ command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ } ################################################################################ # # SAMPLE HOST CHECK COMMANDS # ################################################################################ # This command checks to see if a host is "alive" by pinging it # The check must result in a 100% packet loss or 5 second (5000ms) round trip # average time to produce a critical error. # Note: Five ICMP echo packets are sent (determined by the '-p 5' argument) # 'check-host-alive' command definition define command{ command_name check-host-alive command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5 } ################################################################################ # # SAMPLE SERVICE CHECK COMMANDS # # These are some example service check commands. They may or may not work on # your system, as they must be modified for your plugins. See the HTML # documentation on the plugins for examples of how to configure command definitions. # # NOTE: The following 'check_local_...' functions are designed to monitor # various metrics on the host that Nagios is running on (i.e. this one). ################################################################################ # 'check_local_disk' command definition define command{ command_name check_local_disk command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ } # 'check_local_load' command definition define command{ command_name check_local_load command_line $USER1$/check_load -w $ARG1$ -c $ARG2$ } # 'check_local_procs' command definition define command{ command_name check_local_procs command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$ } # 'check_local_users' command definition define command{ command_name check_local_users command_line $USER1$/check_users -w $ARG1$ -c $ARG2$ } # 'check_local_swap' command definition define command{ command_name check_local_swap command_line $USER1$/check_swap -w $ARG1$ -c $ARG2$ } # 'check_local_mrtgtraf' command definition define command{ command_name check_local_mrtgtraf command_line $USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$ } ################################################################################ # NOTE: The following 'check_...' commands are used to monitor services on # both local and remote hosts. ################################################################################ # 'check_ftp' command definition define command{ command_name check_ftp command_line $USER1$/check_ftp -H $HOSTADDRESS$ $ARG1$ } # 'check_hpjd' command definition define command{ command_name check_hpjd command_line $USER1$/check_hpjd -H $HOSTADDRESS$ $ARG1$ } # 'check_snmp' command definition define command{ command_name check_snmp command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$ } # 'check_http' command definition define command{ command_name check_http command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$ } # 'check_ssh' command definition define command{ command_name check_ssh command_line $USER1$/check_ssh $ARG1$ $HOSTADDRESS$ } # 'check_dhcp' command definition define command{ command_name check_dhcp command_line $USER1$/check_dhcp $ARG1$ } # 'check_ping' command definition define command{ command_name check_ping command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5 } # 'check_pop' command definition define command{ command_name check_pop command_line $USER1$/check_pop -H $HOSTADDRESS$ $ARG1$ } # 'check_imap' command definition define command{ command_name check_imap command_line $USER1$/check_imap -H $HOSTADDRESS$ $ARG1$ } # 'check_smtp' command definition define command{ command_name check_smtp command_line $USER1$/check_smtp -H $HOSTADDRESS$ $ARG1$ } # 'check_tcp' command definition define command{ command_name check_tcp command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$ } # 'check_udp' command definition define command{ command_name check_udp command_line $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$ } # 'check_nt' command definition define command{ command_name check_nt command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$ } ################################################################################ # # SAMPLE PERFORMANCE DATA COMMANDS # # These are sample performance data commands that can be used to send performance # data output to two text files (one for hosts, another for services). If you # plan on simply writing performance data out to a file, consider using the # host_perfdata_file and service_perfdata_file options in the main config file. # ################################################################################ # 'process-host-perfdata' command definition define command{ command_name process-host-perfdata command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /usr/local/nagios/var/host-perfdata.out } # 'process-service-perfdata' command definition define command{ command_name process-service-perfdata command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /usr/local/nagios/var/service-perfdata.out } ############################################################################### # CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS # # Last Modified: 05-31-2007 # # NOTES: This config file provides you with some example contact and contact # group definitions that you can reference in host and service # definitions. # # You don't need to keep these definitions in a separate file from your # other object definitions. This has been done just to make things # easier to understand. # ############################################################################### ############################################################################### ############################################################################### # # CONTACTS # ############################################################################### ############################################################################### # Just one contact defined by default - the Nagios admin (that's you) # This contact definition inherits a lot of default values from the 'generic-contact' # template which is defined elsewhere. define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } ############################################################################### ############################################################################### # # CONTACT GROUPS # ############################################################################### ############################################################################### # We only have one contact in this simple configuration file, so there is # no need to create more than one contact group. define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagiosadmin } ############################################################################### # LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE # # Last Modified: 05-31-2007 # # NOTE: This config file is intended to serve as an *extremely* simple # example of how you can create configuration entries to monitor # the local (Linux) machine. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITION # ############################################################################### ############################################################################### # Define a host for the local machine define host{ use linux-server ; Name of host template to use ; This host definition will inherit all variables that are defined ; in (or inherited by) the linux-server host template definition. host_name localhost alias localhost address 127.0.0.1 } ############################################################################### ############################################################################### # # HOST GROUP DEFINITION # ############################################################################### ############################################################################### # Define an optional hostgroup for Linux machines define hostgroup{ hostgroup_name linux-servers ; The name of the hostgroup alias Linux Servers ; Long name of the group members localhost ; Comma separated list of hosts that belong to this group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Define a service to "ping" the local machine define service{ use local-service ; Name of service template to use host_name localhost service_description PING check_command check_ping!100.0,20%!500.0,60% } # Define a service to check the disk space of the root partition # on the local machine. Warning if < 20% free, critical if # < 10% free space on partition. define service{ use local-service ; Name of service template to use host_name localhost service_description Root Partition check_command check_local_disk!20%!10%!/ } # Define a service to check the number of currently logged in # users on the local machine. Warning if > 20 users, critical # if > 50 users. define service{ use local-service ; Name of service template to use host_name localhost service_description Current Users check_command check_local_users!20!50 } # Define a service to check the number of currently running procs # on the local machine. Warning if > 250 processes, critical if # > 400 users. define service{ use local-service ; Name of service template to use host_name localhost service_description Total Processes check_command check_local_procs!250!400!RSZDT } # Define a service to check the load on the local machine. define service{ use local-service ; Name of service template to use host_name localhost service_description Current Load check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 } # Define a service to check the swap usage the local machine. # Critical if less than 10% of swap is free, warning if less than 20% is free define service{ use local-service ; Name of service template to use host_name localhost service_description Swap Usage check_command check_local_swap!20!10 } # Define a service to check SSH on the local machine. # Disable notifications for this service by default, as not all users may have SSH enabled. define service{ use local-service ; Name of service template to use host_name localhost service_description SSH check_command check_ssh notifications_enabled 0 } # Define a service to check HTTP on the local machine. # Disable notifications for this service by default, as not all users may have HTTP enabled. define service{ use local-service ; Name of service template to use host_name localhost service_description HTTP check_command check_http notifications_enabled 0 } ############################################################################### # PRINTER.CFG - SAMPLE CONFIG FILE FOR MONITORING A NETWORK PRINTER # # Last Modified: 10-03-2007 # # NOTES: This config file assumes that you are using the sample configuration # files that get installed with the Nagios quickstart guide. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITIONS # ############################################################################### ############################################################################### # Define a host for the printer we'll be monitoring # Change the host_name, alias, and address to fit your situation define host{ use generic-printer ; Inherit default values from a template host_name hplj2605dn ; The name we're giving to this printer alias HP LaserJet 2605dn ; A longer name associated with the printer address 192.168.1.30 ; IP address of the printer hostgroups network-printers ; Host groups this printer is associated with } ############################################################################### ############################################################################### # # HOST GROUP DEFINITIONS # ############################################################################### ############################################################################### # A hostgroup for network printers define hostgroup{ hostgroup_name network-printers ; The name of the hostgroup alias Network Printers ; Long name of the group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Create a service for monitoring the status of the printer # Change the host_name to match the name of the host you defined above # If the printer has an SNMP community string other than "public", change the check_command directive to reflect that define service{ use generic-service ; Inherit values from a template host_name hplj2605dn ; The name of the host the service is associated with service_description Printer Status ; The service description check_command check_hpjd!-C public ; The command used to monitor the service normal_check_interval 10 ; Check the service every 10 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined } # Create a service for "pinging" the printer occassionally. Useful for monitoring RTA, packet loss, etc. define service{ use generic-service host_name hplj2605dn service_description PING check_command check_ping!3000.0,80%!5000.0,100% normal_check_interval 10 retry_check_interval 1 } ############################################################################### # SWITCH.CFG - SAMPLE CONFIG FILE FOR MONITORING A SWITCH # # Last Modified: 10-03-2007 # # NOTES: This config file assumes that you are using the sample configuration # files that get installed with the Nagios quickstart guide. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITIONS # ############################################################################### ############################################################################### # Define the switch that we'll be monitoring define host{ use generic-switch ; Inherit default values from a template host_name linksys-srw224p ; The name we're giving to this switch alias Linksys SRW224P Switch ; A longer name associated with the switch address 192.168.1.253 ; IP address of the switch hostgroups switches ; Host groups this switch is associated with } ############################################################################### ############################################################################### # # HOST GROUP DEFINITIONS # ############################################################################### ############################################################################### # Create a new hostgroup for switches define hostgroup{ hostgroup_name switches ; The name of the hostgroup alias Network Switches ; Long name of the group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Create a service to PING to switch define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p ; The name of the host the service is associated with service_description PING ; The service description check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service normal_check_interval 5 ; Check the service every 5 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined } # Monitor uptime via SNMP define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p service_description Uptime check_command check_snmp!-C public -o sysUpTime.0 } # Monitor Port 1 status via SNMP define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p service_description Port 1 Link Status check_command check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-MIB } # Monitor bandwidth via MRTG logs define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p service_description Port 1 Bandwidth Usage check_command check_local_mrtgtraf!/var/lib/mrtg/192.168.1.253_1.log!AVG!1000000,1000000!5000000,5000000!10 } ############################################################################### # TEMPLATES.CFG - SAMPLE OBJECT TEMPLATES # # Last Modified: 10-03-2007 # # NOTES: This config file provides you with some example object definition # templates that are refered by other host, service, contact, etc. # definitions in other config files. # # You don't need to keep these definitions in a separate file from your # other object definitions. This has been done just to make things # easier to understand. # ############################################################################### ############################################################################### ############################################################################### # # CONTACT TEMPLATES # ############################################################################### ############################################################################### # Generic contact definition template - This is NOT a real contact, just a template! define contact{ name generic-contact ; The name of this contact template service_notification_period 24x7 ; service notifications can be sent anytime host_notification_period 24x7 ; host notifications can be sent anytime service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events service_notification_commands notify-service-by-email ; send service notifications via email host_notification_commands notify-host-by-email ; send host notifications via email register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE! } ############################################################################### ############################################################################### # # HOST TEMPLATES # ############################################################################### ############################################################################### # Generic host definition template - This is NOT a real host, just a template! define host{ name generic-host ; The name of this host template notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host 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 notification_period 24x7 ; Send host notifications at any time register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE! } # Linux host definition template - This is NOT a real host, just a template! define host{ name linux-server ; The name of this host template use generic-host ; This template inherits other values from the generic-host template check_period 24x7 ; By default, Linux hosts are checked round the clock check_interval 5 ; Actively check the host every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each Linux host 10 times (max) check_command check-host-alive ; Default command to check Linux hosts notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day ; Note that the notification_period variable is being overridden from ; the value that is inherited from the generic-host template! notification_interval 120 ; Resend notifications every 2 hours notification_options d,u,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE! } # Windows host definition template - This is NOT a real host, just a template! define host{ name windows-server ; The name of this host template use generic-host ; Inherit default values from the generic-host template check_period 24x7 ; By default, Windows servers are monitored round the clock check_interval 5 ; Actively check the server every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each server 10 times (max) check_command check-host-alive ; Default command to check if servers are "alive" notification_period 24x7 ; Send notification out at any time - day or night notification_interval 30 ; Resend notifications every 30 minutes notification_options d,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default hostgroups windows-servers ; Host groups that Windows servers should be a member of register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE } # We define a generic printer template that can be used for most printers we monitor define host{ name generic-printer ; The name of this host template use generic-host ; Inherit default values from the generic-host template check_period 24x7 ; By default, printers are monitored round the clock check_interval 5 ; Actively check the printer every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each printer 10 times (max) check_command check-host-alive ; Default command to check if printers are "alive" notification_period workhours ; Printers are only used during the workday notification_interval 30 ; Resend notifications every 30 minutes notification_options d,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE } # Define a template for switches that we can reuse define host{ name generic-switch ; The name of this host template use generic-host ; Inherit default values from the generic-host template check_period 24x7 ; By default, switches are monitored round the clock check_interval 5 ; Switches are checked every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each switch 10 times (max) check_command check-host-alive ; Default command to check if routers are "alive" notification_period 24x7 ; Send notifications at any time notification_interval 30 ; Resend notifications every 30 minutes notification_options d,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE } ############################################################################### ############################################################################### # # SERVICE TEMPLATES # ############################################################################### ############################################################################### # Generic service definition template - This is NOT a real service, just a template! define service{ name generic-service ; The 'name' of this service template active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled/accepted parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) 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 is_volatile 0 ; The service is not volatile check_period 24x7 ; The service can be checked at any time of the day max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state normal_check_interval 10 ; Check the service every 10 minutes under normal conditions retry_check_interval 2 ; Re-check the service every two minutes until a hard state can be determined contact_groups admins ; Notifications get sent out to everyone in the 'admins' group notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events notification_interval 60 ; Re-notify about service problems every hour notification_period 24x7 ; Notifications can be sent out at any time register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE! } # Local service definition template - This is NOT a real service, just a template! define service{ name local-service ; The name of this service template use generic-service ; Inherit default values from the generic-service definition max_check_attempts 4 ; Re-check the service up to 4 times in order to determine its final (hard) state normal_check_interval 5 ; Check the service every 5 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until a hard state can be determined register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE! } ############################################################################### # TIMEPERIODS.CFG - SAMPLE TIMEPERIOD DEFINITIONS # # Last Modified: 05-31-2007 # # NOTES: This config file provides you with some example timeperiod definitions # that you can reference in host, service, contact, and dependency # definitions. # # You don't need to keep timeperiods in a separate file from your other # object definitions. This has been done just to make things easier to # understand. # ############################################################################### ############################################################################### ############################################################################### # # TIME PERIODS # ############################################################################### ############################################################################### # This defines a timeperiod where all times are valid for checks, # notifications, etc. The classic "24x7" support nightmare. :-) define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } # 'workhours' timeperiod definition define timeperiod{ timeperiod_name workhours alias Normal Work Hours monday 09:00-17:00 tuesday 09:00-17:00 wednesday 09:00-17:00 thursday 09:00-17:00 friday 09:00-17:00 } # 'none' timeperiod definition define timeperiod{ timeperiod_name none alias No Time Is A Good Time } # Some U.S. holidays # Note: The timeranges for each holiday are meant to *exclude* the holidays from being # treated as a valid time for notifications, etc. You probably don't want your pager # going off on New Year's. Although you're employer might... :-) define timeperiod{ name us-holidays timeperiod_name us-holidays alias U.S. Holidays january 1 00:00-00:00 ; New Years monday -1 may 00:00-00:00 ; Memorial Day (last Monday in May) july 4 00:00-00:00 ; Independence Day monday 1 september 00:00-00:00 ; Labor Day (first Monday in September) thursday -1 november 00:00-00:00 ; Thanksgiving (last Thursday in November) december 25 00:00-00:00 ; Christmas } # This defines a modified "24x7" timeperiod that covers every day of the # year, except for U.S. holidays (defined in the timeperiod above). define timeperiod{ timeperiod_name 24x7_sans_holidays alias 24x7 Sans Holidays use us-holidays ; Get holiday exceptions from other timeperiod sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } ############################################################################### # WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE # # Last Modified: 06-13-2007 # # NOTES: This config file assumes that you are using the sample configuration # files that get installed with the Nagios quickstart guide. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITIONS # ############################################################################### ############################################################################### # Define a host for the Windows machine we'll be monitoring # Change the host_name, alias, and address to fit your situation define host{ use windows-server ; Inherit default values from a template host_name winserver ; The name we're giving to this host alias My Windows Server ; A longer name associated with the host address 192.168.1.2 ; IP address of the host } ############################################################################### ############################################################################### # # HOST GROUP DEFINITIONS # ############################################################################### ############################################################################### # Define a hostgroup for Windows machines # All hosts that use the windows-server template will automatically be a member of this group define hostgroup{ hostgroup_name windows-servers ; The name of the hostgroup alias Windows Servers ; Long name of the group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Create a service for monitoring the version of NSCLient++ that is installed # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description NSClient++ Version check_command check_nt!CLIENTVERSION } # Create a service for monitoring the uptime of the server # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description Uptime check_command check_nt!UPTIME } # Create a service for monitoring CPU load # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description CPU Load check_command check_nt!CPULOAD!-l 5,80,90 } # Create a service for monitoring # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description Memory Usage check_command check_nt!MEMUSE!-w 80 -c 90 } # Create a service for monitoring C:\ disk usage # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description C:\ Drive Space check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90 } # Create a service for monitoring the W3SVC service # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description W3SVC check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC } # Create a service for monitoring the Explorer.exe process # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description Explorer check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe } Nagios-Object-0.21.20/t/testconfig3.cfg000444001750001750 1144112220262237 21003 0ustar00dfergusondferguson000000000000define command{ command_name dummy_command command_line /bin/true } define command{ command_name check-host-alive command_line /bin/check_ping -H $HOSTADDRESS$ -w 99,99% -c 100,100% -p 1 } # Generic command to check a device by pinging it define command{ command_name check_ping command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5 } # Command used to check disk space usage on local partitions define command{ command_name check_local_disk command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ } # Command used to check the number of currently logged in users on the # local machine define command{ command_name check_local_users command_line $USER1$/check_users -w $ARG1$ -c $ARG2$ } define contact{ contact_name admin alias Nagios Admin service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email email admin@localhost } define contactgroup{ contactgroup_name admins alias Nagios Administrators members admin } define host{ notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host event handler is enabled flap_detection_enabled 1 ; Flap detection 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 host_name notemplate alias notemplate address 127.0.0.100 check_command check-host-alive max_check_attempts 10 notification_interval 120 notification_period 24x7 notification_options d,r } ############################################################################### ############################################################################### # # HOST GROUPS # ############################################################################### ############################################################################### # We only have one host in our simple config file, so there is no need to # create more than one hostgroup. define hostgroup{ hostgroup_name test alias Test Servers contact_groups admins members notemplate } ############################################################################### ############################################################################### # # SERVICES # ############################################################################### ############################################################################### # Define a service to "ping" the local machine define service{ active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled/accepted parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) 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 dummy_command event_handler_enabled 1 ; Service event handler is enabled flap_detection_enabled 1 ; Flap detection 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 host_name notemplate service_description PING is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_interval 960 notification_period 24x7 check_command check_ping!100.0,20%!500.0,60% } Nagios-Object-0.21.20/t/98nagios-sample-config.t000444001750001750 211212220262237 22415 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl use strict; use File::Temp qw( tempfile ); use Test::More qw(no_plan); use Test::NoWarnings; use Data::Dumper; use Scalar::Util qw(blessed); use lib qw( ./lib ../lib ); #BEGIN { plan tests => 7; } eval { chdir('t') }; use_ok('Nagios::Config'); use_ok('Nagios::Object::Config'); # make sure tests fail if Nagios::Object does not recognize attributes/objects # in the sample configs Nagios::Object::Config->strict_mode(1); my @sample_files = qw( sample-config-bigger.cfg sample-config-minimal.cfg sample-config-v3.cfg ); foreach my $file (@sample_files) { diag("testing with Nagios sample file $file ...") if ( $ENV{TEST_VERBOSE} ); my $parser = Nagios::Object::Config->new( Version => '2.0' ); $parser->parse($file); ok( $parser->resolve_objects, "\$parser->resolve_objects" ); ok( $parser->register_objects, "\$parser->register_objects" ); my $all_objects = $parser->all_objects; foreach my $object (@$all_objects) { ok( $object->dump, 'dump ' . ref($object) . ' named ' . $object->name ); } } Nagios-Object-0.21.20/t/nagios.cfg000444001750001750 4354612220262237 20046 0ustar00dfergusondferguson000000000000log_file=/var/opt/nagios/nagios.log cfg_file=testconfig.cfg cfg_file=testconfig2.cfg cfg_file=testconfig3.cfg resource_file=/etc/opt/nagios/resource.cfg status_file=/var/opt/nagios/status.log nagios_user=nms nagios_group=nobody # EXTERNAL COMMAND OPTION # This option allows you to specify whether or not Nagios should check # for external commands (in the command file defined below). By default # Nagios will *not* check for external commands, just to be on the # cautious side. If you want to be able to use the CGI command interface # you will have to enable this. Setting this value to 0 disables command # checking (the default), other values enable it. check_external_commands=1 # EXTERNAL COMMAND CHECK INTERVAL # This is the interval at which Nagios should check for external commands. # This value works of the interval_length you specify later. If you leave # that at its default value of 60 (seconds), a value of 1 here will cause # Nagios to check for external commands every minute. If you specify a # number followed by an "s" (i.e. 15s), this will be interpreted to mean # actual seconds rather than a multiple of the interval_length variable. # Note: In addition to reading the external command file at regularly # scheduled intervals, Nagios will also check for external commands after # event handlers are executed. # NOTE: Setting this value to -1 causes Nagios to check the external # command file as often as possible. command_check_interval=15s # EXTERNAL COMMAND FILE # This is the file that Nagios checks for external command requests. # It is also where the command CGI will write commands that are submitted # by users, so it must be writeable by the user that the web server # is running as (usually 'nobody'). Permissions should be set at the # directory level instead of on the file, as the file is deleted every # time its contents are processed. command_file=/var/opt/nagios/rw/nagios.cmd # COMMENT FILE # This is the file that Nagios will use for storing host and service # comments. comment_file=/var/opt/nagios/comment.log # DOWNTIME FILE # This is the file that Nagios will use for storing host and service # downtime data. downtime_file=/var/opt/nagios/downtime.log # LOCK FILE # This is the lockfile that Nagios will use to store its PID number # in when it is running in daemon mode. lock_file=/var/opt/nagios/.lockfile # TEMP FILE # This is a temporary file that is used as scratch space when Nagios # updates the status log, cleans the comment file, etc. This file # is created, used, and deleted throughout the time that Nagios is # running. temp_file=/var/opt/nagios/nagios.tmp # LOG ROTATION METHOD # This is the log rotation method that Nagios should use to rotate # the main log file. Values are as follows.. # n = None - don't rotate the log # h = Hourly rotation (top of the hour) # d = Daily rotation (midnight every day) # w = Weekly rotation (midnight on Saturday evening) # m = Monthly rotation (midnight last day of month) log_rotation_method=d # LOG ARCHIVE PATH # This is the directory where archived (rotated) log files should be # placed (assuming you've chosen to do log rotation). log_archive_path=/var/opt/nagios/archives # LOGGING OPTIONS # If you want messages logged to the syslog facility, as well as the # NetAlarm log file set this option to 1. If not, set it to 0. use_syslog=1 # NOTIFICATION LOGGING OPTION # If you don't want notifications to be logged, set this value to 0. # If notifications should be logged, set the value to 1. log_notifications=1 # SERVICE RETRY LOGGING OPTION # If you don't want service check retries to be logged, set this value # to 0. If retries should be logged, set the value to 1. log_service_retries=1 # HOST RETRY LOGGING OPTION # If you don't want host check retries to be logged, set this value to # 0. If retries should be logged, set the value to 1. log_host_retries=1 # EVENT HANDLER LOGGING OPTION # If you don't want host and service event handlers to be logged, set # this value to 0. If event handlers should be logged, set the value # to 1. log_event_handlers=1 # INITIAL STATES LOGGING OPTION # If you want Nagios to log all initial host and service states to # the main log file (the first time the service or host is checked) # you can enable this option by setting this value to 1. If you # are not using an external application that does long term state # statistics reporting, you do not need to enable this option. In # this case, set the value to 0. log_initial_states=0 # EXTERNAL COMMANDS LOGGING OPTION # If you don't want Nagios to log external commands, set this value # to 0. If external commands should be logged, set this value to 1. # Note: This option does not include logging of passive service # checks - see the option below for controlling whether or not # passive checks are logged. log_external_commands=1 # PASSIVE SERVICE CHECKS LOGGING OPTION # If you don't want Nagios to log passive service checks, set this # value to 0. If passive service checks should be logged, set this # value to 1. log_passive_service_checks=1 # GLOBAL HOST AND SERVICE EVENT HANDLERS # These options allow you to specify a host and service event handler # command that is to be run for every host or service state change. # The global event handler is executed immediately prior to the event # handler that you have optionally specified in each host or # service definition. The command argument is the short name of a # command definition that you define in your host configuration file. # Read the HTML docs for more information. #global_host_event_handler=somecommand #global_service_event_handler=somecommand # INTER-CHECK DELAY METHOD # This is the method that Nagios should use when initially # "spreading out" service checks when it starts monitoring. The # default is to use smart delay calculation, which will try to # space all service checks out evenly to minimize CPU load. # Using the dumb setting will cause all checks to be scheduled # at the same time (with no delay between them)! This is not a # good thing for production, but is useful when testing the # parallelization functionality. # n = None - don't use any delay between checks # d = Use a "dumb" delay of 1 second between checks # s = Use "smart" inter-check delay calculation # x.xx = Use an inter-check delay of x.xx seconds inter_check_delay_method=s # SERVICE CHECK INTERLEAVE FACTOR # This variable determines how service checks are interleaved. # Interleaving the service checks allows for a more even # distribution of service checks and reduced load on remote # hosts. Setting this value to 1 is equivalent to how versions # of Nagios previous to 0.0.5 did service checks. Set this # value to s (smart) for automatic calculation of the interleave # factor unless you have a specific reason to change it. # s = Use "smart" interleave factor calculation # x = Use an interleave factor of x, where x is a # number greater than or equal to 1. service_interleave_factor=s # MAXIMUM CONCURRENT SERVICE CHECKS # This option allows you to specify the maximum number of # service checks that can be run in parallel at any given time. # Specifying a value of 1 for this variable essentially prevents # any service checks from being parallelized. A value of 0 # will not restrict the number of concurrent checks that are # being executed. max_concurrent_checks=0 # SERVICE CHECK REAPER FREQUENCY # This is the frequency (in seconds!) that Nagios will process # the results of services that have been checked. service_reaper_frequency=10 # SLEEP TIME # This is the number of seconds to sleep between checking for system # events and service checks that need to be run. I would recommend # *not* changing this from its default value of 1 second. sleep_time=1 # TIMEOUT VALUES # These options control how much time Nagios will allow various # types of commands to execute before killing them off. Options # are available for controlling maximum time allotted for # service checks, host checks, event handlers, notifications, the # ocsp command, and performance data commands. All values are in # seconds. service_check_timeout=60 host_check_timeout=30 event_handler_timeout=30 notification_timeout=30 ocsp_timeout=5 perfdata_timeout=5 # RETAIN STATE INFORMATION # This setting determines whether or not Nagios will save state # information for services and hosts before it shuts down. Upon # startup Nagios will reload all saved service and host state # information before starting to monitor. This is useful for # maintaining long-term data on state statistics, etc, but will # slow Nagios down a bit when it (re)starts. Since its only # a one-time penalty, I think its well worth the additional # startup delay. retain_state_information=1 # STATE RETENTION FILE # This is the file that Nagios should use to store host and # service state information before it shuts down. The state # information in this file is also read immediately prior to # starting to monitor the network when Nagios is restarted. # This file is used only if the preserve_state_information # variable is set to 1. state_retention_file=/var/opt/nagios/status.sav # RETENTION DATA UPDATE INTERVAL # This setting determines how often (in minutes) that Nagios # will automatically save retention data during normal operation. # If you set this value to 0, Nagios will not save retention # data at regular interval, but it will still save retention # data before shutting down or restarting. If you have disabled # state retention, this option has no effect. retention_update_interval=60 # USE RETAINED PROGRAM STATE # This setting determines whether or not Nagios will set # program status variables based on the values saved in the # retention file. If you want to use retained program status # information, set this value to 1. If not, set this value # to 0. use_retained_program_state=0 # INTERVAL LENGTH # This is the seconds per unit interval as used in the # host/contact/service configuration files. Setting this to 60 means # that each interval is one minute long (60 seconds). Other settings # have not been tested much, so your mileage is likely to vary... interval_length=60 # AGRESSIVE HOST CHECKING OPTION # If you don't want to turn on agressive host checking features, set # this value to 0 (the default). Otherwise set this value to 1 to # enable the agressive check option. Read the docs for more info # on what agressive host check is or check out the source code in # base/checks.c use_agressive_host_checking=0 # SERVICE CHECK EXECUTION OPTION # This determines whether or not Nagios will actively execute # service checks when it initially starts. If this option is # disabled, checks are not actively made, but Nagios can still # receive and process passive check results that come in. Unless # you're implementing redundant hosts or have a special need for # disabling the execution of service checks, leave this enabled! # Values: 1 = enable checks, 0 = disable checks execute_service_checks=1 # PASSIVE CHECK ACCEPTANCE OPTION # This determines whether or not Nagios will accept passive # service checks results when it initially (re)starts. # Values: 1 = accept passive checks, 0 = reject passive checks accept_passive_service_checks=1 # NOTIFICATIONS OPTION # This determines whether or not Nagios will sent out any host or # service notifications when it is initially (re)started. # Values: 1 = enable notifications, 0 = disable notifications enable_notifications=1 # EVENT HANDLER USE OPTION # This determines whether or not Nagios will run any host or # service event handlers when it is initially (re)started. Unless # you're implementing redundant hosts, leave this option enabled. # Values: 1 = enable event handlers, 0 = disable event handlers enable_event_handlers=1 # PROCESS PERFORMANCE DATA OPTION # This determines whether or not Nagios will process performance # data returned from service and host checks. If this option is # enabled, host performance data will be processed using the # host_perfdata_command (defined below) and service performance # data will be processed using the service_perfdata_command (also # defined below). Read the HTML docs for more information on # performance data. # Values: 1 = process performance data, 0 = do not process performance data process_performance_data=1 # HOST AND SERVICE PERFORMANCE DATA PROCESSING COMMANDS # These commands are run after every host and service check is # performed. These commands are executed only if the # enable_performance_data option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on performance data. host_perfdata_command=process-host-perfdata service_perfdata_command=process-service-perfdata # OBSESS OVER SERVICE CHECKS OPTION # This determines whether or not Nagios will obsess over service # checks and run the ocsp_command defined below. Unless you're # planning on implementing distributed monitoring, do not enable # this option. Read the HTML docs for more information on # implementing distributed monitoring. # Values: 1 = obsess over services, 0 = do not obsess (default) obsess_over_services=0 # OBSESSIVE COMPULSIVE SERVICE PROCESSOR COMMAND # This is the command that is run for every service check that is # processed by Nagios. This command is executed only if the # obsess_over_service option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on implementing distributed monitoring. #ocsp_command=somecommand # ORPHANED SERVICE CHECK OPTION # This determines whether or not Nagios will periodically # check for orphaned services. Since service checks are not # rescheduled until the results of their previous execution # instance are processed, there exists a possibility that some # checks may never get rescheduled. This seems to be a rare # problem and should not happen under normal circumstances. # If you have problems with service checks never getting # rescheduled, you might want to try enabling this option. # Values: 1 = enable checks, 0 = disable checks check_for_orphaned_services=0 # SERVICE FRESHNESS CHECK OPTION # This option determines whether or not Nagios will periodically # check the "freshness" of service results. Enabling this option # is useful for ensuring passive checks are received in a timely # manner. # Values: 1 = enabled freshness checking, 0 = disable freshness checking check_service_freshness=1 # FRESHNESS CHECK INTERVAL # This setting determines how often (in seconds) Nagios will # check the "freshness" of service check results. If you have # disabled service freshness checking, this option has no effect. freshness_check_interval=60 # AGGREGATED STATUS UPDATES # This option determines whether or not Nagios will # aggregate updates of host, service, and program status # data. Normally, status data is updated immediately when # a change occurs. This can result in high CPU loads if # you are monitoring a lot of services. If you want Nagios # to only refresh status data every few seconds, disable # this option. # Values: 1 = enable aggregate updates, 0 = disable aggregate updates aggregate_status_updates=1 # AGGREGATED STATUS UPDATE INTERVAL # Combined with the aggregate_status_updates option, # this option determines the frequency (in seconds!) that # Nagios will periodically dump program, host, and # service status data. If you are not using aggregated # status data updates, this option has no effect. status_update_interval=15 # FLAP DETECTION OPTION # This option determines whether or not Nagios will try # and detect hosts and services that are "flapping". # Flapping occurs when a host or service changes between # states too frequently. When Nagios detects that a # host or service is flapping, it will temporarily supress # notifications for that host/service until it stops # flapping. Flap detection is very experimental, so read # the HTML documentation before enabling this feature! # Values: 1 = enable flap detection # 0 = disable flap detection (default) enable_flap_detection=1 # FLAP DETECTION THRESHOLDS FOR HOSTS AND SERVICES # Read the HTML documentation on flap detection for # an explanation of what this option does. This option # has no effect if flap detection is disabled. low_service_flap_threshold=5.0 high_service_flap_threshold=20.0 low_host_flap_threshold=5.0 high_host_flap_threshold=20.0 # DATE FORMAT OPTION # This option determines how short dates are displayed. Valid options # include: # us (MM-DD-YYYY HH:MM:SS) # euro (DD-MM-YYYY HH:MM:SS) # iso8601 (YYYY-MM-DD HH:MM:SS) # strict-iso8601 (YYYY-MM-DDTHH:MM:SS) # date_format=us # ILLEGAL OBJECT NAME CHARACTERS # This options allows you to specify illegal characters that cannot # be used in host names, service descriptions, or names of other # object types. illegal_object_name_chars=`~!$%^&*|'"<>?,()= # ILLEGAL MACRO OUTPUT CHARACTERS # This options allows you to specify illegal characters that are # stripped from macros before being used in notifications, event # handlers, etc. This DOES NOT affect macros used in service or # host check commands. # The following macros are stripped of the characters you specify: # $OUTPUT$, $PERFDATA$ illegal_macro_output_chars=`~$&|'"<> # ADMINISTRATOR EMAIL ADDRESS # The email address of the administrator of *this* machine (the one # doing the monitoring). Nagios never uses this value itself, but # you can access this value by using the $ADMINEMAIL$ macro in your # notification commands. admin_email=emailroot # ADMINISTRATOR PAGER NUMBER/ADDRESS # The pager number/address for the administrator of *this* machine. # Nagios never uses this value itself, but you can access this # value by using the $ADMINPAGER$ macro in your notification # commands. admin_pager=pageroot # EOF (End of file) Nagios-Object-0.21.20/t/find_object-template.cfg000444001750001750 272012220262237 22612 0ustar00dfergusondferguson000000000000############################################################################### # # HostEscalation Objects # ############################################################################### define hostescalation{ name hostescalation-template first_notification 4 last_notification 10 notification_interval 60 contact_groups all-escalation register 0 } define hostescalation{ use hostescalation-template host_name host1 } ############################################################################### # # ServiceDependency Objects # ############################################################################### define servicedependency{ name servicedependency-template execution_failure_criteria n notification_failure_criteria w,u,c register 0 } define servicedependency{ use servicedependency-template host_name host1 service_description http check dependent_host_name host1 dependent_service_description http process check } ############################################################################### # # ServiceEscalation Objects # ############################################################################### define serviceescalation{ name serviceescalation-template first_notification 4 last_notification 10 notification_interval 60 contact_groups all-escalation register 0 } define serviceescalation{ use serviceescalation-template host_name host1 service_description http check } Nagios-Object-0.21.20/t/10config_file.t000444001750001750 132712220262237 20646 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl use strict; use Test::More; use Test::NoWarnings; use lib qw( ./lib ../lib ); BEGIN { plan tests => 8; } eval { chdir('t') }; use_ok('Nagios::Config::File'); ok( my $cf = Nagios::Config::File->new("nagios.cfg"), "Nagios::Config::File->new()" ); is( $cf->get('command_check_interval'), '15s', "get('command_check_interval') returns 15s" ); is( $cf->get('downtime_file'), $cf->get_attr('downtime_file'), "make sure get_attr from v0.02 still works" ); ok( my $list = $cf->get('cfg_file'), "get('cfg_file')" ); is( ref($list), 'ARRAY', "getting an attribute that allows multiples returns an arrayref" ); ok( @$list > 2, "arrayref from previous test has more than two elements" ); Nagios-Object-0.21.20/t/60flexible-attributes.t000444001750001750 170712220262237 22367 0ustar00dfergusondferguson000000000000#!/usr/bin/perl -w use strict; use Test::More qw(no_plan); use Test::NoWarnings; use Test::Exception; use Scalar::Util qw(blessed); use lib qw( ../lib ./lib ); use Data::Dumper; eval { chdir('t') }; use Nagios::Config; my $lax = Nagios::Object::Config->new(); lives_ok( sub { $lax->parse('60flexible-attributes1.cfg') }, "parse() does not throw exceptions by default" ); my @contacts = $lax->list_contacts; lives_ok( sub { $contacts[0]->random_one }, "Verify that get method was instantiated" ); lives_ok( sub { $contacts[0]->set_random_one('foobar') }, "Verify that set method was instantiated" ); # enable strict mode Nagios::Object::Config->strict_mode(1); my $strict = Nagios::Object::Config->new(); dies_ok( sub { $strict->parse('60flexible-attributes2.cfg') }, "parse() throws exceptions with strict_mode" ); dies_ok( sub { $contacts[0]->random_four }, "verify that no methods were instantiated under strict_mode" ); Nagios-Object-0.21.20/t/multi_type_entries.t000444001750001750 143112220262237 22161 0ustar00dfergusondferguson000000000000#!/usr/bin/perl use strict; use warnings; use lib qw( ./lib ../lib ); use Test::More 'no_plan'; use Test::NoWarnings; use Data::Dumper; use Nagios::Object::Config; use Nagios::Object; eval { chdir('t'); }; my $cfile = 'multi_type_entries.cfg'; my $c = Nagios::Object::Config->new( Version => 2.5 ); ok( $c->parse($cfile), "Config parse() succeeded for '$cfile'" ); $c->resolve_objects; $c->register_objects; ok( my $service = $c->find_object('Current Load'), "Get a service object to work with" ); ok( my $host = $c->find_object('anotherhost'), "Get a host to work with" ); my $host_multi = $host->parents; #print Dumper($host_multi); #use B::Deparse; #my $dp = B::Deparse->new(); #print $dp->coderef2text( \&Nagios::Service::servicegroups ); my $list = $service->servicegroups; Nagios-Object-0.21.20/t/status.log000444001750001750 517012220262237 20102 0ustar00dfergusondferguson000000000000# Nagios 1.1 Status File [1064776420] PROGRAM;1064677510;16199;1;1064776405;1064721600;1;1;1;1;0;1;1;1 [1064776420] HOST;localhost;UP;1064677510;1029787907;0;34889607;0;0;0;0;1;1;1;1;0;0.00;0;1;0;(Host assumed to be up) [1064776420] HOST;spaceghost;UP;1064774415;1029787913;0;34889601;0;0;0;0;1;1;1;1;0;0.00;0;1;0;PING OK - Packet loss = 0%, RTA = 0.27 ms [1064776420] SERVICE;localhost;BASE_DISK;OK;1/3;HARD;1064776389;1064776689;ACTIVE;1;1;1;1029788029;0;OK;34889331;0;0;0;0;0;1;0;0;1;0;0.00;0;1;1;1;Disk OK - 19% used on /, 79% used on /opt, 49% used on /var, 6% used on /tmp, 91% used on /usr [1064776420] SERVICE;localhost;FTP;OK;1/3;HARD;1064776144;1064776444;ACTIVE;1;1;1;1029788152;0;OK;34888831;0;0;0;0;0;1;0;0;1;0;0.00;0;1;0;1;(No output!) [1064776420] SERVICE;localhost;HEARTBEAT_PROC;OK;1/3;HARD;1064776224;1064776524;ACTIVE;1;1;1;1063657522;0;OK;1027697;0;0;2025;0;0;1;0;0;1;0;0.00;0;1;1;1;OK - 12 process(es) found resembling 'heartbeat:' [1064776420] SERVICE;localhost;PING;OK;1/3;HARD;1064776385;1064776685;ACTIVE;1;1;1;1063646373;0;OK;1031140;0;0;0;0;0;1;0;4;1;0;0.00;0;1;1;1;PING OK - Packet loss = 0%, RTA = 0.25 ms [1064776420] SERVICE;localhost;SNMP;OK;1/3;HARD;1064776387;1064776687;ACTIVE;1;1;1;1029788154;0;OK;34889010;0;0;0;0;0;1;0;0;1;0;0.00;0;1;0;1;SNMP OK - Linux localhost 2.4.19 #6 SMP Sat Jan 18 16:04:46 EST 2003 i686 [1064776420] SERVICE;localhost;SSH;OK;1/3;HARD;1064776139;1064776439;ACTIVE;1;1;1;1029787911;0;OK;34889372;0;0;0;0;0;1;0;0;1;0;0.00;0;1;0;1;SSH ok - OpenSSH_3.6.1p2 (protocol 1.99) [1064776420] SERVICE;spaceghost;BASE_DISK;OK;1/3;HARD;1064776389;1064776689;ACTIVE;1;1;1;1064733180;0;OK;34943855;0;0;0;0;0;1;0;1;1;0;0.00;0;1;1;1;Disk OK - % used on , 64% used on /var, 5% used on /tmp, 70% used on /usr, 53% used on /opt, 62% used on / [1064776420] SERVICE;spaceghost;FTP;OK;1/3;HARD;1064776248;1064776548;ACTIVE;1;1;1;1029787913;0;OK;34889251;0;0;0;0;0;1;0;0;1;0;0.00;0;1;0;1;(No output!) [1064776420] SERVICE;spaceghost;PING;OK;1/3;HARD;1064776391;1064776691;ACTIVE;1;1;1;1063646594;0;OK;1030919;0;0;0;0;0;1;0;4;1;0;0.00;0;1;1;1;PING OK - Packet loss = 0%, RTA = 1.35 ms [1064776420] SERVICE;spaceghost;SNMP;OK;1/3;HARD;1064776253;1064776553;ACTIVE;1;1;1;1029788160;0;OK;34888317;0;0;0;0;0;1;0;1;1;0;0.00;0;1;0;1;SNMP OK - HP-UX spaceghost B.11.11 U 9000/800 [1064776420] SERVICE;spaceghost;SSH;OK;1/3;HARD;1064776327;1064776627;ACTIVE;1;1;1;1029787917;0;OK;34889547;0;0;0;0;0;1;0;0;1;0;0.00;0;1;0;1;SSH ok - OpenSSH_3.5p1 (protocol 2.0) [1064776420] SERVICE;spaceghost;WIRELESS;OK;1/3;HARD;1064776264;1064776564;ACTIVE;1;1;1;1064774471;0;OK;34982311;0;0;2595;0;0;1;0;0;1;0;8.95;0;1;0;1;PING OK - Packet loss = 0%, RTA = 6.61 ms Nagios-Object-0.21.20/t/sample-config-bigger.cfg000444001750001750 7321712220262237 22545 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 05-30-2006 # ################################################################################ ################################################################################ # TIMEPERIOD DEFINITIONS ################################################################################ # '24x7' timeperiod definition define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } # 'workhours' timeperiod definition define timeperiod{ timeperiod_name workhours alias "Normal" Working Hours monday 09:00-17:00 tuesday 09:00-17:00 wednesday 09:00-17:00 thursday 09:00-17:00 friday 09:00-17:00 } # 'nonworkhours' timeperiod definition define timeperiod{ timeperiod_name nonworkhours alias Non-Work Hours sunday 00:00-24:00 monday 00:00-09:00,17:00-24:00 tuesday 00:00-09:00,17:00-24:00 wednesday 00:00-09:00,17:00-24:00 thursday 00:00-09:00,17:00-24:00 friday 00:00-09:00,17:00-24:00 saturday 00:00-24:00 } # 'none' timeperiod definition define timeperiod{ timeperiod_name none alias No Time Is A Good Time } ################################################################################ # CONTACT DEFINITIONS ################################################################################ # 'nagios' contact definition define contact{ contact_name nagios alias Nagios Admin service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,u,r service_notification_commands notify-by-email,notify-by-epager host_notification_commands host-notify-by-email,host-notify-by-epager email nagios-admin@localhost.localdomain pager pagenagios-admin@localhost.localdomain } # 'jdoe' contact definition define contact{ contact_name jdoe alias John Doe service_notification_period workhours host_notification_period workhours service_notification_options c,r host_notification_options d,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email email jdoe@localhost.localdomain } ################################################################################ # CONTACT GROUP DEFINITIONS ################################################################################ # 'novell-admins' contact group definition define contactgroup{ contactgroup_name novell-admins alias Novell Administrators members nagios } # 'nt-admins' contact group definition define contactgroup{ contactgroup_name nt-admins alias NT Administrators members nagios,jdoe } # 'linux-admins' contact group definition define contactgroup{ contactgroup_name linux-admins alias Linux Administrators members nagios } # 'switch-admins' contact group definition define contactgroup{ contactgroup_name switch-admins alias Etherswitch Administrators members nagios } # 'router-admins' contact group definition define contactgroup{ contactgroup_name router-admins alias Router Technicians members nagios } # 'printer-admins' contact group definition define contactgroup{ contactgroup_name printer-admins alias Printer Administrators members nagios,jdoe } ################################################################################ # HOST DEFINITIONS ################################################################################ # Generic host definition template define host{ name generic-host ; The name of this host template - referenced in other host definitions, used for template recursion/resolution notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host event handler is enabled flap_detection_enabled 1 ; Flap detection 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 HOST, JUST A TEMPLATE! } # 'novell1' host definition define host{ use generic-host ; Name of host template to use host_name novell1 alias Novell Server #1 address 192.168.1.2 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,u,r contact_groups novell-admins } # 'novell2' host definition define host{ use generic-host ; Name of host template to use host_name novell2 alias Novell Server #2 address 192.168.1.3 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,u,r contact_groups novell-admins } # 'nt1' host definition define host{ use generic-host ; Name of host template to use host_name nt1 alias NT Server #1 address 192.168.1.4 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,u,r contact_groups nt-admins } # 'nt2' host definition define host{ use generic-host ; Name of host template to use host_name nt2 alias NT Server #2 address 192.168.1.5 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,u,r contact_groups nt-admins } # 'linux1' host definition define host{ use generic-host ; Name of host template to use host_name linux1 alias Linux Server #1 address 192.169.1.6 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 480 notification_period 24x7 notification_options d,u,r contact_groups linux-admins } # 'linux2' host definition define host{ use generic-host ; Name of host template to use host_name linux2 alias Linux Server #2 address 192.168.0.2 parents router1 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 480 notification_period 24x7 notification_options d,u,r contact_groups linux-admins } # 'switch1' host definition define host{ use generic-host ; Name of host template to use host_name switch1 alias Switch #1 address 192.168.1.230 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups switch-admins } # 'switch2' host definition define host{ use generic-host ; Name of host template to use host_name switch2 alias Switch #2 address 192.168.1.231 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups switch-admins } # 'switch3' host definition define host{ use generic-host ; Name of host template to use host_name switch3 alias Switch #3 address 192.168.1.232 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups switch-admins } # 'switch4' host definition define host{ use generic-host ; Name of host template to use host_name switch4 alias Switch #4 address 192.168.1.233 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups switch-admins } # 'switch5' host definition define host{ use generic-host ; Name of host template to use host_name switch5 alias Switch #5 address 192.168.1.234 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups switch-admins } # 'router1' host definition define host{ use generic-host ; Name of host template to use host_name router1 alias Router #1 address 192.168.1.254 check_command check-host-alive max_check_attempts 20 check_period 24x7 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups router-admins } # 'printer1' host definition define host{ use generic-host ; Name of host template to use host_name printer1 alias Printer #1 address 192.168.1.100 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 480 notification_period workhours contact_groups printer-admins } # 'printer2' host definition define host{ use generic-host ; Name of host template to use host_name printer2 alias Printer #2 address 192.168.1.101 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 480 notification_period workhours contact_groups printer-admins } # 'printer3' host definition define host{ use generic-host ; Name of host template to use host_name printer3 alias Printer #3 address 192.168.1.102 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 480 notification_period workhours contact_groups printer-admins } ################################################################################ # HOST GROUP DEFINITIONS ################################################################################ # 'novell-servers' host group definition define hostgroup{ hostgroup_name novell-servers alias Novell Servers members novell1,novell2 } # 'nt-servers' host group definition define hostgroup{ hostgroup_name nt-servers alias NT Servers members nt1,nt2 } # 'linux-boxes' host group definition define hostgroup{ hostgroup_name linux-boxes alias Linux Servers members linux1,linux2 } # 'switches' host group definition define hostgroup{ hostgroup_name switches alias Switches members switch1,switch2,switch3,switch4,switch5 } # 'routers' host group definition define hostgroup{ hostgroup_name routers alias Routers members router1 } # 'printers' host group definition define hostgroup{ hostgroup_name printers alias Printers members printer1,printer2,printer3 } ################################################################################ # SERVICE DEFINITIONS ################################################################################ # Generic service definition template define service{ name generic-service ; The 'name' of this service template, referenced in other service definitions active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled/accepted parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) 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 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! } # Service definition define service{ use generic-service ; Name of service template to use host_name novell1 service_description SMTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 3 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_smtp } # Service definition define service{ use generic-service ; Name of service template to use host_name novell1 service_description FTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_ftp } # Service definition define service{ use generic-service ; Name of service template to use host_name novell1 service_description POP3 is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_pop } # Service definition define service{ use generic-service ; Name of service template to use host_name novell1 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name novell2 service_description SMTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 3 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_smtp } # Service definition define service{ use generic-service ; Name of service template to use host_name novell2 service_description FTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_ftp } # Service definition define service{ use generic-service ; Name of service template to use host_name novell2 service_description POP3 is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_pop } # Service definition define service{ use generic-service ; Name of service template to use host_name novell2 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name nt1 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name nt1 service_description FTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_ftp } # Service definition define service{ use generic-service ; Name of service template to use host_name nt1 service_description HTTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_http } # Service definition define service{ use generic-service ; Name of service template to use host_name nt2 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name nt2 service_description FTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_ftp } # Service definition define service{ use generic-service ; Name of service template to use host_name nt2 service_description HTTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_http } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description HTTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 2 retry_check_interval 1 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_http } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description Current Users is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 2 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_local_users!75!150 } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description Total Processes is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 2 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_local_procs!150!200!RSZDT } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description /dev/hda1 Free Space is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_local_disk!20%!10%!/dev/hda1 } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description /dev/hdb2 Free Space is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_local_disk!20%!10%!/dev/hdb2 } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description HTTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 2 retry_check_interval 1 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_http } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description Current Users is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 2 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_local_users!75!150 } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description Total Processes is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 2 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_local_procs!150!200!RSZDT } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description /dev/hda1 Free Space is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_local_disk!20%!10%!/dev/hda1 } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description /dev/hdb1 Free Space is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_local_disk!20%!10%!/dev/hdb1 } # Service definition define service{ use generic-service ; Name of service template to use host_name switch1 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups switch-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name switch2 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups switch-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name switch3 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups switch-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name switch4 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups switch-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name switch5 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups switch-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name router1 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups router-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name printer1 service_description Printer Status is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours notification_options c,r check_command check_hpjd } # Service definition define service{ use generic-service ; Name of service template to use host_name printer1 service_description PING is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name printer2 service_description Printer Status is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours check_command check_hpjd } # Service definition define service{ use generic-service ; Name of service template to use host_name printer2 service_description PING is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name printer3 service_description Printer Status is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours check_command check_hpjd } # Service definition define service{ use generic-service ; Name of service template to use host_name printer3 service_description PING is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours notification_options c,r check_command check_ping!100.0,20%!500.0,60% } ################################################################################ # SERVICE DEPENDENCY DEFINITIONS ################################################################################ # Servicedependency definition define servicedependency{ host_name nt1 service_description IIS Process dependent_host_name nt1 dependent_service_description Website #1 execution_failure_criteria n ; These are the criteria for which check execution will be suppressed notification_failure_criteria w,u,c ; These are the criteria for which notifications will be suppressed } # Servicedependency definition define servicedependency{ host_name nt1 service_description IIS Process dependent_host_name nt1 dependent_service_description Website #2 execution_failure_criteria w,u,c ; These are the criteria for which check execution will be suppressed notification_failure_criteria w,u,c ; These are the criteria for which notifications will be suppressed } ################################################################################ # HOST DEPENDENCY DEFINITIONS ################################################################################ # Hostdependency definition define hostdependency{ host_name nt1 dependent_host_name nt2 notification_failure_criteria d ; These are the criteria for which notifications will be suppressed } ################################################################################ # SERVICE ESCALATION DEFINITIONS ################################################################################ # Serviceescalation definition define serviceescalation{ host_name linux1 service_description PING first_notification 2 last_notification 6 contact_groups linux-admins,novell-admins notification_interval 0 } # Serviceescalation definition define serviceescalation{ host_name linux1 service_description Current Users first_notification 5 last_notification 0 contact_groups linux-admins,novell-admins notification_interval 0 } ################################################################################ # HOST ESCALATION DEFINITIONS ################################################################################ # Host 'nt1' escalation definition define hostescalation{ host_name nt1 first_notification 2 last_notification 5 contact_groups novell-admins,nt-admins notification_interval 10 } Nagios-Object-0.21.20/t/service_escalation.cfg000444001750001750 174512220262237 22403 0ustar00dfergusondferguson000000000000define host{ host_name host1 address 192.168.0.1 } define host{ host_name host2 address 192.168.0.2 } define host{ host_name host3 address 192.168.0.3 hostgroups servers } define hostgroup{ hostgroup_name servers } define serviceescalation{ host_name host3 service_description http check contact_groups all-escalation } define serviceescalation{ hostgroup_name servers service_description cpu contact_groups all-escalation } define service{ host_name host1,host2 service_description http check check_command check_http } define service{ host_name host1,host2 service_description cpu check_command check_load } define service{ host_name host3 service_description http check contact_groups all-page check_command check_http } define service{ hostgroup_name servers service_description cpu contact_groups all-page check_command check_load } Nagios-Object-0.21.20/t/60flexible-attributes1.cfg000444001750001750 135512220262237 22743 0ustar00dfergusondferguson000000000000define command { command_name check_load ; same-line comment command_line $USER1$/check_load } ; comment on a line by itself define contact { use generic-contact contact_name testuser2 alias Another Test User email nobody@localhost ; email ; next line is pager ... this comment could end up in the wrong place pager 1234567890 ; previous line was pager ... what will happen to this comment? random_one 1 random_two a,b,c random_three 89 } define contactgroup { contactgroup_name morecontacts alias More Test Contacts members testuser1,testuser2 } ; I hope this doesn't get lost Nagios-Object-0.21.20/t/sample-config-minimal.cfg000444001750001750 3271112220262237 22726 0ustar00dfergusondferguson000000000000############################################################################### # MINIMAL.CFG # # MINIMALISTIC OBJECT CONFIG FILE (Template-Based Object File Format) # # Last Modified: 05-30-2006 # # # NOTE: This config file is intended to be used to test a Nagios installation # that has been compiled with support for the template-based object # configuration files. # # This config file is intended to servce as an *extremely* simple # example of how you can create your object configuration file(s). # If you're interested in more complex object configuration files for # Nagios, look in the sample-config/template-object/ subdirectory of # the distribution. # ############################################################################### ############################################################################### ############################################################################### # # TIME PERIODS # ############################################################################### ############################################################################### # This defines a timeperiod where all times are valid for checks, # notifications, etc. The classic "24x7" support nightmare. :-) define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } ############################################################################### ############################################################################### # # COMMANDS # ############################################################################### ############################################################################### # This is a sample service notification command that can be used to send email # notifications (about service alerts) to contacts. define command{ command_name notify-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ } # This is a sample host notification command that can be used to send email # notifications (about host alerts) to contacts. define command{ command_name host-notify-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$ } # Command to check to see if a host is "alive" (up) by pinging it define command{ command_name check-host-alive command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 99,99% -c 100,100% -p 1 } # Generic command to check a device by pinging it define command{ command_name check_ping command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5 } # Command used to check disk space usage on local partitions define command{ command_name check_local_disk command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ } # Command used to check the number of currently logged in users on the # local machine define command{ command_name check_local_users command_line $USER1$/check_users -w $ARG1$ -c $ARG2$ } # Command to check the number of running processing on the local machine define command{ command_name check_local_procs command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ } # Command to check the load on the local machine define command{ command_name check_local_load command_line $USER1$/check_load -w $ARG1$ -c $ARG2$ } ############################################################################### ############################################################################### # # CONTACTS # ############################################################################### ############################################################################### # In this simple config file, a single contact will receive all alerts. # This assumes that you have an account (or email alias) called # "nagios-admin" on the local host. define contact{ contact_name nagios-admin alias Nagios Admin service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email email nagios-admin@localhost } ############################################################################### ############################################################################### # # CONTACT GROUPS # ############################################################################### ############################################################################### # We only have one contact in this simple configuration file, so there is # no need to create more than one contact group. define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagios-admin } ############################################################################### ############################################################################### # # HOSTS # ############################################################################### ############################################################################### # Generic host definition template - This is NOT a real host, just a template! define host{ name generic-host ; The name of this host template notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host 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 HOST, JUST A TEMPLATE! } # Since this is a simple configuration file, we only monitor one host - the # local host (this machine). define host{ use generic-host ; Name of host template to use host_name localhost alias localhost address 127.0.0.1 check_command check-host-alive max_check_attempts 10 check_period 24x7 notification_interval 120 notification_period 24x7 notification_options d,r contact_groups admins } ############################################################################### ############################################################################### # # HOST GROUPS # ############################################################################### ############################################################################### # We only have one host in our simple config file, so there is no need to # create more than one hostgroup. define hostgroup{ hostgroup_name test alias Test Servers members localhost } ############################################################################### ############################################################################### # # SERVICES # ############################################################################### ############################################################################### # Generic service definition template - This is NOT a real service, just a template! define service{ name generic-service ; The 'name' of this service template active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled/accepted parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) 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! } # Define a service to "ping" the local machine define service{ use generic-service ; Name of service template to use host_name localhost service_description PING is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_ping!100.0,20%!500.0,60% } # Define a service to check the disk space of the root partition # on the local machine. Warning if < 20% free, critical if # < 10% free space on partition. define service{ use generic-service ; Name of service template to use host_name localhost service_description Root Partition is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_disk!20%!10%!/ } # Define a service to check the number of currently logged in # users on the local machine. Warning if > 20 users, critical # if > 50 users. define service{ use generic-service ; Name of service template to use host_name localhost service_description Current Users is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_users!20!50 } # Define a service to check the number of currently running procs # on the local machine. Warning if > 250 processes, critical if # > 400 users. define service{ use generic-service ; Name of service template to use host_name localhost service_description Total Processes is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_procs!250!400 } # Define a service to check the load on the local machine. define service{ use generic-service ; Name of service template to use host_name localhost service_description Current Load is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_options w,u,c,r notification_interval 960 notification_period 24x7 check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 } # EOF Nagios-Object-0.21.20/t/00object.t000444001750001750 1407212220262237 17670 0ustar00dfergusondferguson000000000000#!/usr/bin/perl -w use lib qw( ../lib ./lib ); use Test::More qw(no_plan); use Test::NoWarnings; use_ok('Nagios::Object'); can_ok( 'Nagios::Host', 'host_name' ); can_ok( 'Nagios::Host', 'new' ); my $timetxt = '00:00-09:00,17:00-24:00'; ok( my $timerange = Nagios::Object::parse_time_range($timetxt), "parse_time_range( $timetxt )" ); ok( eq_array( $timerange, [ [ 0, 32400 ], [ 61200, 86400 ] ] ), "verify data returned by parse_time_range" ); diag("creating a Nagios::TimePeriod object ...") if ( $ENV{TEST_VERBOSE} ); my $tp = Nagios::TimePeriod->new( timeperiod_name => '24x7', alias => '24x7', sunday => '00:00-24:00', monday => '00:00-12:00,12:00-24:00', tuesday => '00:00-24:00', wednesday => '00:00-24:00', thursday => '00:00-24:00', friday => '00:00-24:00', saturday => '00:00-24:00' ); isa_ok( $tp, 'Nagios::Object' ); diag("creating a Nagios::Command object ...") if ( $ENV{TEST_VERBOSE} ); my $cmd = Nagios::Command->new( command_name => 'Test', command_line => '/bin/true' ); isa_ok( $cmd, 'Nagios::Object' ); diag("creating a Nagios::Contact object ...") if ( $ENV{TEST_VERBOSE} ); my $contact = Nagios::Contact->new( contact_name => "testuser", alias => "The Testing User", host_notification_period => $tp, service_notification_period => $tp, host_notification_options => [qw(d u r n)], service_notification_options => [qw(w u c r n)], host_notification_commands => $cmd, service_notification_commands => $cmd, email => 'testuser@localhost', pager => '5555555555' ); diag("creating a Nagios::ContactGroup object ...") if ( $ENV{TEST_VERBOSE} ); my $cg = Nagios::ContactGroup->new( alias => 'A Test Contact Group', contactgroup_name => 'testgroup', members => [$contact] ); diag("creating a Nagios::Host object ...") if ( $ENV{TEST_VERBOSE} ); my $host = Nagios::Host->new( host_name => 'localhost', alias => 'localhost', address => '127.0.0.1', parents => undef, check_command => 'check-host-alive', max_check_attempts => 3, checks_enabled => 1, event_handler => 'command_name', event_handler_enabled => 0, low_flap_threshold => 0, high_flap_threshold => 0, flap_detection_enabled => 0, process_perf_data => 1, retain_status_information => 1, retain_nonstatus_information => 1, notification_interval => 120, notification_options => [qw(d u r)], notifications_enabled => 1, stalking_options => [qw(o d u)] ); isa_ok( $host, 'Nagios::Object' ); can_ok( $host, 'host_name' ); is( $host->host_name(), 'localhost', "Nagios::Host->host_name() returns correct value" ); can_ok( $host, 'set_alias' ); can_ok( $host, 'alias' ); ok( $host->set_alias("bar"), "Nagios::Host->set_alias() works" ); is( $host->alias(), "bar", "Nagios::Host->alias() returns value set by previous test" ); diag("\ntesting templates ...\n\n") if ( $ENV{TEST_VERBOSE} ); diag("creating service template ...") if ( $ENV{TEST_VERBOSE} ); my $template = Nagios::Service->new( register => 0, host => $host, description => 'Test::More', is_volatile => 0, check_command => $cmd, max_check_attempts => 1, normal_check_interval => 1, retry_check_interval => 1, active_checks_enabled => 1, passive_checks_enabled => 1, check_period => $tp, parallelize_check => 1, obsess_over_service => 1, check_freshness => 1, freshness_threshhold => 5, event_handler => $cmd, event_handler_enabled => 1, low_flap_threshhold => 3, high_flap_threshhold => 5, flap_detection_enabled => 1, process_perf_data => 1, retain_status_information => 1, retain_nonstatus_information => 1, notification_interval => 120, notification_options => [qw(u w c r)], contact_groups => [], notifications_enabled => 1, stalking_options => [qw(o w u c)] ); isa_ok( $template, 'Nagios::Object' ); foreach my $pkg ( qw( Service Host HostGroup Contact ContactGroup Command TimePeriod ServiceEscalation ServiceDependency HostEscalation HostDependency HostGroupEscalation ) ) { my $fqpkg = 'Nagios::' . $pkg; ok( my $object = $fqpkg->new(), "$fqpkg->new()" ); my $vfref; UGLY: { no strict 'refs'; $vfref = ${ $fqpkg . '::valid_fields' }; } # make sure all objects have all the methods defind for their attributes # - these are the compile-time created methods foreach my $method ( keys(%$vfref) ) { can_ok( $object, $method ); $object->$method(); can_ok( $object, "set_$method" ); } # make sure all objects can call the "regular" methods foreach my $method ( qw( list_attributes attribute_type attribute_is_list name )) { can_ok( $object, $method ); } # make sure ->name returns the right data for an object #foreach my $pkg } ok( my $empty_cmd = Nagios::Object->new( Type => 'Nagios::Command' ), "Nagios::Object->new( Type => Nagios::Command )" ); can_ok( $empty_cmd, 'set_command_name' ); ok( my $empty_tp = Nagios::Object->new( Type => 'Nagios::TimePeriod' ), "Nagios::Object->new( Type => Nagios::TimePeriod )" ); can_ok( $empty_tp, 'timeperiod_name' ); can_ok( $empty_tp, 'set_timeperiod_name' ); ok( $empty_tp->set_timeperiod_name("foobar"), "\$object->set_timeperiod_name" ); is( $empty_tp->timeperiod_name, 'foobar', "\$object->timeperiod_name" ); is( $empty_tp->name, 'foobar', "\$object->name" ); Nagios-Object-0.21.20/t/v2_config000755001750001750 012220262237 17570 5ustar00dfergusondferguson000000000000Nagios-Object-0.21.20/t/v2_config/hostgroups.cfg000444001750001750 310612220262237 22623 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 06-11-2004 # ################################################################################ ################################################################################ # HOST GROUP DEFINITIONS # # SYNTAX: # ################################################################################ # 'novell-servers' host group definition define hostgroup{ hostgroup_name novell-servers alias Novell Servers members novell1,novell2 } # 'nt-servers' host group definition define hostgroup{ hostgroup_name nt-servers alias NT Servers members nt1,nt2 } # 'linux-boxes' host group definition define hostgroup{ hostgroup_name linux-boxes alias Linux Servers members linux1,linux2 } # 'switches' host group definition define hostgroup{ hostgroup_name switches alias Switches members switch1,switch2,switch3,switch4,switch5 } # 'routers' host group definition define hostgroup{ hostgroup_name routers alias Routers members router1 } # 'printers' host group definition define hostgroup{ hostgroup_name printers alias Printers members printer1,printer2,printer3 } define hostgroup { hostgroup_name all alias All Hosts contact_groups * members * } Nagios-Object-0.21.20/t/v2_config/minimal.cfg000444001750001750 3241712220262237 22063 0ustar00dfergusondferguson000000000000############################################################################### # MINIMAL.CFG # # MINIMALISTIC OBJECT CONFIG FILE (Template-Based Object File Format) # # Last Modified: 10-03-2002 # # # NOTE: This config file is intended to be used to test a Nagios installation # that has been compiled with support for the template-based object # configuration files. # # This config file is intended to servce as an *extremely* simple # example of how you can create your object configuration file(s). # If you're interested in more complex object configuration files for # Nagios, look in the sample-config/template-object/ subdirectory of # the distribution. # ############################################################################### ############################################################################### ############################################################################### # # TIME PERIODS # ############################################################################### ############################################################################### # This defines a timeperiod where all times are valid for checks, # notifications, etc. The classic "24x7" support nightmare. :-) define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } ############################################################################### ############################################################################### # # COMMANDS # ############################################################################### ############################################################################### # This is a sample service notification command that can be used to send email # notifications (about service alerts) to contacts. define command{ command_name notify-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $DATETIME$\n\nAdditional Info:\n\n$OUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ } # This is a sample host notification command that can be used to send email # notifications (about host alerts) to contacts. define command{ command_name host-notify-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $OUTPUT$\n\nDate/Time: $DATETIME$\n" | /bin/mail -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$ } # Command to check to see if a host is "alive" (up) by pinging it define command{ command_name check-host-alive command_line /bin/check_ping -H $HOSTADDRESS$ -w 99,99% -c 100,100% -p 1 } # Generic command to check a device by pinging it define command{ command_name check_ping command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5 } # Command used to check disk space usage on local partitions define command{ command_name check_local_disk command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ } # Command used to check the number of currently logged in users on the # local machine define command{ command_name check_local_users command_line $USER1$/check_users -w $ARG1$ -c $ARG2$ } # Command to check the number of running processing on the local machine define command{ command_name check_local_procs command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ } # Command to check the load on the local machine define command{ command_name check_local_load command_line $USER1$/check_load -w $ARG1$ -c $ARG2$ } ############################################################################### ############################################################################### # # CONTACTS # ############################################################################### ############################################################################### # In this simple config file, a single contact will receive all alerts. # This assumes that you have an account (or email alias) called # "nagios-admin" on the local host. define contact{ contact_name nagios-admin alias Nagios Admin service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email email nagios-admin@localhost } ############################################################################### ############################################################################### # # CONTACT GROUPS # ############################################################################### ############################################################################### # We only have one contact in this simple configuration file, so there is # no need to create more than one contact group. define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagios-admin } ############################################################################### ############################################################################### # # HOSTS # ############################################################################### ############################################################################### # Generic host definition template - This is NOT a real host, just a template! define host{ name generic-host ; The name of this host template notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host 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 HOST, JUST A TEMPLATE! } # Since this is a simple configuration file, we only monitor one host - the # local host (this machine). define host{ use generic-host ; Name of host template to use host_name localhost alias localhost address 127.0.0.1 check_command check-host-alive max_check_attempts 10 notification_interval 120 notification_period 24x7 notification_options d,r } ############################################################################### ############################################################################### # # HOST GROUPS # ############################################################################### ############################################################################### # We only have one host in our simple config file, so there is no need to # create more than one hostgroup. define hostgroup{ hostgroup_name test alias Test Servers contact_groups admins members localhost } ############################################################################### ############################################################################### # # SERVICES # ############################################################################### ############################################################################### # Generic service definition template - This is NOT a real service, just a template! define service{ name generic-service ; The 'name' of this service template active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled/accepted parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) 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! } # Define a service to "ping" the local machine define service{ use generic-service ; Name of service template to use host_name localhost service_description PING is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_interval 960 notification_period 24x7 check_command check_ping!100.0,20%!500.0,60% } # Define a service to check the disk space of the root partition # on the local machine. Warning if < 20% free, critical if # < 10% free space on partition. define service{ use generic-service ; Name of service template to use host_name localhost service_description Root Partition is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_interval 960 notification_period 24x7 check_command check_local_disk!20%!10%!/ } # Define a service to check the number of currently logged in # users on the local machine. Warning if > 20 users, critical # if > 50 users. define service{ use generic-service ; Name of service template to use host_name localhost service_description Current Users is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_interval 960 notification_period 24x7 check_command check_local_users!20!50 } # Define a service to check the number of currently running procs # on the local machine. Warning if > 250 processes, critical if # > 400 users. define service{ use generic-service ; Name of service template to use host_name localhost service_description Total Processes is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_interval 960 notification_period 24x7 check_command check_local_procs!250!400 } # Define a service to check the load on the local machine. define service{ use generic-service ; Name of service template to use host_name localhost service_description Current Load is_volatile 0 check_period 24x7 max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups admins notification_interval 960 notification_period 24x7 check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 } # EOF Nagios-Object-0.21.20/t/v2_config/resource.cfg000444001750001750 245312220262237 22241 0ustar00dfergusondferguson000000000000########################################################################### # # RESOURCE.CFG - Sample Resource File for Nagios # # Last Modified: 09-10-2003 # # You can define $USERx$ macros in this file, which can in turn be used # in command definitions in your host config file(s). $USERx$ macros are # useful for storing sensitive information such as usernames, passwords, # etc. They are also handy for specifying the path to plugins and # event handlers - if you decide to move the plugins or event handlers to # a different directory in the future, you can just update one or two # $USERx$ macros, instead of modifying a lot of command definitions. # # The CGIs will not attempt to read the contents of resource files, so # you can set restrictive permissions (600 or 660) on them. # # Nagios supports up to 32 $USERx$ macros ($USER1$ through $USER32$) # # Resource files may also be used to store configuration directives for # external data sources like MySQL... # ########################################################################### # Sets $USER1$ to be the path to the plugins $USER1$=/opt/nagios/libexec # Sets $USER2$ to be the path to event handlers #$USER2$=/opt/nagios/libexec/eventhandlers # Store some usernames and passwords (hidden from the CGIs) #$USER3$=someuser #$USER4$=somepassword Nagios-Object-0.21.20/t/v2_config/contacts.cfg000444001750001750 271012220262237 22224 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 03-07-2002 # ################################################################################ ################################################################################ # CONTACT DEFINITIONS # # SYNTAX: # ################################################################################ # 'nagios' contact definition define contact{ contact_name nagios alias Nagios Admin service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,u,r service_notification_commands notify-by-email,notify-by-epager host_notification_commands host-notify-by-email,host-notify-by-epager email nagios-admin@localhost.localdomain pager pagenagios-admin@localhost.localdomain } # 'jdoe' contact definition define contact{ contact_name jdoe alias John Doe service_notification_period workhours host_notification_period workhours service_notification_options c,r host_notification_options d,r service_notification_commands notify-by-email host_notification_commands host-notify-by-email email jdoe@localhost.localdomain } Nagios-Object-0.21.20/t/v2_config/timeperiods.cfg000444001750001750 306512220262237 22736 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 03-07-2002 # ################################################################################ ################################################################################ # TIMEPERIOD DEFINITIONS # # SYNTAX: # ################################################################################ # '24x7' timeperiod definition define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } # 'workhours' timeperiod definition define timeperiod{ timeperiod_name workhours alias "Normal" Working Hours monday 09:00-17:00 tuesday 09:00-17:00 wednesday 09:00-17:00 thursday 09:00-17:00 friday 09:00-17:00 } # 'nonworkhours' timeperiod definition define timeperiod{ timeperiod_name nonworkhours alias Non-Work Hours sunday 00:00-24:00 monday 00:00-09:00,17:00-24:00 tuesday 00:00-09:00,17:00-24:00 wednesday 00:00-09:00,17:00-24:00 thursday 00:00-09:00,17:00-24:00 friday 00:00-09:00,17:00-24:00 saturday 00:00-24:00 } # 'none' timeperiod definition define timeperiod{ timeperiod_name none alias No Time Is A Good Time } Nagios-Object-0.21.20/t/v2_config/contactgroups.cfg000444001750001750 304012220262237 23276 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 10-03-2002 # ################################################################################ ################################################################################ # CONTACT GROUP DEFINITIONS # # SYNTAX: # ################################################################################ # 'novell-admins' contact group definition define contactgroup{ contactgroup_name novell-admins alias Novell Administrators members nagios } # 'nt-admins' contact group definition define contactgroup{ contactgroup_name nt-admins alias NT Administrators members nagios,jdoe } # 'linux-admins' contact group definition define contactgroup{ contactgroup_name linux-admins alias Linux Administrators members nagios } # 'switch-admins' contact group definition define contactgroup{ contactgroup_name switch-admins alias Etherswitch Administrators members nagios } # 'router-admins' contact group definition define contactgroup{ contactgroup_name router-admins alias Router Technicians members nagios } # 'printer-admins' contact group definition define contactgroup{ contactgroup_name printer-admins alias Printer Administrators members nagios,jdoe } Nagios-Object-0.21.20/t/v2_config/dependencies.cfg000444001750001750 315612220262237 23041 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 03-07-2002 # ################################################################################ ################################################################################ # SERVICE DEPENDENCY DEFINITIONS # # SYNTAX: # ################################################################################ # Servicedependency definition define servicedependency{ host_name nt1 service_description IIS Process dependent_host_name nt1 dependent_service_description Website #1 execution_failure_criteria n ; These are the criteria for which check execution will be supressed notification_failure_criteria w,u,c ; These are the criteria for which notifications will be supressed } # Servicedependency definition define servicedependency{ host_name nt1 service_description IIS Process dependent_host_name nt1 dependent_service_description Website #2 execution_failure_criteria w,u,c ; These are the criteria for which check execution will be supressed notification_failure_criteria w,u,c ; These are the criteria for which notifications will be supressed } ################################################################################ # HOST DEPENDENCY DEFINITIONS # # SYNTAX: # ################################################################################ Nagios-Object-0.21.20/t/v2_config/hosts.cfg000444001750001750 1412312220262237 21567 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 06-11-2004 # ################################################################################ ################################################################################ # HOST DEFINITIONS # # SYNTAX: # ################################################################################ # Generic host definition template define host{ name generic-host ; The name of this host template - referenced in other host definitions, used for template recursion/resolution notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host event handler is enabled flap_detection_enabled 1 ; Flap detection 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 HOST, JUST A TEMPLATE! } # 'novell1' host definition define host{ use generic-host ; Name of host template to use host_name novell1 alias Novell Server #1 address 192.168.1.2 check_command check-host-alive max_check_attempts 10 notification_interval 120 notification_period 24x7 notification_options d,u,r contact_groups novell-admins } # 'novell2' host definition define host{ use generic-host ; Name of host template to use host_name novell2 alias Novell Server #2 address 192.168.1.3 check_command check-host-alive max_check_attempts 10 notification_interval 120 notification_period 24x7 notification_options d,u,r contact_groups novell-admins } # 'nt1' host definition define host{ use generic-host ; Name of host template to use host_name nt1 alias NT Server #1 address 192.168.1.4 check_command check-host-alive max_check_attempts 10 notification_interval 120 notification_period 24x7 notification_options d,u,r contact_groups nt-admins } # 'nt2' host definition define host{ use generic-host ; Name of host template to use host_name nt2 alias NT Server #2 address 192.168.1.5 check_command check-host-alive max_check_attempts 10 notification_interval 120 notification_period 24x7 notification_options d,u,r contact_groups nt-admins } # 'linux1' host definition define host{ use generic-host ; Name of host template to use host_name linux1 alias Linux Server #1 address 192.169.1.6 check_command check-host-alive max_check_attempts 10 notification_interval 480 notification_period 24x7 notification_options d,u,r contact_groups linux-admins } # 'linux2' host definition define host{ use generic-host ; Name of host template to use host_name linux2 alias Linux Server #2 address 192.168.0.2 parents router1 check_command check-host-alive max_check_attempts 10 notification_interval 480 notification_period 24x7 notification_options d,u,r contact_groups linux-admins } # 'switch1' host definition define host{ use generic-host ; Name of host template to use host_name switch1 alias Switch #1 address 192.168.1.230 check_command check-host-alive max_check_attempts 10 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups switch-admins } # 'switch2' host definition define host{ use generic-host ; Name of host template to use host_name switch2 alias Switch #2 address 192.168.1.231 check_command check-host-alive max_check_attempts 10 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups switch-admins } # 'switch3' host definition define host{ use generic-host ; Name of host template to use host_name switch3 alias Switch #3 address 192.168.1.232 check_command check-host-alive max_check_attempts 10 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups switch-admins } # 'switch4' host definition define host{ use generic-host ; Name of host template to use host_name switch4 alias Switch #4 address 192.168.1.233 check_command check-host-alive max_check_attempts 10 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups switch-admins } # 'switch5' host definition define host{ use generic-host ; Name of host template to use host_name switch5 alias Switch #5 address 192.168.1.234 check_command check-host-alive max_check_attempts 10 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups switch-admins } # 'router1' host definition define host{ use generic-host ; Name of host template to use host_name router1 alias Router #1 address 192.168.1.254 check_command check-host-alive max_check_attempts 20 notification_interval 60 notification_period 24x7 notification_options d,u,r contact_groups router-admins } # 'printer1' host definition define host{ use generic-host ; Name of host template to use host_name printer1 alias Printer #1 address 192.168.1.100 check_command check-host-alive max_check_attempts 10 notification_interval 480 notification_period workhours contact_groups printer-admins } # 'printer2' host definition define host{ use generic-host ; Name of host template to use host_name printer2 alias Printer #2 address 192.168.1.101 check_command check-host-alive max_check_attempts 10 notification_interval 480 notification_period workhours contact_groups printer-admins } # 'printer3' host definition define host{ use generic-host ; Name of host template to use host_name printer3 alias Printer #3 address 192.168.1.102 check_command check-host-alive max_check_attempts 10 notification_interval 480 notification_period workhours contact_groups printer-admins } Nagios-Object-0.21.20/t/v2_config/checkcommands.cfg000444001750001750 1057312220262237 23233 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 06-09-2002 # ################################################################################ ################################################################################ # COMMAND DEFINITIONS # # SYNTAX: # # define command{ # template # name # command_name # command_line # } # # WHERE: # # = object name of another command definition that should be # used as a template for this definition (optional) # = object name of command definition, referenced by other # command definitions that use it as a template (optional) # = name of the command, as recognized/used by Nagios # = command line # ################################################################################ ################################################################################ # # SAMPLE SERVICE CHECK COMMANDS # # These are some example service check commands. They may or may not work on # your system, as they must be modified for your plugins. See the HTML # documentation on the plugins for examples of how to configure command definitions. # ################################################################################ # 'check_tcp' command definition define command{ command_name check_tcp command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ } # 'check_udp' command definition define command{ command_name check_udp command_line $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$ } # 'check_ftp' command definition define command{ command_name check_ftp command_line $USER1$/check_ftp -H $HOSTADDRESS$ } # 'check_pop' command definition define command{ command_name check_pop command_line $USER1$/check_pop -H $HOSTADDRESS$ } # 'check_smtp' command definition define command{ command_name check_smtp command_line $USER1$/check_smtp -H $HOSTADDRESS$ } # 'check_nntp' command definition define command{ command_name check_nntp command_line $USER1$/check_nntp -H $HOSTADDRESS$ } # 'check_http' command definition define command{ command_name check_http command_line $USER1$/check_http -H $HOSTADDRESS$ } # 'check_telnet' command definition define command{ command_name check_telnet command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p 23 } # 'check_ping' command definition define command{ command_name check_ping command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5 } # 'check_dns' command definition define command{ command_name check_dns command_line $USER1$/check_dns -H www.yahoo.com -s $HOSTADDRESS$ } # 'check_hpjd' command definition define command{ command_name check_hpjd command_line $USER1$/check_hpjd -H $HOSTADDRESS$ -C public } # 'check_local_disk' command definition define command{ command_name check_local_disk command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ } # 'check_local_users' command definition define command{ command_name check_local_users command_line $USER1$/check_users -w $ARG1$ -c $ARG2$ } # 'check_local_procs' command definition define command{ command_name check_local_procs command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$ } # 'check_local_load' command definition define command{ command_name check_local_load command_line $USER1$/check_load -w $ARG1$ -c $ARG2$ } ################################################################################ # # SAMPLE HOST CHECK COMMANDS # ################################################################################ # This command checks to see if a host is "alive" by pinging it # The check must result in a 100% packet loss or 5 second (5000ms) round trip # average time to produce a critical error. # Note: Only one ICMP echo packet is sent (determined by the '-p 1' argument) # 'check-host-alive' command definition define command{ command_name check-host-alive command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 1 } Nagios-Object-0.21.20/t/v2_config/servicegroups.cfg000444001750001750 150312220262237 23305 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 11 Mar 2009 # ################################################################################ ################################################################################ # SERVICE GROUP DEFINITIONS # # SYNTAX: # ################################################################################ # 'novell-servers' host group definition define servicegroup{ servicegroup_name svcgroup1 alias Service Group 1 members novell1, FTP, novell1, POP3, novell2, SMTP } Nagios-Object-0.21.20/t/v2_config/escalations.cfg000444001750001750 301012220262237 22705 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 03-07-2002 # ################################################################################ ################################################################################ # SERVICE ESCALATION DEFINITIONS # # SYNTAX: # ################################################################################ # Serviceescalation definition define serviceescalation{ host_name linux1 service_description PING first_notification 2 last_notification 6 contact_groups linux-admins,novell-admins notification_interval 0 } # Serviceescalation definition define serviceescalation{ host_name linux1 service_description Current Users first_notification 5 last_notification 0 contact_groups linux-admins,novell-admins notification_interval 0 } ################################################################################ # HOSTGROUP ESCALATION DEFINITIONS # # SYNTAX: # ################################################################################ ################################################################################ # HOST ESCALATION DEFINITIONS # # SYNTAX: # ################################################################################ Nagios-Object-0.21.20/t/v2_config/cgi.cfg000444001750001750 2251612220262237 21176 0ustar00dfergusondferguson000000000000################################################################# # # CGI.CFG - Sample CGI Configuration File for Nagios # # Last Modified: 10-08-2003 # ################################################################# # MAIN CONFIGURATION FILE # This tells the CGIs where to find your main configuration file. # The CGIs will read the main and host config files for any other # data they might need. main_config_file=/opt/nagios/etc/nagios.cfg # PHYSICAL HTML PATH # This is the path where the HTML files for Nagios reside. This # value is used to locate the logo images needed by the statusmap # and statuswrl CGIs. physical_html_path=/opt/nagios/share # URL HTML PATH # This is the path portion of the URL that corresponds to the # physical location of the Nagios HTML files (as defined above). # This value is used by the CGIs to locate the online documentation # and graphics. If you access the Nagios pages with an URL like # http://www.myhost.com/nagios, this value should be '/nagios' # (without the quotes). url_html_path=/nagios # CONTEXT-SENSITIVE HELP # This option determines whether or not a context-sensitive # help icon will be displayed for most of the CGIs. # Values: 0 = disables context-sensitive help # 1 = enables context-sensitive help show_context_help=0 # NAGIOS PROCESS CHECK COMMAND # This is the full path and filename of the program used to check # the status of the Nagios process. It is used only by the CGIs # and is completely optional. However, if you don't use it, you'll # see warning messages in the CGIs about the Nagios process # not running and you won't be able to execute any commands from # the web interface. The program should follow the same rules # as plugins; the return codes are the same as for the plugins, # it should have timeout protection, it should output something # to STDIO, etc. # # Note: The command line for the check_nagios plugin below may # have to be tweaked a bit, as different versions of the plugin # use different command line arguments/syntaxes. #nagios_check_command=/opt/nagios/libexec/check_nagios /opt/nagios/var/status.log 5 '/opt/nagios/bin/nagios' # AUTHENTICATION USAGE # This option controls whether or not the CGIs will use any # authentication when displaying host and service information, as # well as committing commands to Nagios for processing. # # Read the HTML documentation to learn how the authorization works! # # NOTE: It is a really *bad* idea to disable authorization, unless # you plan on removing the command CGI (cmd.cgi)! Failure to do # so will leave you wide open to kiddies messing with Nagios and # possibly hitting you with a denial of service attack by filling up # your drive by continuously writing to your command file! # # Setting this value to 0 will cause the CGIs to *not* use # authentication (bad idea), while any other value will make them # use the authentication functions (the default). use_authentication=1 # DEFAULT USER # Setting this variable will define a default user name that can # access pages without authentication. This allows people within a # secure domain (i.e., behind a firewall) to see the current status # without authenticating. You may want to use this to avoid basic # authentication if you are not using a sercure server since basic # authentication transmits passwords in the clear. # # Important: Do not define a default username unless you are # running a secure web server and are sure that everyone who has # access to the CGIs has been authenticated in some manner! If you # define this variable, anyone who has not authenticated to the web # server will inherit all rights you assign to this user! #default_user_name=guest # SYSTEM/PROCESS INFORMATION ACCESS # This option is a comma-delimited list of all usernames that # have access to viewing the Nagios process information as # provided by the Extended Information CGI (extinfo.cgi). By # default, *no one* has access to this unless you choose to # not use authorization. You may use an asterisk (*) to # authorize any user who has authenticated to the web server. #authorized_for_system_information=nagiosadmin,theboss,jdoe # CONFIGURATION INFORMATION ACCESS # This option is a comma-delimited list of all usernames that # can view ALL configuration information (hosts, commands, etc). # By default, users can only view configuration information # for the hosts and services they are contacts for. You may use # an asterisk (*) to authorize any user who has authenticated # to the web server. #authorized_for_configuration_information=nagiosadmin,jdoe # SYSTEM/PROCESS COMMAND ACCESS # This option is a comma-delimited list of all usernames that # can issue shutdown and restart commands to Nagios via the # command CGI (cmd.cgi). Users in this list can also change # the program mode to active or standby. By default, *no one* # has access to this unless you choose to not use authorization. # You may use an asterisk (*) to authorize any user who has # authenticated to the web server. #authorized_for_system_commands=nagiosadmin # GLOBAL HOST/SERVICE VIEW ACCESS # These two options are comma-delimited lists of all usernames that # can view information for all hosts and services that are being # monitored. By default, users can only view information # for hosts or services that they are contacts for (unless you # you choose to not use authorization). You may use an asterisk (*) # to authorize any user who has authenticated to the web server. #authorized_for_all_services=nagiosadmin,guest #authorized_for_all_hosts=nagiosadmin,guest # GLOBAL HOST/SERVICE COMMAND ACCESS # These two options are comma-delimited lists of all usernames that # can issue host or service related commands via the command # CGI (cmd.cgi) for all hosts and services that are being monitored. # By default, users can only issue commands for hosts or services # that they are contacts for (unless you you choose to not use # authorization). You may use an asterisk (*) to authorize any # user who has authenticated to the web server. #authorized_for_all_service_commands=nagiosadmin #authorized_for_all_host_commands=nagiosadmin # STATUSMAP BACKGROUND IMAGE # This option allows you to specify an image to be used as a # background in the statusmap CGI. It is assumed that the image # resides in the HTML images path (i.e. /usr/local/nagios/share/images). # This path is automatically determined by appending "/images" # to the path specified by the 'physical_html_path' directive. # Note: The image file may be in GIF, PNG, JPEG, or GD2 format. # However, I recommend that you convert your image to GD2 format # (uncompressed), as this will cause less CPU load when the CGI # generates the image. #statusmap_background_image=smbackground.gd2 # DEFAULT STATUSMAP LAYOUT METHOD # This option allows you to specify the default layout method # the statusmap CGI should use for drawing hosts. If you do # not use this option, the default is to use user-defined # coordinates. Valid options are as follows: # 0 = User-defined coordinates # 1 = Depth layers # 2 = Collapsed tree # 3 = Balanced tree # 4 = Circular # 5 = Circular (Marked Up) default_statusmap_layout=5 # DEFAULT STATUSWRL LAYOUT METHOD # This option allows you to specify the default layout method # the statuswrl (VRML) CGI should use for drawing hosts. If you # do not use this option, the default is to use user-defined # coordinates. Valid options are as follows: # 0 = User-defined coordinates # 2 = Collapsed tree # 3 = Balanced tree # 4 = Circular default_statuswrl_layout=4 # STATUSWRL INCLUDE # This option allows you to include your own objects in the # generated VRML world. It is assumed that the file # resides in the HTML path (i.e. /usr/local/nagios/share). #statuswrl_include=myworld.wrl # PING SYNTAX # This option determines what syntax should be used when # attempting to ping a host from the WAP interface (using # the statuswml CGI. You must include the full path to # the ping binary, along with all required options. The # $HOSTADDRESS$ macro is substituted with the address of # the host before the command is executed. # Please note that the syntax for the ping binary is # notorious for being different on virtually ever *NIX # OS and distribution, so you may have to tweak this to # work on your system. ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$ # REFRESH RATE # This option allows you to specify the refresh rate in seconds # of various CGIs (status, statusmap, extinfo, and outages). refresh_rate=90 # SOUND OPTIONS # These options allow you to specify an optional audio file # that should be played in your browser window when there are # problems on the network. The audio files are used only in # the status CGI. Only the sound for the most critical problem # will be played. Order of importance (higher to lower) is as # follows: unreachable hosts, down hosts, critical services, # warning services, and unknown services. If there are no # visible problems, the sound file optionally specified by # 'normal_sound' variable will be played. # # # = # # Note: All audio files must be placed in the /media subdirectory # under the HTML path (i.e. /usr/local/nagios/share/media/). #host_unreachable_sound=hostdown.wav #host_down_sound=hostdown.wav #service_critical_sound=critical.wav #service_warning_sound=warning.wav #service_unknown_sound=warning.wav #normal_sound=noproblem.wav Nagios-Object-0.21.20/t/v2_config/services.cfg000444001750001750 4241312220262237 22255 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 09-17-2002 # ################################################################################ ################################################################################ # SERVICE DEFINITIONS # # SYNTAX: # ################################################################################ # Generic service definition template define service{ name generic-service ; The 'name' of this service template, referenced in other service definitions active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled/accepted parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) 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 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! } # Service definition define service{ use generic-service ; Name of service template to use host_name novell1 service_description SMTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 3 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_smtp } # Service definition define service{ use generic-service ; Name of service template to use host_name novell1 service_description FTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_ftp } # Service definition define service{ use generic-service ; Name of service template to use host_name novell1 service_description POP3 is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_pop } # Service definition define service{ use generic-service ; Name of service template to use host_name novell1 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name novell2 service_description SMTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 3 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_smtp } # Service definition define service{ use generic-service ; Name of service template to use host_name novell2 service_description FTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_ftp } # Service definition define service{ use generic-service ; Name of service template to use host_name novell2 service_description POP3 is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_pop } # Service definition define service{ use generic-service ; Name of service template to use host_name novell2 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups novell-admins notification_interval 120 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name nt1 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name nt1 service_description FTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_ftp } # Service definition define service{ use generic-service ; Name of service template to use host_name nt1 service_description HTTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_http } # Service definition define service{ use generic-service ; Name of service template to use host_name nt2 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name nt2 service_description FTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_ftp } # Service definition define service{ use generic-service ; Name of service template to use host_name nt2 service_description HTTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups nt-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_http } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description HTTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 2 retry_check_interval 1 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_http } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description Current Users is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 2 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_local_users!75!150 } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description Total Processes is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 2 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_local_procs!150!200!RSZDT } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description /dev/hda1 Free Space is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_local_disk!20%!10%!/dev/hda1 } # Service definition define service{ use generic-service ; Name of service template to use host_name linux1 service_description /dev/hdb2 Free Space is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_local_disk!20%!10%!/dev/hdb2 } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description HTTP is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 2 retry_check_interval 1 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_http } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description Current Users is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 2 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_local_users!75!150 } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description Total Processes is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 2 contact_groups linux-admins notification_interval 240 notification_period 24x7 notification_options w,u,c,r check_command check_local_procs!150!200!RSZDT } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description /dev/hda1 Free Space is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_local_disk!20%!10%!/dev/hda1 } # Service definition define service{ use generic-service ; Name of service template to use host_name linux2 service_description /dev/hdb1 Free Space is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups linux-admins notification_interval 120 notification_period 24x7 notification_options w,u,c,r check_command check_local_disk!20%!10%!/dev/hdb1 } # Service definition define service{ use generic-service ; Name of service template to use host_name switch1 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups switch-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name switch2 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups switch-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name switch3 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups switch-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name switch4 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups switch-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name switch5 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups switch-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name router1 service_description PING is_volatile 0 check_period 24x7 max_check_attempts 3 normal_check_interval 5 retry_check_interval 1 contact_groups router-admins notification_interval 240 notification_period 24x7 notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name printer1 service_description Printer Status is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours notification_options c,r check_command check_hpjd } # Service definition define service{ use generic-service ; Name of service template to use host_name printer1 service_description PING is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name printer2 service_description Printer Status is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours check_command check_hpjd } # Service definition define service{ use generic-service ; Name of service template to use host_name printer2 service_description PING is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours notification_options c,r check_command check_ping!100.0,20%!500.0,60% } # Service definition define service{ use generic-service ; Name of service template to use host_name printer3 service_description Printer Status is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours check_command check_hpjd } # Service definition define service{ use generic-service ; Name of service template to use host_name printer3 service_description PING is_volatile 0 check_period workhours max_check_attempts 4 normal_check_interval 5 retry_check_interval 1 contact_groups printer-admins notification_interval 960 notification_period workhours notification_options c,r check_command check_ping!100.0,20%!500.0,60% } Nagios-Object-0.21.20/t/v2_config/nagios.cfg000444001750001750 7404212220262237 21715 0ustar00dfergusondferguson000000000000############################################################################## # # NAGIOS.CFG - Sample Main Config File for Nagios # # Read the documentation for more information on this configuration # file. I've provided some comments here, but things may not be so # clear without further explanation. # # Last Modified: 09-02-2004 # ############################################################################## # LOG FILE # This is the main log file where service and host events are logged # for historical purposes. This should be the first option specified # in the config file!!! log_file=nagios.log # OBJECT CONFIGURATION FILE(S) # This is the configuration file in which you define hosts, host # groups, contacts, contact groups, services, etc. I guess it would # be better called an object definition file, but for historical # reasons it isn't. You can split object definitions into several # different config files by using multiple cfg_file statements here. # Nagios will read and process all the config files you define. # This can be very useful if you want to keep command definitions # separate from host and contact definitions... # Plugin commands (service and host check commands) # Arguments are likely to change between different releases of the # plugins, so you should use the same config file provided with the # plugin release rather than the one provided with Nagios. cfg_file=v2_config/checkcommands.cfg # Misc commands (notification and event handler commands, etc) cfg_file=v2_config/misccommands.cfg # You can split other types of object definitions across several # config files if you wish (as done here), or keep them all in a # single config file. cfg_file=v2_config/contactgroups.cfg cfg_file=v2_config/contacts.cfg cfg_file=v2_config/dependencies.cfg cfg_file=v2_config/escalations.cfg cfg_file=v2_config/hostgroups.cfg cfg_file=v2_config/servicegroups.cfg cfg_file=v2_config/hosts.cfg cfg_file=v2_config/services.cfg cfg_file=v2_config/timeperiods.cfg # Extended host/service info definitions are now stored along with # other object definitions: #cfg_file=/opt/nagios/etc/hostextinfo.cfg #cfg_file=/opt/nagios/etc/serviceextinfo.cfg # You can also tell Nagios to process all config files (with a .cfg # extension) in a particular directory by using the cfg_dir # directive as shown below: #cfg_dir=/opt/nagios/etc/servers #cfg_dir=/opt/nagios/etc/printers #cfg_dir=/opt/nagios/etc/switches #cfg_dir=/opt/nagios/etc/routers # OBJECT CACHE FILE # This option determines where object definitions are cached when # Nagios starts/restarts. The CGIs read object definitions from # this cache file (rather than looking at the object config files # directly) in order to prevent inconsistencies that can occur # when the config files are modified after Nagios starts. object_cache_file=objects.cache # RESOURCE FILE # This is an optional resource file that contains $USERx$ macro # definitions. Multiple resource files can be specified by using # multiple resource_file definitions. The CGIs will not attempt to # read the contents of resource files, so information that is # considered to be sensitive (usernames, passwords, etc) can be # defined as macros in this file and restrictive permissions (600) # can be placed on this file. resource_file=v2_config/resource.cfg # STATUS FILE # This is where the current status of all monitored services and # hosts is stored. Its contents are read and processed by the CGIs. # The contentsof the status file are deleted every time Nagios # restarts. status_file=status.dat # NAGIOS USER # This determines the effective user that Nagios should run as. # You can either supply a username or a UID. nagios_user=nagios # NAGIOS GROUP # This determines the effective group that Nagios should run as. # You can either supply a group name or a GID. nagios_group=nobody # EXTERNAL COMMAND OPTION # This option allows you to specify whether or not Nagios should check # for external commands (in the command file defined below). By default # Nagios will *not* check for external commands, just to be on the # cautious side. If you want to be able to use the CGI command interface # you will have to enable this. Setting this value to 0 disables command # checking (the default), other values enable it. check_external_commands=0 # EXTERNAL COMMAND CHECK INTERVAL # This is the interval at which Nagios should check for external commands. # This value works of the interval_length you specify later. If you leave # that at its default value of 60 (seconds), a value of 1 here will cause # Nagios to check for external commands every minute. If you specify a # number followed by an "s" (i.e. 15s), this will be interpreted to mean # actual seconds rather than a multiple of the interval_length variable. # Note: In addition to reading the external command file at regularly # scheduled intervals, Nagios will also check for external commands after # event handlers are executed. # NOTE: Setting this value to -1 causes Nagios to check the external # command file as often as possible. #command_check_interval=1 #command_check_interval=15s command_check_interval=-1 # EXTERNAL COMMAND FILE # This is the file that Nagios checks for external command requests. # It is also where the command CGI will write commands that are submitted # by users, so it must be writeable by the user that the web server # is running as (usually 'nobody'). Permissions should be set at the # directory level instead of on the file, as the file is deleted every # time its contents are processed. command_file=/opt/nagios/var/rw/nagios.cmd # COMMENT FILE # This is the file that Nagios will use for storing host and service # comments. comment_file=/opt/nagios/var/comments.dat # DOWNTIME FILE # This is the file that Nagios will use for storing host and service # downtime data. downtime_file=/opt/nagios/var/downtime.dat # LOCK FILE # This is the lockfile that Nagios will use to store its PID number # in when it is running in daemon mode. lock_file=/opt/nagios/var/nagios.lock # TEMP FILE # This is a temporary file that is used as scratch space when Nagios # updates the status log, cleans the comment file, etc. This file # is created, used, and deleted throughout the time that Nagios is # running. temp_file=/opt/nagios/var/nagios.tmp # EVENT BROKER OPTIONS # Controls what (if any) data gets sent to the event broker. # Values: 0 = Broker nothing # -1 = Broker everything # = See documentation event_broker_options=-1 # EVENT BROKER MODULE(S) # This directive is used to specify an event broker module that should # by loaded by Nagios at startup. Use multiple directives if you want # to load more than one module. Arguments that should be passed to # the module at startup are seperated from the module path by a space. # # Example: # # nebmodule= [moduleargs] #broker_module=/somewhere/module1.o #broker_module=/somewhere/module2.o arg1 arg2=3 debug=0 # LOG ROTATION METHOD # This is the log rotation method that Nagios should use to rotate # the main log file. Values are as follows.. # n = None - don't rotate the log # h = Hourly rotation (top of the hour) # d = Daily rotation (midnight every day) # w = Weekly rotation (midnight on Saturday evening) # m = Monthly rotation (midnight last day of month) log_rotation_method=d # LOG ARCHIVE PATH # This is the directory where archived (rotated) log files should be # placed (assuming you've chosen to do log rotation). log_archive_path=/opt/nagios/var/archives # LOGGING OPTIONS # If you want messages logged to the syslog facility, as well as the # NetAlarm log file set this option to 1. If not, set it to 0. use_syslog=1 # NOTIFICATION LOGGING OPTION # If you don't want notifications to be logged, set this value to 0. # If notifications should be logged, set the value to 1. log_notifications=1 # SERVICE RETRY LOGGING OPTION # If you don't want service check retries to be logged, set this value # to 0. If retries should be logged, set the value to 1. log_service_retries=1 # HOST RETRY LOGGING OPTION # If you don't want host check retries to be logged, set this value to # 0. If retries should be logged, set the value to 1. log_host_retries=1 # EVENT HANDLER LOGGING OPTION # If you don't want host and service event handlers to be logged, set # this value to 0. If event handlers should be logged, set the value # to 1. log_event_handlers=1 # INITIAL STATES LOGGING OPTION # If you want Nagios to log all initial host and service states to # the main log file (the first time the service or host is checked) # you can enable this option by setting this value to 1. If you # are not using an external application that does long term state # statistics reporting, you do not need to enable this option. In # this case, set the value to 0. log_initial_states=0 # EXTERNAL COMMANDS LOGGING OPTION # If you don't want Nagios to log external commands, set this value # to 0. If external commands should be logged, set this value to 1. # Note: This option does not include logging of passive service # checks - see the option below for controlling whether or not # passive checks are logged. log_external_commands=1 # PASSIVE CHECKS LOGGING OPTION # If you don't want Nagios to log passive host and service checks, set # this value to 0. If passive service checks should be logged, set # this value to 1. log_passive_checks=1 # GLOBAL HOST AND SERVICE EVENT HANDLERS # These options allow you to specify a host and service event handler # command that is to be run for every host or service state change. # The global event handler is executed immediately prior to the event # handler that you have optionally specified in each host or # service definition. The command argument is the short name of a # command definition that you define in your host configuration file. # Read the HTML docs for more information. #global_host_event_handler=somecommand #global_service_event_handler=somecommand # SERVICE INTER-CHECK DELAY METHOD # This is the method that Nagios should use when initially # "spreading out" service checks when it starts monitoring. The # default is to use smart delay calculation, which will try to # space all service checks out evenly to minimize CPU load. # Using the dumb setting will cause all checks to be scheduled # at the same time (with no delay between them)! This is not a # good thing for production, but is useful when testing the # parallelization functionality. # n = None - don't use any delay between checks # d = Use a "dumb" delay of 1 second between checks # s = Use "smart" inter-check delay calculation # x.xx = Use an inter-check delay of x.xx seconds service_inter_check_delay_method=s # MAXIMUM SERVICE CHECK SPREAD # This variable determines the timeframe (in minutes) from the # program start time that an initial check of all services should # be completed. Default is 30 minutes. max_service_check_spread=30 # SERVICE CHECK INTERLEAVE FACTOR # This variable determines how service checks are interleaved. # Interleaving the service checks allows for a more even # distribution of service checks and reduced load on remote # hosts. Setting this value to 1 is equivalent to how versions # of Nagios previous to 0.0.5 did service checks. Set this # value to s (smart) for automatic calculation of the interleave # factor unless you have a specific reason to change it. # s = Use "smart" interleave factor calculation # x = Use an interleave factor of x, where x is a # number greater than or equal to 1. service_interleave_factor=s # HOST INTER-CHECK DELAY METHOD # This is the method that Nagios should use when initially # "spreading out" host checks when it starts monitoring. The # default is to use smart delay calculation, which will try to # space all host checks out evenly to minimize CPU load. # Using the dumb setting will cause all checks to be scheduled # at the same time (with no delay between them)! # n = None - don't use any delay between checks # d = Use a "dumb" delay of 1 second between checks # s = Use "smart" inter-check delay calculation # x.xx = Use an inter-check delay of x.xx seconds host_inter_check_delay_method=s # MAXIMUM HOST CHECK SPREAD # This variable determines the timeframe (in minutes) from the # program start time that an initial check of all hosts should # be completed. Default is 30 minutes. max_host_check_spread=30 # MAXIMUM CONCURRENT SERVICE CHECKS # This option allows you to specify the maximum number of # service checks that can be run in parallel at any given time. # Specifying a value of 1 for this variable essentially prevents # any service checks from being parallelized. A value of 0 # will not restrict the number of concurrent checks that are # being executed. max_concurrent_checks=0 # SERVICE CHECK REAPER FREQUENCY # This is the frequency (in seconds!) that Nagios will process # the results of services that have been checked. service_reaper_frequency=10 # AUTO-RESCHEDULING OPTION # This option determines whether or not Nagios will attempt to # automatically reschedule active host and service checks to # "smooth" them out over time. This can help balance the load on # the monitoring server. # WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE # PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY auto_reschedule_checks=0 # AUTO-RESCHEDULING INTERVAL # This option determines how often (in seconds) Nagios will # attempt to automatically reschedule checks. This option only # has an effect if the auto_reschedule_checks option is enabled. # Default is 30 seconds. # WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE # PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY auto_rescheduling_interval=30 # AUTO-RESCHEDULING WINDOW # This option determines the "window" of time (in seconds) that # Nagios will look at when automatically rescheduling checks. # Only host and service checks that occur in the next X seconds # (determined by this variable) will be rescheduled. This option # only has an effect if the auto_reschedule_checks option is # enabled. Default is 180 seconds (3 minutes). # WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE # PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY auto_rescheduling_window=180 # SLEEP TIME # This is the number of seconds to sleep between checking for system # events and service checks that need to be run. sleep_time=0.25 # TIMEOUT VALUES # These options control how much time Nagios will allow various # types of commands to execute before killing them off. Options # are available for controlling maximum time allotted for # service checks, host checks, event handlers, notifications, the # ocsp command, and performance data commands. All values are in # seconds. service_check_timeout=60 host_check_timeout=30 event_handler_timeout=30 notification_timeout=30 ocsp_timeout=5 perfdata_timeout=5 # RETAIN STATE INFORMATION # This setting determines whether or not Nagios will save state # information for services and hosts before it shuts down. Upon # startup Nagios will reload all saved service and host state # information before starting to monitor. This is useful for # maintaining long-term data on state statistics, etc, but will # slow Nagios down a bit when it (re)starts. Since its only # a one-time penalty, I think its well worth the additional # startup delay. retain_state_information=1 # STATE RETENTION FILE # This is the file that Nagios should use to store host and # service state information before it shuts down. The state # information in this file is also read immediately prior to # starting to monitor the network when Nagios is restarted. # This file is used only if the preserve_state_information # variable is set to 1. state_retention_file=/opt/nagios/var/retention.dat # RETENTION DATA UPDATE INTERVAL # This setting determines how often (in minutes) that Nagios # will automatically save retention data during normal operation. # If you set this value to 0, Nagios will not save retention # data at regular interval, but it will still save retention # data before shutting down or restarting. If you have disabled # state retention, this option has no effect. retention_update_interval=60 # USE RETAINED PROGRAM STATE # This setting determines whether or not Nagios will set # program status variables based on the values saved in the # retention file. If you want to use retained program status # information, set this value to 1. If not, set this value # to 0. use_retained_program_state=1 # USE RETAINED SCHEDULING INFO # This setting determines whether or not Nagios will retain # the scheduling info (next check time) for hosts and services # based on the values saved in the retention file. If you # If you want to use retained scheduling info, set this # value to 1. If not, set this value to 0. use_retained_scheduling_info=0 # INTERVAL LENGTH # This is the seconds per unit interval as used in the # host/contact/service configuration files. Setting this to 60 means # that each interval is one minute long (60 seconds). Other settings # have not been tested much, so your mileage is likely to vary... interval_length=60 # AGRESSIVE HOST CHECKING OPTION # If you don't want to turn on agressive host checking features, set # this value to 0 (the default). Otherwise set this value to 1 to # enable the agressive check option. Read the docs for more info # on what agressive host check is or check out the source code in # base/checks.c use_agressive_host_checking=0 # SERVICE CHECK EXECUTION OPTION # This determines whether or not Nagios will actively execute # service checks when it initially starts. If this option is # disabled, checks are not actively made, but Nagios can still # receive and process passive check results that come in. Unless # you're implementing redundant hosts or have a special need for # disabling the execution of service checks, leave this enabled! # Values: 1 = enable checks, 0 = disable checks execute_service_checks=1 # PASSIVE SERVICE CHECK ACCEPTANCE OPTION # This determines whether or not Nagios will accept passive # service checks results when it initially (re)starts. # Values: 1 = accept passive checks, 0 = reject passive checks accept_passive_service_checks=1 # HOST CHECK EXECUTION OPTION # This determines whether or not Nagios will actively execute # host checks when it initially starts. If this option is # disabled, checks are not actively made, but Nagios can still # receive and process passive check results that come in. Unless # you're implementing redundant hosts or have a special need for # disabling the execution of host checks, leave this enabled! # Values: 1 = enable checks, 0 = disable checks execute_host_checks=1 # PASSIVE HOST CHECK ACCEPTANCE OPTION # This determines whether or not Nagios will accept passive # host checks results when it initially (re)starts. # Values: 1 = accept passive checks, 0 = reject passive checks accept_passive_host_checks=1 # NOTIFICATIONS OPTION # This determines whether or not Nagios will sent out any host or # service notifications when it is initially (re)started. # Values: 1 = enable notifications, 0 = disable notifications enable_notifications=1 # EVENT HANDLER USE OPTION # This determines whether or not Nagios will run any host or # service event handlers when it is initially (re)started. Unless # you're implementing redundant hosts, leave this option enabled. # Values: 1 = enable event handlers, 0 = disable event handlers enable_event_handlers=1 # PROCESS PERFORMANCE DATA OPTION # This determines whether or not Nagios will process performance # data returned from service and host checks. If this option is # enabled, host performance data will be processed using the # host_perfdata_command (defined below) and service performance # data will be processed using the service_perfdata_command (also # defined below). Read the HTML docs for more information on # performance data. # Values: 1 = process performance data, 0 = do not process performance data process_performance_data=0 # HOST AND SERVICE PERFORMANCE DATA PROCESSING COMMANDS # These commands are run after every host and service check is # performed. These commands are executed only if the # enable_performance_data option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on performance data. #host_perfdata_command=process-host-perfdata #service_perfdata_command=process-service-perfdata # HOST AND SERVICE PERFORMANCE DATA FILES # These files are used to store host and service performance data. # Performance data is only written to these files if the # enable_performance_data option (above) is set to 1. #host_perfdata_file=/tmp/host-perfdata #service_perfdata_file=/tmp/service-perfdata # HOST AND SERVICE PERFORMANCE DATA FILE TEMPLATES # These options determine what data is written (and how) to the # performance data files. The templates may contain macros, special # characters (\t for tab, \r for carriage return, \n for newline) # and plain text. A newline is automatically added after each write # to the performance data file. Some examples of what you can do are # shown below. #host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$ #service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$ # HOST AND SERVICE PERFORMANCE DATA FILE MODES # This option determines whether or not the host and service # performance data files are opened in write ("w") or append ("a") # mode. Unless you are the files are named pipes, you will probably # want to use the default mode of append ("a"). #host_perfdata_file_mode=a #service_perfdata_file_mode=a # HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING INTERVAL # These options determine how often (in seconds) the host and service # performance data files are processed using the commands defined # below. A value of 0 indicates the files should not be periodically # processed. #host_perfdata_file_processing_interval=0 #service_perfdata_file_processing_interval=0 # HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING COMMANDS # These commands are used to periodically process the host and # service performance data files. The interval at which the # processing occurs is determined by the options above. #host_perfdata_file_processing_command=process-host-perfdata-file #service_perfdata_file_processing_command=process-service-perfdata-file # OBSESS OVER SERVICE CHECKS OPTION # This determines whether or not Nagios will obsess over service # checks and run the ocsp_command defined below. Unless you're # planning on implementing distributed monitoring, do not enable # this option. Read the HTML docs for more information on # implementing distributed monitoring. # Values: 1 = obsess over services, 0 = do not obsess (default) obsess_over_services=0 # OBSESSIVE COMPULSIVE SERVICE PROCESSOR COMMAND # This is the command that is run for every service check that is # processed by Nagios. This command is executed only if the # obsess_over_service option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on implementing distributed monitoring. #ocsp_command=somecommand # ORPHANED SERVICE CHECK OPTION # This determines whether or not Nagios will periodically # check for orphaned services. Since service checks are not # rescheduled until the results of their previous execution # instance are processed, there exists a possibility that some # checks may never get rescheduled. This seems to be a rare # problem and should not happen under normal circumstances. # If you have problems with service checks never getting # rescheduled, you might want to try enabling this option. # Values: 1 = enable checks, 0 = disable checks check_for_orphaned_services=0 # SERVICE FRESHNESS CHECK OPTION # This option determines whether or not Nagios will periodically # check the "freshness" of service results. Enabling this option # is useful for ensuring passive checks are received in a timely # manner. # Values: 1 = enabled freshness checking, 0 = disable freshness checking check_service_freshness=1 # SERVICE FRESHNESS CHECK INTERVAL # This setting determines how often (in seconds) Nagios will # check the "freshness" of service check results. If you have # disabled service freshness checking, this option has no effect. service_freshness_check_interval=60 # HOST FRESHNESS CHECK OPTION # This option determines whether or not Nagios will periodically # check the "freshness" of host results. Enabling this option # is useful for ensuring passive checks are received in a timely # manner. # Values: 1 = enabled freshness checking, 0 = disable freshness checking check_host_freshness=0 # HOST FRESHNESS CHECK INTERVAL # This setting determines how often (in seconds) Nagios will # check the "freshness" of host check results. If you have # disabled host freshness checking, this option has no effect. host_freshness_check_interval=60 # AGGREGATED STATUS UPDATES # This option determines whether or not Nagios will # aggregate updates of host, service, and program status # data. Normally, status data is updated immediately when # a change occurs. This can result in high CPU loads if # you are monitoring a lot of services. If you want Nagios # to only refresh status data every few seconds, disable # this option. # Values: 1 = enable aggregate updates, 0 = disable aggregate updates aggregate_status_updates=1 # AGGREGATED STATUS UPDATE INTERVAL # Combined with the aggregate_status_updates option, # this option determines the frequency (in seconds!) that # Nagios will periodically dump program, host, and # service status data. If you are not using aggregated # status data updates, this option has no effect. status_update_interval=15 # FLAP DETECTION OPTION # This option determines whether or not Nagios will try # and detect hosts and services that are "flapping". # Flapping occurs when a host or service changes between # states too frequently. When Nagios detects that a # host or service is flapping, it will temporarily supress # notifications for that host/service until it stops # flapping. Flap detection is very experimental, so read # the HTML documentation before enabling this feature! # Values: 1 = enable flap detection # 0 = disable flap detection (default) enable_flap_detection=0 # FLAP DETECTION THRESHOLDS FOR HOSTS AND SERVICES # Read the HTML documentation on flap detection for # an explanation of what this option does. This option # has no effect if flap detection is disabled. low_service_flap_threshold=5.0 high_service_flap_threshold=20.0 low_host_flap_threshold=5.0 high_host_flap_threshold=20.0 # DATE FORMAT OPTION # This option determines how short dates are displayed. Valid options # include: # us (MM-DD-YYYY HH:MM:SS) # euro (DD-MM-YYYY HH:MM:SS) # iso8601 (YYYY-MM-DD HH:MM:SS) # strict-iso8601 (YYYY-MM-DDTHH:MM:SS) # date_format=us # MAXIMUM EMBEDDED PERL INTERPRETER CALLS # This value determines how often (if at all) the embedded Perl # interpreter is reinitialized during runtime. This is useful # if you notice that the Perl interpreter is causing slow # memory leaks over time. Setting this value to 0 means the # embedded Perl interpreter will never be reinitialized. Any # value > 0 is the number of times the embedded Perl interpreter # is used (i.e. a Perl plugin is executed) before it is # reinitialized during runtime. If you didn't compile Nagios with # embedded Perl support, this option has no effect. max_embedded_perl_calls=0 # P1.PL FILE LOCATION # This value determines where the p1.pl perl script (used by the # embedded Perl interpreter) is located. If you didn't compile # Nagios with embedded Perl support, this option has no effect. p1_file=/opt/nagios/bin/p1.pl # ILLEGAL OBJECT NAME CHARACTERS # This option allows you to specify illegal characters that cannot # be used in host names, service descriptions, or names of other # object types. illegal_object_name_chars=`~!$%^&*|'"<>?,()= # ILLEGAL MACRO OUTPUT CHARACTERS # This option allows you to specify illegal characters that are # stripped from macros before being used in notifications, event # handlers, etc. This DOES NOT affect macros used in service or # host check commands. # The following macros are stripped of the characters you specify: # $HOSTOUTPUT$ # $HOSTPERFDATA$ # $HOSTACKAUTHOR$ # $HOSTACKCOMMENT$ # $SERVICEOUTPUT$ # $SERVICEPERFDATA$ # $SERVICEACKAUTHOR$ # $SERVICEACKCOMMENT$ illegal_macro_output_chars=`~$&|'"<> # REGULAR EXPRESSION MATCHING # This option controls whether or not regular expression matching # takes place in the object config files. Regular expression # matching is used to match host, hostgroup, service, and service # group names/descriptions in some fields of various object types. # Values: 1 = enable regexp matching, 0 = disable regexp matching use_regexp_matching=0 # "TRUE" REGULAR EXPRESSION MATCHING # This option controls whether or not "true" regular expression # matching takes place in the object config files. This option # only has an effect if regular expression matching is enabled # (see above). If this option is DISABLED, regular expression # matching only occurs if a string contains wildcard characters # (* and ?). If the option is ENABLED, regexp matching occurs # all the time (which can be annoying). # Values: 1 = enable true matching, 0 = disable true matching use_true_regexp_matching=0 # ADMINISTRATOR EMAIL ADDRESS # The email address of the administrator of *this* machine (the one # doing the monitoring). Nagios never uses this value itself, but # you can access this value by using the $ADMINEMAIL$ macro in your # notification commands. admin_email=nagios # ADMINISTRATOR PAGER NUMBER/ADDRESS # The pager number/address for the administrator of *this* machine. # Nagios never uses this value itself, but you can access this # value by using the $ADMINPAGER$ macro in your notification # commands. admin_pager=pagenagios # EOF (End of file) Nagios-Object-0.21.20/t/v2_config/misccommands.cfg000444001750001750 1033612220262237 23106 0ustar00dfergusondferguson000000000000################################################################################ # Sample object config file for Nagios # # Read the documentation for more information on this configuration file. I've # provided some comments here, but things may not be so clear without further # explanation, so make sure to read the HTML documentation! # # Last Modified: 02-18-2003 # ################################################################################ ################################################################################ # COMMAND DEFINITIONS # # SYNTAX: # # define command{ # template # name # command_name # command_line # } # # WHERE: # # = object name of another command definition that should be # used as a template for this definition (optional) # = object name of command definition, referenced by other # command definitions that use it as a template (optional) # = name of the command, as recognized/used by Nagios # = command line # ################################################################################ ################################################################################ # # SAMPLE NOTIFICATION COMMANDS # # These are some example notification commands. They may or may not work on # your system without modification. # ################################################################################ # 'notify-by-email' command definition define command{ command_name notify-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $DATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ } # 'notify-by-epager' command definition define command{ command_name notify-by-epager command_line /usr/bin/printf "%b" "Service: $SERVICEDESC$\nHost: $HOSTNAME$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nInfo: $SERVICEOUTPUT$\nDate: $DATETIME$" | /bin/mail -s "$NOTIFICATIONTYPE$: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" $CONTACTPAGER$ } # 'host-notify-by-email' command definition define command{ command_name host-notify-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $DATETIME$\n" | /bin/mail -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$ } # 'host-notify-by-epager' command definition define command{ command_name host-notify-by-epager command_line /usr/bin/printf "%b" "Host '$HOSTALIAS$' is $HOSTSTATE$\nInfo: $HOSTOUTPUT$\nTime: $DATETIME$" | /bin/mail -s "$NOTIFICATIONTYPE$ alert - Host $HOSTNAME$ is $HOSTSTATE$" $CONTACTPAGER$ } ################################################################################ # # SAMPLE PERFORMANCE DATA COMMANDS # # These are sample performance data commands that can be used to send performance # data output to two text files (one for hosts, another for services). If you # plan on simply writing performance data out to a file, consider compiling # Nagios with native file support for performance data. This is done by # supplying the --with-file-perfdata option to the configure script. # ################################################################################ # 'process-host-perfdata' command definition define command{ command_name process-host-perfdata command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$" >> /opt/nagios/var/host-perfdata.out } # 'process-service-perfdata' command definition define command{ command_name process-service-perfdata command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$" >> /opt/nagios/var/service-perfdata.out } Nagios-Object-0.21.20/t/v2_config/hostextinfo.cfg000444001750001750 265612220262237 22771 0ustar00dfergusondferguson000000000000################################################################################ # Sample Extended Host Info Definition File for Nagios # Template-based config format # # Last Modified: 12-03-2002 ################################################################################ # This definition is used as a template define hostextinfo{ name hei1 ; This name is referenced in other hostextinfo definitions that ; want to use this as a template icon_image novell40.gif icon_image_alt IntranetWare 4.11 vrml_image novell40.gif statusmap_image novell40.gd2 register 0 ; DO NOT REGISTER THIS DEFINITION - IT IS JUST A TEMPLATE!! } # A 'normal' definition define hostextinfo{ use hei1 ; Use the hostextinfo definition with name 'he1' as a template ; for this definition host_name big_host1 ; Name of the host, as recognized/used by Nagios 2d_coords 100,350 ; 2-D drawing coordinates 3d_coords 4.0,0.0,0.0 ; 3-D drawing coordinates } # Another 'normal' definition define hostextinfo{ use hei1 ; Use the hostextinfo definition with name 'he1' as a template ; for this definition. host_name big_host2 ; Name of the host, as recognized/used by Nagios 2d_coords 65,425 ; 2-D drawing coordinates 3d_coords 3.0,0.0,0.0 ; 3-D drawing coordinates } # A very minimalistic definition - has only 3-D drawing coorindates define hostextinfo{ host_name bogus1 3d_coords 4.0,0.0,-1.0 } Nagios-Object-0.21.20/t/v2_config/serviceextinfo.cfg000444001750001750 247412220262237 23452 0ustar00dfergusondferguson000000000000################################################################################ # Sample Extended Host Info Definition File for Nagios # Template-based config format # # Last Modified: 01-15-2002 ################################################################################ # A simple definition - applies to a single service (on a single host) define serviceextinfo{ host_name host9 service_description PING icon_image ping.gif } # This definition is applied to several services on different hosts. # In order for this to work, all services need to be named the same way. # In this case, all the services are named 'TCP Wrappers' define serviceextinfo{ name sei1 host_name host1,host2,host3,host4 service_description TCP Wrappers icon_image wrappers.gif } # This definition will also be applied to several services on different # hosts because the 'host_name' member will be inherited from the # definition above. define serviceextinfo{ use sei1 service_description Security Alerts icon_image security.gif } # This definition is applied to all hosts in a specific hostgroup. # You can have it apply to all hosts in multiple hostgroups by # separating different hostgroups with commas... define serviceextinfo{ hostgroup novell-servers service_description LRU Sitting Time icon_image cache.gif } Nagios-Object-0.21.20/t/v3_config000755001750001750 012220262237 17571 5ustar00dfergusondferguson000000000000Nagios-Object-0.21.20/t/v3_config/resource.cfg000444001750001750 247412220262237 22245 0ustar00dfergusondferguson000000000000########################################################################### # # RESOURCE.CFG - Sample Resource File for Nagios 3.1.2 # # Last Modified: 09-10-2003 # # You can define $USERx$ macros in this file, which can in turn be used # in command definitions in your host config file(s). $USERx$ macros are # useful for storing sensitive information such as usernames, passwords, # etc. They are also handy for specifying the path to plugins and # event handlers - if you decide to move the plugins or event handlers to # a different directory in the future, you can just update one or two # $USERx$ macros, instead of modifying a lot of command definitions. # # The CGIs will not attempt to read the contents of resource files, so # you can set restrictive permissions (600 or 660) on them. # # Nagios supports up to 32 $USERx$ macros ($USER1$ through $USER32$) # # Resource files may also be used to store configuration directives for # external data sources like MySQL... # ########################################################################### # Sets $USER1$ to be the path to the plugins $USER1$=/usr/local/nagios/libexec # Sets $USER2$ to be the path to event handlers #$USER2$=/usr/local/nagios/libexec/eventhandlers # Store some usernames and passwords (hidden from the CGIs) #$USER3$=someuser #$USER4$=somepassword Nagios-Object-0.21.20/t/v3_config/mrtg.cfg000444001750001750 1571012220262237 21404 0ustar00dfergusondferguson000000000000################################################################### # MRTG Graphs: Nagios 3.1.2 Statistics # # You can add the following entries to your MRTG config file to # begin graphing several Nagios statistics which can be useful for # debugging and trending purposes. The nagiostats binary (which is # included as part of the Nagios distribution) is used to generate # the data. ################################################################### # Service Latency and Execution Time Target[nagios-a]: `/usr/local/nagios/bin/nagiostats --mrtg --data=AVGACTSVCLAT,AVGACTSVCEXT,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-a]: 100000 Title[nagios-a]: Average Service Check Latency and Execution Time PageTop[nagios-a]:

Average Service Check Latency and Execution Time

Options[nagios-a]: growright,gauge,nopercent YLegend[nagios-a]: Milliseconds ShortLegend[nagios-a]:   LegendI[nagios-a]:  Latency: LegendO[nagios-a]:  Execution Time: Legend1[nagios-a]: Latency Legend2[nagios-a]: Execution Time Legend3[nagios-a]: Maximal 5 Minute Latency Legend4[nagios-a]: Maximal 5 Minute Execution Time # Service Percent State Change Target[nagios-b]: `/usr/local/nagios/bin/nagiostats --mrtg --data=AVGACTSVCPSC,AVGPSVSVCPSC,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-b]: 100 Title[nagios-b]: Average Service State Change PageTop[nagios-b]:

Average Service State Change

Options[nagios-b]: growright,gauge,nopercent YLegend[nagios-b]: Percent ShortLegend[nagios-b]:   LegendI[nagios-b]:  Active Check % Change: LegendO[nagios-b]:  Passive Check % Change: Legend1[nagios-b]: State Change Legend2[nagios-b]: State Change Legend3[nagios-b]: Maximal 5 Minute State Change Legend4[nagios-b]: Maximal 5 Minute State Change # Host Latency and Execution Time Target[nagios-c]: `/usr/local/nagios/bin/nagiostats --mrtg --data=AVGACTHSTLAT,AVGACTHSTEXT,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-c]: 100000 Title[nagios-c]: Average Host Check Latency and Execution Time PageTop[nagios-c]:

Average Host Check Latency and Execution Time

Options[nagios-c]: growright,gauge,nopercent YLegend[nagios-c]: Milliseconds ShortLegend[nagios-c]:   LegendI[nagios-c]:  Latency: LegendO[nagios-c]:  Execution Time: Legend1[nagios-c]: Latency Legend2[nagios-c]: Execution Time Legend3[nagios-c]: Maximal 5 Minute Latency Legend4[nagios-c]: Maximal 5 Minute Execution Time # Host Percent State Change Target[nagios-d]: `/usr/local/nagios/bin/nagiostats --mrtg --data=AVGACTHSTPSC,AVGPSVHSTPSC,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-d]: 100 Title[nagios-d]: Average Host State Change PageTop[nagios-d]:

Average Host State Change

Options[nagios-d]: growright,gauge,nopercent YLegend[nagios-d]: Percent ShortLegend[nagios-d]:   LegendI[nagios-d]:  Active Check % Change: LegendO[nagios-d]:  Passive Check % Change: Legend1[nagios-d]: State Change Legend2[nagios-d]: State Change Legend3[nagios-d]: Maximal 5 Minute State Change Legend4[nagios-d]: Maximal 5 Minute State Change # Hosts/Services Actively Checked Target[nagios-e]: `/usr/local/nagios/bin/nagiostats --mrtg --data=NUMHSTACTCHK5M,NUMSVCACTCHK5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-e]: 7000 Title[nagios-e]: Hosts/Services Actively Checked PageTop[nagios-e]:

Hosts/Services Actively Checked

Options[nagios-e]: growright,gauge,nopercent YLegend[nagios-e]: Total ShortLegend[nagios-e]:   LegendI[nagios-e]:  Hosts: LegendO[nagios-e]:  Services: # Hosts/Services Passively Checked Target[nagios-f]: `/usr/local/nagios/bin/nagiostats --mrtg --data=NUMHSTPSVCHK5M,NUMSVCPSVCHK5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-f]: 7000 Title[nagios-f]: Hosts/Services Passively Checked PageTop[nagios-f]:

Hosts/Services Passively Checked

Options[nagios-f]: growright,gauge,nopercent YLegend[nagios-f]: Total ShortLegend[nagios-f]:   LegendI[nagios-f]:  Hosts: LegendO[nagios-f]:  Services: # Used/Avail External Command Buffers Target[nagios-g]: `/usr/local/nagios/bin/nagiostats --mrtg --data=TOTCMDBUF,USEDCMDBUF,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-g]: 7000 Title[nagios-g]: External Command Buffers PageTop[nagios-g]:

External Command Buffers

Options[nagios-g]: growright,gauge,nopercent YLegend[nagios-g]: Buffers ShortLegend[nagios-g]:   LegendI[nagios-g]:  Total: LegendO[nagios-g]:  Used: # Active Host Checks Target[nagios-i]: `/usr/local/nagios/bin/nagiostats --mrtg --data=NUMSACTHSTCHECKS5M,NUMOACTHSTCHECKS5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-i]: 7000 Title[nagios-i]: Active Host Checks PageTop[nagios-i]:

Active Host Checks

Options[nagios-i]: growright,gauge,nopercent YLegend[nagios-i]: Checks ShortLegend[nagios-i]:   LegendI[nagios-i]:  Scheduled Checks: LegendO[nagios-i]:  On-Demand Checks: # Active Service Checks Target[nagios-j]: `/usr/local/nagios/bin/nagiostats --mrtg --data=NUMSACTSVCCHECKS5M,NUMOACTSVCCHECKS5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-j]: 7000 Title[nagios-j]: Active Service Checks PageTop[nagios-j]:

Active Service Checks

Options[nagios-j]: growright,gauge,nopercent YLegend[nagios-j]: Checks ShortLegend[nagios-j]:   LegendI[nagios-j]:  Scheduled Checks: LegendO[nagios-j]:  On-Demand Checks: # Passive Host/Service Checks Target[nagios-k]: `/usr/local/nagios/bin/nagiostats --mrtg --data=NUMPSVHSTCHECKS5M,NUMPSVSVCCHECKS5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-k]: 7000 Title[nagios-k]: Passive Host/Service Checks PageTop[nagios-k]:

Passive Host/Service Checks

Options[nagios-k]: growright,gauge,nopercent YLegend[nagios-k]: Checks ShortLegend[nagios-k]:   LegendI[nagios-k]:  Host Checks: LegendO[nagios-k]:  Service Checks: # Cached Host/Service Checks Target[nagios-l]: `/usr/local/nagios/bin/nagiostats --mrtg --data=NUMCACHEDHSTCHECKS5M,NUMCACHEDSVCCHECKS5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-l]: 7000 Title[nagios-l]: Cached Host/Service Checks PageTop[nagios-l]:

Cached Host/Service Checks

Options[nagios-l]: growright,gauge,nopercent YLegend[nagios-l]: Checks ShortLegend[nagios-l]:   LegendI[nagios-l]:  Host Checks: LegendO[nagios-l]:  Service Checks: # External Commands Target[nagios-m]: `/usr/local/nagios/bin/nagiostats --mrtg --data=NUMEXTCMDS5M,0,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-m]: 7000 Title[nagios-m]: External Commands PageTop[nagios-m]:

External Commands

Options[nagios-m]: growright,gauge,nopercent YLegend[nagios-m]: Commands ShortLegend[nagios-m]:   LegendI[nagios-m]:  Commands: LegendO[nagios-m]:   # Parallel/Service Host Checks Target[nagios-n]: `/usr/local/nagios/bin/nagiostats --mrtg --data=NUMPARHSTCHECKS5M,NUMSERHSTCHECKS5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-n]: 7000 Title[nagios-n]: Parallel/Serial Host Checks PageTop[nagios-n]:

Parallel/Serial Host Checks

Options[nagios-n]: growright,gauge,nopercent YLegend[nagios-n]: Checks ShortLegend[nagios-n]:   LegendI[nagios-n]:  Parallel Checks: LegendO[nagios-n]:  Serial Checks: Nagios-Object-0.21.20/t/v3_config/httpd.conf.in000444001750001750 164412220262237 22332 0ustar00dfergusondferguson000000000000# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER # Last Modified: 11-26-2005 # # This file contains examples of entries that need # to be incorporated into your Apache web server # configuration file. Customize the paths, etc. as # needed to fit your system. ScriptAlias @cgiurl@ "@sbindir@" # SSLRequireSSL Options ExecCGI AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile @sysconfdir@/htpasswd.users Require valid-user Alias @htmurl@ "@datadir@" # SSLRequireSSL Options None AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile @sysconfdir@/htpasswd.users Require valid-user Nagios-Object-0.21.20/t/v3_config/README000444001750001750 172712220262237 20615 0ustar00dfergusondferguson000000000000========================= SAMPLE CONFIG FILE README ========================= This directory contains *sample* configuration files for Nagios. You should read the HTML documentation for information on customizing these config files to suit your needs. A description of the sample config files and subdirectories contained here follows: CONTENTS: --------- cgi.cfg - This is a sample CGI config file nagios.cfg - This is a sample main config file resource.cfg - This is a sample resource config file, used for definining custom macros, storing sensitive data, etc. httpd.conf - This file contains sample snippets that you'll need to include in your Apache web server config file if you want to use the web interface. template-object/ - This directory contains sample object config files. You'll need to define object config files like these before you can actually start to monitor anything. Nagios-Object-0.21.20/t/v3_config/cgi.cfg.in000444001750001750 2617612220262237 21612 0ustar00dfergusondferguson000000000000################################################################# # # CGI.CFG - Sample CGI Configuration File for Nagios @VERSION@ # # Last Modified: 06-17-2009 # ################################################################# # MAIN CONFIGURATION FILE # This tells the CGIs where to find your main configuration file. # The CGIs will read the main and host config files for any other # data they might need. main_config_file=@sysconfdir@/nagios.cfg # PHYSICAL HTML PATH # This is the path where the HTML files for Nagios reside. This # value is used to locate the logo images needed by the statusmap # and statuswrl CGIs. physical_html_path=@datadir@ # URL HTML PATH # This is the path portion of the URL that corresponds to the # physical location of the Nagios HTML files (as defined above). # This value is used by the CGIs to locate the online documentation # and graphics. If you access the Nagios pages with an URL like # http://www.myhost.com/nagios, this value should be '/nagios' # (without the quotes). url_html_path=@htmurl@ # CONTEXT-SENSITIVE HELP # This option determines whether or not a context-sensitive # help icon will be displayed for most of the CGIs. # Values: 0 = disables context-sensitive help # 1 = enables context-sensitive help show_context_help=0 # PENDING STATES OPTION # This option determines what states should be displayed in the web # interface for hosts/services that have not yet been checked. # Values: 0 = leave hosts/services that have not been check yet in their original state # 1 = mark hosts/services that have not been checked yet as PENDING use_pending_states=1 # AUTHENTICATION USAGE # This option controls whether or not the CGIs will use any # authentication when displaying host and service information, as # well as committing commands to Nagios for processing. # # Read the HTML documentation to learn how the authorization works! # # NOTE: It is a really *bad* idea to disable authorization, unless # you plan on removing the command CGI (cmd.cgi)! Failure to do # so will leave you wide open to kiddies messing with Nagios and # possibly hitting you with a denial of service attack by filling up # your drive by continuously writing to your command file! # # Setting this value to 0 will cause the CGIs to *not* use # authentication (bad idea), while any other value will make them # use the authentication functions (the default). use_authentication=1 # x509 CERT AUTHENTICATION # When enabled, this option allows you to use x509 cert (SSL) # authentication in the CGIs. This is an advanced option and should # not be enabled unless you know what you're doing. use_ssl_authentication=0 # DEFAULT USER # Setting this variable will define a default user name that can # access pages without authentication. This allows people within a # secure domain (i.e., behind a firewall) to see the current status # without authenticating. You may want to use this to avoid basic # authentication if you are not using a secure server since basic # authentication transmits passwords in the clear. # # Important: Do not define a default username unless you are # running a secure web server and are sure that everyone who has # access to the CGIs has been authenticated in some manner! If you # define this variable, anyone who has not authenticated to the web # server will inherit all rights you assign to this user! #default_user_name=guest # SYSTEM/PROCESS INFORMATION ACCESS # This option is a comma-delimited list of all usernames that # have access to viewing the Nagios process information as # provided by the Extended Information CGI (extinfo.cgi). By # default, *no one* has access to this unless you choose to # not use authorization. You may use an asterisk (*) to # authorize any user who has authenticated to the web server. authorized_for_system_information=nagiosadmin # CONFIGURATION INFORMATION ACCESS # This option is a comma-delimited list of all usernames that # can view ALL configuration information (hosts, commands, etc). # By default, users can only view configuration information # for the hosts and services they are contacts for. You may use # an asterisk (*) to authorize any user who has authenticated # to the web server. authorized_for_configuration_information=nagiosadmin # SYSTEM/PROCESS COMMAND ACCESS # This option is a comma-delimited list of all usernames that # can issue shutdown and restart commands to Nagios via the # command CGI (cmd.cgi). Users in this list can also change # the program mode to active or standby. By default, *no one* # has access to this unless you choose to not use authorization. # You may use an asterisk (*) to authorize any user who has # authenticated to the web server. authorized_for_system_commands=nagiosadmin # GLOBAL HOST/SERVICE VIEW ACCESS # These two options are comma-delimited lists of all usernames that # can view information for all hosts and services that are being # monitored. By default, users can only view information # for hosts or services that they are contacts for (unless you # you choose to not use authorization). You may use an asterisk (*) # to authorize any user who has authenticated to the web server. authorized_for_all_services=nagiosadmin authorized_for_all_hosts=nagiosadmin # GLOBAL HOST/SERVICE COMMAND ACCESS # These two options are comma-delimited lists of all usernames that # can issue host or service related commands via the command # CGI (cmd.cgi) for all hosts and services that are being monitored. # By default, users can only issue commands for hosts or services # that they are contacts for (unless you you choose to not use # authorization). You may use an asterisk (*) to authorize any # user who has authenticated to the web server. authorized_for_all_service_commands=nagiosadmin authorized_for_all_host_commands=nagiosadmin # READ-ONLY USERS # A comma-delimited list of usernames that have read-only rights in # the CGIs. This will block any service or host commands normally shown # on the extinfo CGI pages. It will also block comments from being shown # to read-only users. #authorized_for_read_only=user1,user2 # STATUSMAP BACKGROUND IMAGE # This option allows you to specify an image to be used as a # background in the statusmap CGI. It is assumed that the image # resides in the HTML images path (i.e. /usr/local/nagios/share/images). # This path is automatically determined by appending "/images" # to the path specified by the 'physical_html_path' directive. # Note: The image file may be in GIF, PNG, JPEG, or GD2 format. # However, I recommend that you convert your image to GD2 format # (uncompressed), as this will cause less CPU load when the CGI # generates the image. #statusmap_background_image=smbackground.gd2 # STATUSMAP TRANSPARENCY INDEX COLOR # These options set the r,g,b values of the background color used the statusmap CGI, # so normal browsers that can't show real png transparency set the desired color as # a background color instead (to make it look pretty). # Defaults to white: (R,G,B) = (255,255,255). #color_transparency_index_r=255 #color_transparency_index_g=255 #color_transparency_index_b=255 # DEFAULT STATUSMAP LAYOUT METHOD # This option allows you to specify the default layout method # the statusmap CGI should use for drawing hosts. If you do # not use this option, the default is to use user-defined # coordinates. Valid options are as follows: # 0 = User-defined coordinates # 1 = Depth layers # 2 = Collapsed tree # 3 = Balanced tree # 4 = Circular # 5 = Circular (Marked Up) default_statusmap_layout=5 # DEFAULT STATUSWRL LAYOUT METHOD # This option allows you to specify the default layout method # the statuswrl (VRML) CGI should use for drawing hosts. If you # do not use this option, the default is to use user-defined # coordinates. Valid options are as follows: # 0 = User-defined coordinates # 2 = Collapsed tree # 3 = Balanced tree # 4 = Circular default_statuswrl_layout=4 # STATUSWRL INCLUDE # This option allows you to include your own objects in the # generated VRML world. It is assumed that the file # resides in the HTML path (i.e. /usr/local/nagios/share). #statuswrl_include=myworld.wrl # PING SYNTAX # This option determines what syntax should be used when # attempting to ping a host from the WAP interface (using # the statuswml CGI. You must include the full path to # the ping binary, along with all required options. The # $HOSTADDRESS$ macro is substituted with the address of # the host before the command is executed. # Please note that the syntax for the ping binary is # notorious for being different on virtually ever *NIX # OS and distribution, so you may have to tweak this to # work on your system. ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$ # REFRESH RATE # This option allows you to specify the refresh rate in seconds # of various CGIs (status, statusmap, extinfo, and outages). refresh_rate=90 # ESCAPE HTML TAGS # This option determines whether HTML tags in host and service # status output is escaped in the web interface. If enabled, # your plugin output will not be able to contain clickable links. escape_html_tags=1 # SOUND OPTIONS # These options allow you to specify an optional audio file # that should be played in your browser window when there are # problems on the network. The audio files are used only in # the status CGI. Only the sound for the most critical problem # will be played. Order of importance (higher to lower) is as # follows: unreachable hosts, down hosts, critical services, # warning services, and unknown services. If there are no # visible problems, the sound file optionally specified by # 'normal_sound' variable will be played. # # # = # # Note: All audio files must be placed in the /media subdirectory # under the HTML path (i.e. /usr/local/nagios/share/media/). #host_unreachable_sound=hostdown.wav #host_down_sound=hostdown.wav #service_critical_sound=critical.wav #service_warning_sound=warning.wav #service_unknown_sound=warning.wav #normal_sound=noproblem.wav # URL TARGET FRAMES # These options determine the target frames in which notes and # action URLs will open. action_url_target=_blank notes_url_target=_blank # LOCK AUTHOR NAMES OPTION # This option determines whether users can change the author name # when submitting comments, scheduling downtime. If disabled, the # author names will be locked into their contact name, as defined in Nagios. # Values: 0 = allow editing author names # 1 = lock author names (disallow editing) lock_author_names=1 # SPLUNK INTEGRATION OPTIONS # These options allow you to enable integration with Splunk # in the web interface. If enabled, you'll be presented with # "Splunk It" links in various places in the CGIs (log file, # alert history, host/service detail, etc). Useful if you're # trying to research why a particular problem occurred. # For more information on Splunk, visit http://www.splunk.com/ # This option determines whether the Splunk integration is enabled # Values: 0 = disable Splunk integration # 1 = enable Splunk integration #enable_splunk_integration=1 # This option should be the URL used to access your instance of Splunk #splunk_url=http://127.0.0.1:8000/ Nagios-Object-0.21.20/t/v3_config/mrtg.cfg.in000444001750001750 1544312220262237 22014 0ustar00dfergusondferguson000000000000################################################################### # MRTG Graphs: Nagios @VERSION@ Statistics # # You can add the following entries to your MRTG config file to # begin graphing several Nagios statistics which can be useful for # debugging and trending purposes. The nagiostats binary (which is # included as part of the Nagios distribution) is used to generate # the data. ################################################################### # Service Latency and Execution Time Target[nagios-a]: `@bindir@/nagiostats --mrtg --data=AVGACTSVCLAT,AVGACTSVCEXT,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-a]: 100000 Title[nagios-a]: Average Service Check Latency and Execution Time PageTop[nagios-a]:

Average Service Check Latency and Execution Time

Options[nagios-a]: growright,gauge,nopercent YLegend[nagios-a]: Milliseconds ShortLegend[nagios-a]:   LegendI[nagios-a]:  Latency: LegendO[nagios-a]:  Execution Time: Legend1[nagios-a]: Latency Legend2[nagios-a]: Execution Time Legend3[nagios-a]: Maximal 5 Minute Latency Legend4[nagios-a]: Maximal 5 Minute Execution Time # Service Percent State Change Target[nagios-b]: `@bindir@/nagiostats --mrtg --data=AVGACTSVCPSC,AVGPSVSVCPSC,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-b]: 100 Title[nagios-b]: Average Service State Change PageTop[nagios-b]:

Average Service State Change

Options[nagios-b]: growright,gauge,nopercent YLegend[nagios-b]: Percent ShortLegend[nagios-b]:   LegendI[nagios-b]:  Active Check % Change: LegendO[nagios-b]:  Passive Check % Change: Legend1[nagios-b]: State Change Legend2[nagios-b]: State Change Legend3[nagios-b]: Maximal 5 Minute State Change Legend4[nagios-b]: Maximal 5 Minute State Change # Host Latency and Execution Time Target[nagios-c]: `@bindir@/nagiostats --mrtg --data=AVGACTHSTLAT,AVGACTHSTEXT,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-c]: 100000 Title[nagios-c]: Average Host Check Latency and Execution Time PageTop[nagios-c]:

Average Host Check Latency and Execution Time

Options[nagios-c]: growright,gauge,nopercent YLegend[nagios-c]: Milliseconds ShortLegend[nagios-c]:   LegendI[nagios-c]:  Latency: LegendO[nagios-c]:  Execution Time: Legend1[nagios-c]: Latency Legend2[nagios-c]: Execution Time Legend3[nagios-c]: Maximal 5 Minute Latency Legend4[nagios-c]: Maximal 5 Minute Execution Time # Host Percent State Change Target[nagios-d]: `@bindir@/nagiostats --mrtg --data=AVGACTHSTPSC,AVGPSVHSTPSC,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-d]: 100 Title[nagios-d]: Average Host State Change PageTop[nagios-d]:

Average Host State Change

Options[nagios-d]: growright,gauge,nopercent YLegend[nagios-d]: Percent ShortLegend[nagios-d]:   LegendI[nagios-d]:  Active Check % Change: LegendO[nagios-d]:  Passive Check % Change: Legend1[nagios-d]: State Change Legend2[nagios-d]: State Change Legend3[nagios-d]: Maximal 5 Minute State Change Legend4[nagios-d]: Maximal 5 Minute State Change # Hosts/Services Actively Checked Target[nagios-e]: `@bindir@/nagiostats --mrtg --data=NUMHSTACTCHK5M,NUMSVCACTCHK5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-e]: 7000 Title[nagios-e]: Hosts/Services Actively Checked PageTop[nagios-e]:

Hosts/Services Actively Checked

Options[nagios-e]: growright,gauge,nopercent YLegend[nagios-e]: Total ShortLegend[nagios-e]:   LegendI[nagios-e]:  Hosts: LegendO[nagios-e]:  Services: # Hosts/Services Passively Checked Target[nagios-f]: `@bindir@/nagiostats --mrtg --data=NUMHSTPSVCHK5M,NUMSVCPSVCHK5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-f]: 7000 Title[nagios-f]: Hosts/Services Passively Checked PageTop[nagios-f]:

Hosts/Services Passively Checked

Options[nagios-f]: growright,gauge,nopercent YLegend[nagios-f]: Total ShortLegend[nagios-f]:   LegendI[nagios-f]:  Hosts: LegendO[nagios-f]:  Services: # Used/Avail External Command Buffers Target[nagios-g]: `@bindir@/nagiostats --mrtg --data=TOTCMDBUF,USEDCMDBUF,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-g]: 7000 Title[nagios-g]: External Command Buffers PageTop[nagios-g]:

External Command Buffers

Options[nagios-g]: growright,gauge,nopercent YLegend[nagios-g]: Buffers ShortLegend[nagios-g]:   LegendI[nagios-g]:  Total: LegendO[nagios-g]:  Used: # Active Host Checks Target[nagios-i]: `@bindir@/nagiostats --mrtg --data=NUMSACTHSTCHECKS5M,NUMOACTHSTCHECKS5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-i]: 7000 Title[nagios-i]: Active Host Checks PageTop[nagios-i]:

Active Host Checks

Options[nagios-i]: growright,gauge,nopercent YLegend[nagios-i]: Checks ShortLegend[nagios-i]:   LegendI[nagios-i]:  Scheduled Checks: LegendO[nagios-i]:  On-Demand Checks: # Active Service Checks Target[nagios-j]: `@bindir@/nagiostats --mrtg --data=NUMSACTSVCCHECKS5M,NUMOACTSVCCHECKS5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-j]: 7000 Title[nagios-j]: Active Service Checks PageTop[nagios-j]:

Active Service Checks

Options[nagios-j]: growright,gauge,nopercent YLegend[nagios-j]: Checks ShortLegend[nagios-j]:   LegendI[nagios-j]:  Scheduled Checks: LegendO[nagios-j]:  On-Demand Checks: # Passive Host/Service Checks Target[nagios-k]: `@bindir@/nagiostats --mrtg --data=NUMPSVHSTCHECKS5M,NUMPSVSVCCHECKS5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-k]: 7000 Title[nagios-k]: Passive Host/Service Checks PageTop[nagios-k]:

Passive Host/Service Checks

Options[nagios-k]: growright,gauge,nopercent YLegend[nagios-k]: Checks ShortLegend[nagios-k]:   LegendI[nagios-k]:  Host Checks: LegendO[nagios-k]:  Service Checks: # Cached Host/Service Checks Target[nagios-l]: `@bindir@/nagiostats --mrtg --data=NUMCACHEDHSTCHECKS5M,NUMCACHEDSVCCHECKS5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-l]: 7000 Title[nagios-l]: Cached Host/Service Checks PageTop[nagios-l]:

Cached Host/Service Checks

Options[nagios-l]: growright,gauge,nopercent YLegend[nagios-l]: Checks ShortLegend[nagios-l]:   LegendI[nagios-l]:  Host Checks: LegendO[nagios-l]:  Service Checks: # External Commands Target[nagios-m]: `@bindir@/nagiostats --mrtg --data=NUMEXTCMDS5M,0,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-m]: 7000 Title[nagios-m]: External Commands PageTop[nagios-m]:

External Commands

Options[nagios-m]: growright,gauge,nopercent YLegend[nagios-m]: Commands ShortLegend[nagios-m]:   LegendI[nagios-m]:  Commands: LegendO[nagios-m]:   # Parallel/Service Host Checks Target[nagios-n]: `@bindir@/nagiostats --mrtg --data=NUMPARHSTCHECKS5M,NUMSERHSTCHECKS5M,PROGRUNTIME,NAGIOSVERPID` MaxBytes[nagios-n]: 7000 Title[nagios-n]: Parallel/Serial Host Checks PageTop[nagios-n]:

Parallel/Serial Host Checks

Options[nagios-n]: growright,gauge,nopercent YLegend[nagios-n]: Checks ShortLegend[nagios-n]:   LegendI[nagios-n]:  Parallel Checks: LegendO[nagios-n]:  Serial Checks: Nagios-Object-0.21.20/t/v3_config/cgi.cfg000444001750001750 2622012220262237 21173 0ustar00dfergusondferguson000000000000################################################################# # # CGI.CFG - Sample CGI Configuration File for Nagios 3.1.2 # # Last Modified: 06-17-2009 # ################################################################# # MAIN CONFIGURATION FILE # This tells the CGIs where to find your main configuration file. # The CGIs will read the main and host config files for any other # data they might need. main_config_file=/usr/local/nagios/etc/nagios.cfg # PHYSICAL HTML PATH # This is the path where the HTML files for Nagios reside. This # value is used to locate the logo images needed by the statusmap # and statuswrl CGIs. physical_html_path=/usr/local/nagios/share # URL HTML PATH # This is the path portion of the URL that corresponds to the # physical location of the Nagios HTML files (as defined above). # This value is used by the CGIs to locate the online documentation # and graphics. If you access the Nagios pages with an URL like # http://www.myhost.com/nagios, this value should be '/nagios' # (without the quotes). url_html_path=/nagios # CONTEXT-SENSITIVE HELP # This option determines whether or not a context-sensitive # help icon will be displayed for most of the CGIs. # Values: 0 = disables context-sensitive help # 1 = enables context-sensitive help show_context_help=0 # PENDING STATES OPTION # This option determines what states should be displayed in the web # interface for hosts/services that have not yet been checked. # Values: 0 = leave hosts/services that have not been check yet in their original state # 1 = mark hosts/services that have not been checked yet as PENDING use_pending_states=1 # AUTHENTICATION USAGE # This option controls whether or not the CGIs will use any # authentication when displaying host and service information, as # well as committing commands to Nagios for processing. # # Read the HTML documentation to learn how the authorization works! # # NOTE: It is a really *bad* idea to disable authorization, unless # you plan on removing the command CGI (cmd.cgi)! Failure to do # so will leave you wide open to kiddies messing with Nagios and # possibly hitting you with a denial of service attack by filling up # your drive by continuously writing to your command file! # # Setting this value to 0 will cause the CGIs to *not* use # authentication (bad idea), while any other value will make them # use the authentication functions (the default). use_authentication=1 # x509 CERT AUTHENTICATION # When enabled, this option allows you to use x509 cert (SSL) # authentication in the CGIs. This is an advanced option and should # not be enabled unless you know what you're doing. use_ssl_authentication=0 # DEFAULT USER # Setting this variable will define a default user name that can # access pages without authentication. This allows people within a # secure domain (i.e., behind a firewall) to see the current status # without authenticating. You may want to use this to avoid basic # authentication if you are not using a secure server since basic # authentication transmits passwords in the clear. # # Important: Do not define a default username unless you are # running a secure web server and are sure that everyone who has # access to the CGIs has been authenticated in some manner! If you # define this variable, anyone who has not authenticated to the web # server will inherit all rights you assign to this user! #default_user_name=guest # SYSTEM/PROCESS INFORMATION ACCESS # This option is a comma-delimited list of all usernames that # have access to viewing the Nagios process information as # provided by the Extended Information CGI (extinfo.cgi). By # default, *no one* has access to this unless you choose to # not use authorization. You may use an asterisk (*) to # authorize any user who has authenticated to the web server. authorized_for_system_information=nagiosadmin # CONFIGURATION INFORMATION ACCESS # This option is a comma-delimited list of all usernames that # can view ALL configuration information (hosts, commands, etc). # By default, users can only view configuration information # for the hosts and services they are contacts for. You may use # an asterisk (*) to authorize any user who has authenticated # to the web server. authorized_for_configuration_information=nagiosadmin # SYSTEM/PROCESS COMMAND ACCESS # This option is a comma-delimited list of all usernames that # can issue shutdown and restart commands to Nagios via the # command CGI (cmd.cgi). Users in this list can also change # the program mode to active or standby. By default, *no one* # has access to this unless you choose to not use authorization. # You may use an asterisk (*) to authorize any user who has # authenticated to the web server. authorized_for_system_commands=nagiosadmin # GLOBAL HOST/SERVICE VIEW ACCESS # These two options are comma-delimited lists of all usernames that # can view information for all hosts and services that are being # monitored. By default, users can only view information # for hosts or services that they are contacts for (unless you # you choose to not use authorization). You may use an asterisk (*) # to authorize any user who has authenticated to the web server. authorized_for_all_services=nagiosadmin authorized_for_all_hosts=nagiosadmin # GLOBAL HOST/SERVICE COMMAND ACCESS # These two options are comma-delimited lists of all usernames that # can issue host or service related commands via the command # CGI (cmd.cgi) for all hosts and services that are being monitored. # By default, users can only issue commands for hosts or services # that they are contacts for (unless you you choose to not use # authorization). You may use an asterisk (*) to authorize any # user who has authenticated to the web server. authorized_for_all_service_commands=nagiosadmin authorized_for_all_host_commands=nagiosadmin # READ-ONLY USERS # A comma-delimited list of usernames that have read-only rights in # the CGIs. This will block any service or host commands normally shown # on the extinfo CGI pages. It will also block comments from being shown # to read-only users. #authorized_for_read_only=user1,user2 # STATUSMAP BACKGROUND IMAGE # This option allows you to specify an image to be used as a # background in the statusmap CGI. It is assumed that the image # resides in the HTML images path (i.e. /usr/local/nagios/share/images). # This path is automatically determined by appending "/images" # to the path specified by the 'physical_html_path' directive. # Note: The image file may be in GIF, PNG, JPEG, or GD2 format. # However, I recommend that you convert your image to GD2 format # (uncompressed), as this will cause less CPU load when the CGI # generates the image. #statusmap_background_image=smbackground.gd2 # STATUSMAP TRANSPARENCY INDEX COLOR # These options set the r,g,b values of the background color used the statusmap CGI, # so normal browsers that can't show real png transparency set the desired color as # a background color instead (to make it look pretty). # Defaults to white: (R,G,B) = (255,255,255). #color_transparency_index_r=255 #color_transparency_index_g=255 #color_transparency_index_b=255 # DEFAULT STATUSMAP LAYOUT METHOD # This option allows you to specify the default layout method # the statusmap CGI should use for drawing hosts. If you do # not use this option, the default is to use user-defined # coordinates. Valid options are as follows: # 0 = User-defined coordinates # 1 = Depth layers # 2 = Collapsed tree # 3 = Balanced tree # 4 = Circular # 5 = Circular (Marked Up) default_statusmap_layout=5 # DEFAULT STATUSWRL LAYOUT METHOD # This option allows you to specify the default layout method # the statuswrl (VRML) CGI should use for drawing hosts. If you # do not use this option, the default is to use user-defined # coordinates. Valid options are as follows: # 0 = User-defined coordinates # 2 = Collapsed tree # 3 = Balanced tree # 4 = Circular default_statuswrl_layout=4 # STATUSWRL INCLUDE # This option allows you to include your own objects in the # generated VRML world. It is assumed that the file # resides in the HTML path (i.e. /usr/local/nagios/share). #statuswrl_include=myworld.wrl # PING SYNTAX # This option determines what syntax should be used when # attempting to ping a host from the WAP interface (using # the statuswml CGI. You must include the full path to # the ping binary, along with all required options. The # $HOSTADDRESS$ macro is substituted with the address of # the host before the command is executed. # Please note that the syntax for the ping binary is # notorious for being different on virtually ever *NIX # OS and distribution, so you may have to tweak this to # work on your system. ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$ # REFRESH RATE # This option allows you to specify the refresh rate in seconds # of various CGIs (status, statusmap, extinfo, and outages). refresh_rate=90 # ESCAPE HTML TAGS # This option determines whether HTML tags in host and service # status output is escaped in the web interface. If enabled, # your plugin output will not be able to contain clickable links. escape_html_tags=1 # SOUND OPTIONS # These options allow you to specify an optional audio file # that should be played in your browser window when there are # problems on the network. The audio files are used only in # the status CGI. Only the sound for the most critical problem # will be played. Order of importance (higher to lower) is as # follows: unreachable hosts, down hosts, critical services, # warning services, and unknown services. If there are no # visible problems, the sound file optionally specified by # 'normal_sound' variable will be played. # # # = # # Note: All audio files must be placed in the /media subdirectory # under the HTML path (i.e. /usr/local/nagios/share/media/). #host_unreachable_sound=hostdown.wav #host_down_sound=hostdown.wav #service_critical_sound=critical.wav #service_warning_sound=warning.wav #service_unknown_sound=warning.wav #normal_sound=noproblem.wav # URL TARGET FRAMES # These options determine the target frames in which notes and # action URLs will open. action_url_target=_blank notes_url_target=_blank # LOCK AUTHOR NAMES OPTION # This option determines whether users can change the author name # when submitting comments, scheduling downtime. If disabled, the # author names will be locked into their contact name, as defined in Nagios. # Values: 0 = allow editing author names # 1 = lock author names (disallow editing) lock_author_names=1 # SPLUNK INTEGRATION OPTIONS # These options allow you to enable integration with Splunk # in the web interface. If enabled, you'll be presented with # "Splunk It" links in various places in the CGIs (log file, # alert history, host/service detail, etc). Useful if you're # trying to research why a particular problem occurred. # For more information on Splunk, visit http://www.splunk.com/ # This option determines whether the Splunk integration is enabled # Values: 0 = disable Splunk integration # 1 = enable Splunk integration #enable_splunk_integration=1 # This option should be the URL used to access your instance of Splunk #splunk_url=http://127.0.0.1:8000/ Nagios-Object-0.21.20/t/v3_config/nagios.cfg000444001750001750 12540012220262237 21731 0ustar00dfergusondferguson000000000000############################################################################## # # NAGIOS.CFG - Sample Main Config File for Nagios 3.1.2 # # Read the documentation for more information on this configuration # file. I've provided some comments here, but things may not be so # clear without further explanation. # # Last Modified: 12-14-2008 # ############################################################################## # LOG FILE # This is the main log file where service and host events are logged # for historical purposes. This should be the first option specified # in the config file!!! log_file=/usr/local/nagios/var/nagios.log # OBJECT CONFIGURATION FILE(S) # These are the object configuration files in which you define hosts, # host groups, contacts, contact groups, services, etc. # You can split your object definitions across several config files # if you wish (as shown below), or keep them all in a single config file. # You can specify individual object config files as shown below: cfg_file=/usr/local/nagios/etc/objects/commands.cfg cfg_file=/usr/local/nagios/etc/objects/contacts.cfg cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg cfg_file=/usr/local/nagios/etc/objects/templates.cfg # Definitions for monitoring the local (Linux) host cfg_file=/usr/local/nagios/etc/objects/localhost.cfg # Definitions for monitoring a Windows machine #cfg_file=/usr/local/nagios/etc/objects/windows.cfg # Definitions for monitoring a router/switch #cfg_file=/usr/local/nagios/etc/objects/switch.cfg # Definitions for monitoring a network printer #cfg_file=/usr/local/nagios/etc/objects/printer.cfg # You can also tell Nagios to process all config files (with a .cfg # extension) in a particular directory by using the cfg_dir # directive as shown below: #cfg_dir=/usr/local/nagios/etc/servers #cfg_dir=/usr/local/nagios/etc/printers #cfg_dir=/usr/local/nagios/etc/switches #cfg_dir=/usr/local/nagios/etc/routers # OBJECT CACHE FILE # This option determines where object definitions are cached when # Nagios starts/restarts. The CGIs read object definitions from # this cache file (rather than looking at the object config files # directly) in order to prevent inconsistencies that can occur # when the config files are modified after Nagios starts. object_cache_file=/usr/local/nagios/var/objects.cache # PRE-CACHED OBJECT FILE # This options determines the location of the precached object file. # If you run Nagios with the -p command line option, it will preprocess # your object configuration file(s) and write the cached config to this # file. You can then start Nagios with the -u option to have it read # object definitions from this precached file, rather than the standard # object configuration files (see the cfg_file and cfg_dir options above). # Using a precached object file can speed up the time needed to (re)start # the Nagios process if you've got a large and/or complex configuration. # Read the documentation section on optimizing Nagios to find our more # about how this feature works. precached_object_file=/usr/local/nagios/var/objects.precache # RESOURCE FILE # This is an optional resource file that contains $USERx$ macro # definitions. Multiple resource files can be specified by using # multiple resource_file definitions. The CGIs will not attempt to # read the contents of resource files, so information that is # considered to be sensitive (usernames, passwords, etc) can be # defined as macros in this file and restrictive permissions (600) # can be placed on this file. resource_file=/usr/local/nagios/etc/resource.cfg # STATUS FILE # This is where the current status of all monitored services and # hosts is stored. Its contents are read and processed by the CGIs. # The contents of the status file are deleted every time Nagios # restarts. status_file=/usr/local/nagios/var/status.dat # STATUS FILE UPDATE INTERVAL # This option determines the frequency (in seconds) that # Nagios will periodically dump program, host, and # service status data. status_update_interval=10 # NAGIOS USER # This determines the effective user that Nagios should run as. # You can either supply a username or a UID. nagios_user=nagios # NAGIOS GROUP # This determines the effective group that Nagios should run as. # You can either supply a group name or a GID. nagios_group=nagios # EXTERNAL COMMAND OPTION # This option allows you to specify whether or not Nagios should check # for external commands (in the command file defined below). By default # Nagios will *not* check for external commands, just to be on the # cautious side. If you want to be able to use the CGI command interface # you will have to enable this. # Values: 0 = disable commands, 1 = enable commands check_external_commands=1 # EXTERNAL COMMAND CHECK INTERVAL # This is the interval at which Nagios should check for external commands. # This value works of the interval_length you specify later. If you leave # that at its default value of 60 (seconds), a value of 1 here will cause # Nagios to check for external commands every minute. If you specify a # number followed by an "s" (i.e. 15s), this will be interpreted to mean # actual seconds rather than a multiple of the interval_length variable. # Note: In addition to reading the external command file at regularly # scheduled intervals, Nagios will also check for external commands after # event handlers are executed. # NOTE: Setting this value to -1 causes Nagios to check the external # command file as often as possible. #command_check_interval=15s command_check_interval=-1 # EXTERNAL COMMAND FILE # This is the file that Nagios checks for external command requests. # It is also where the command CGI will write commands that are submitted # by users, so it must be writeable by the user that the web server # is running as (usually 'nobody'). Permissions should be set at the # directory level instead of on the file, as the file is deleted every # time its contents are processed. command_file=/usr/local/nagios/var/rw/nagios.cmd # EXTERNAL COMMAND BUFFER SLOTS # This settings is used to tweak the number of items or "slots" that # the Nagios daemon should allocate to the buffer that holds incoming # external commands before they are processed. As external commands # are processed by the daemon, they are removed from the buffer. external_command_buffer_slots=4096 # LOCK FILE # This is the lockfile that Nagios will use to store its PID number # in when it is running in daemon mode. lock_file=/usr/local/nagios/var/nagios.lock # TEMP FILE # This is a temporary file that is used as scratch space when Nagios # updates the status log, cleans the comment file, etc. This file # is created, used, and deleted throughout the time that Nagios is # running. temp_file=/usr/local/nagios/var/nagios.tmp # TEMP PATH # This is path where Nagios can create temp files for service and # host check results, etc. temp_path=/tmp # EVENT BROKER OPTIONS # Controls what (if any) data gets sent to the event broker. # Values: 0 = Broker nothing # -1 = Broker everything # = See documentation event_broker_options=-1 # EVENT BROKER MODULE(S) # This directive is used to specify an event broker module that should # by loaded by Nagios at startup. Use multiple directives if you want # to load more than one module. Arguments that should be passed to # the module at startup are seperated from the module path by a space. # #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # # Do NOT overwrite modules while they are being used by Nagios or Nagios # will crash in a fiery display of SEGFAULT glory. This is a bug/limitation # either in dlopen(), the kernel, and/or the filesystem. And maybe Nagios... # # The correct/safe way of updating a module is by using one of these methods: # 1. Shutdown Nagios, replace the module file, restart Nagios # 2. Delete the original module file, move the new module file into place, restart Nagios # # Example: # # broker_module= [moduleargs] #broker_module=/somewhere/module1.o #broker_module=/somewhere/module2.o arg1 arg2=3 debug=0 # LOG ROTATION METHOD # This is the log rotation method that Nagios should use to rotate # the main log file. Values are as follows.. # n = None - don't rotate the log # h = Hourly rotation (top of the hour) # d = Daily rotation (midnight every day) # w = Weekly rotation (midnight on Saturday evening) # m = Monthly rotation (midnight last day of month) log_rotation_method=d # LOG ARCHIVE PATH # This is the directory where archived (rotated) log files should be # placed (assuming you've chosen to do log rotation). log_archive_path=/usr/local/nagios/var/archives # LOGGING OPTIONS # If you want messages logged to the syslog facility, as well as the # Nagios log file set this option to 1. If not, set it to 0. use_syslog=1 # NOTIFICATION LOGGING OPTION # If you don't want notifications to be logged, set this value to 0. # If notifications should be logged, set the value to 1. log_notifications=1 # SERVICE RETRY LOGGING OPTION # If you don't want service check retries to be logged, set this value # to 0. If retries should be logged, set the value to 1. log_service_retries=1 # HOST RETRY LOGGING OPTION # If you don't want host check retries to be logged, set this value to # 0. If retries should be logged, set the value to 1. log_host_retries=1 # EVENT HANDLER LOGGING OPTION # If you don't want host and service event handlers to be logged, set # this value to 0. If event handlers should be logged, set the value # to 1. log_event_handlers=1 # INITIAL STATES LOGGING OPTION # If you want Nagios to log all initial host and service states to # the main log file (the first time the service or host is checked) # you can enable this option by setting this value to 1. If you # are not using an external application that does long term state # statistics reporting, you do not need to enable this option. In # this case, set the value to 0. log_initial_states=0 # EXTERNAL COMMANDS LOGGING OPTION # If you don't want Nagios to log external commands, set this value # to 0. If external commands should be logged, set this value to 1. # Note: This option does not include logging of passive service # checks - see the option below for controlling whether or not # passive checks are logged. log_external_commands=1 # PASSIVE CHECKS LOGGING OPTION # If you don't want Nagios to log passive host and service checks, set # this value to 0. If passive checks should be logged, set # this value to 1. log_passive_checks=1 # GLOBAL HOST AND SERVICE EVENT HANDLERS # These options allow you to specify a host and service event handler # command that is to be run for every host or service state change. # The global event handler is executed immediately prior to the event # handler that you have optionally specified in each host or # service definition. The command argument is the short name of a # command definition that you define in your host configuration file. # Read the HTML docs for more information. #global_host_event_handler=somecommand #global_service_event_handler=somecommand # SERVICE INTER-CHECK DELAY METHOD # This is the method that Nagios should use when initially # "spreading out" service checks when it starts monitoring. The # default is to use smart delay calculation, which will try to # space all service checks out evenly to minimize CPU load. # Using the dumb setting will cause all checks to be scheduled # at the same time (with no delay between them)! This is not a # good thing for production, but is useful when testing the # parallelization functionality. # n = None - don't use any delay between checks # d = Use a "dumb" delay of 1 second between checks # s = Use "smart" inter-check delay calculation # x.xx = Use an inter-check delay of x.xx seconds service_inter_check_delay_method=s # MAXIMUM SERVICE CHECK SPREAD # This variable determines the timeframe (in minutes) from the # program start time that an initial check of all services should # be completed. Default is 30 minutes. max_service_check_spread=30 # SERVICE CHECK INTERLEAVE FACTOR # This variable determines how service checks are interleaved. # Interleaving the service checks allows for a more even # distribution of service checks and reduced load on remote # hosts. Setting this value to 1 is equivalent to how versions # of Nagios previous to 0.0.5 did service checks. Set this # value to s (smart) for automatic calculation of the interleave # factor unless you have a specific reason to change it. # s = Use "smart" interleave factor calculation # x = Use an interleave factor of x, where x is a # number greater than or equal to 1. service_interleave_factor=s # HOST INTER-CHECK DELAY METHOD # This is the method that Nagios should use when initially # "spreading out" host checks when it starts monitoring. The # default is to use smart delay calculation, which will try to # space all host checks out evenly to minimize CPU load. # Using the dumb setting will cause all checks to be scheduled # at the same time (with no delay between them)! # n = None - don't use any delay between checks # d = Use a "dumb" delay of 1 second between checks # s = Use "smart" inter-check delay calculation # x.xx = Use an inter-check delay of x.xx seconds host_inter_check_delay_method=s # MAXIMUM HOST CHECK SPREAD # This variable determines the timeframe (in minutes) from the # program start time that an initial check of all hosts should # be completed. Default is 30 minutes. max_host_check_spread=30 # MAXIMUM CONCURRENT SERVICE CHECKS # This option allows you to specify the maximum number of # service checks that can be run in parallel at any given time. # Specifying a value of 1 for this variable essentially prevents # any service checks from being parallelized. A value of 0 # will not restrict the number of concurrent checks that are # being executed. max_concurrent_checks=0 # HOST AND SERVICE CHECK REAPER FREQUENCY # This is the frequency (in seconds!) that Nagios will process # the results of host and service checks. check_result_reaper_frequency=10 # MAX CHECK RESULT REAPER TIME # This is the max amount of time (in seconds) that a single # check result reaper event will be allowed to run before # returning control back to Nagios so it can perform other # duties. max_check_result_reaper_time=30 # CHECK RESULT PATH # This is directory where Nagios stores the results of host and # service checks that have not yet been processed. # # Note: Make sure that only one instance of Nagios has access # to this directory! check_result_path=/usr/local/nagios/var/spool/checkresults # MAX CHECK RESULT FILE AGE # This option determines the maximum age (in seconds) which check # result files are considered to be valid. Files older than this # threshold will be mercilessly deleted without further processing. max_check_result_file_age=3600 # CACHED HOST CHECK HORIZON # This option determines the maximum amount of time (in seconds) # that the state of a previous host check is considered current. # Cached host states (from host checks that were performed more # recently that the timeframe specified by this value) can immensely # improve performance in regards to the host check logic. # Too high of a value for this option may result in inaccurate host # states being used by Nagios, while a lower value may result in a # performance hit for host checks. Use a value of 0 to disable host # check caching. cached_host_check_horizon=15 # CACHED SERVICE CHECK HORIZON # This option determines the maximum amount of time (in seconds) # that the state of a previous service check is considered current. # Cached service states (from service checks that were performed more # recently that the timeframe specified by this value) can immensely # improve performance in regards to predictive dependency checks. # Use a value of 0 to disable service check caching. cached_service_check_horizon=15 # ENABLE PREDICTIVE HOST DEPENDENCY CHECKS # This option determines whether or not Nagios will attempt to execute # checks of hosts when it predicts that future dependency logic test # may be needed. These predictive checks can help ensure that your # host dependency logic works well. # Values: # 0 = Disable predictive checks # 1 = Enable predictive checks (default) enable_predictive_host_dependency_checks=1 # ENABLE PREDICTIVE SERVICE DEPENDENCY CHECKS # This option determines whether or not Nagios will attempt to execute # checks of service when it predicts that future dependency logic test # may be needed. These predictive checks can help ensure that your # service dependency logic works well. # Values: # 0 = Disable predictive checks # 1 = Enable predictive checks (default) enable_predictive_service_dependency_checks=1 # SOFT STATE DEPENDENCIES # This option determines whether or not Nagios will use soft state # information when checking host and service dependencies. Normally # Nagios will only use the latest hard host or service state when # checking dependencies. If you want it to use the latest state (regardless # of whether its a soft or hard state type), enable this option. # Values: # 0 = Don't use soft state dependencies (default) # 1 = Use soft state dependencies soft_state_dependencies=0 # TIME CHANGE ADJUSTMENT THRESHOLDS # These options determine when Nagios will react to detected changes # in system time (either forward or backwards). #time_change_threshold=900 # AUTO-RESCHEDULING OPTION # This option determines whether or not Nagios will attempt to # automatically reschedule active host and service checks to # "smooth" them out over time. This can help balance the load on # the monitoring server. # WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE # PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY auto_reschedule_checks=0 # AUTO-RESCHEDULING INTERVAL # This option determines how often (in seconds) Nagios will # attempt to automatically reschedule checks. This option only # has an effect if the auto_reschedule_checks option is enabled. # Default is 30 seconds. # WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE # PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY auto_rescheduling_interval=30 # AUTO-RESCHEDULING WINDOW # This option determines the "window" of time (in seconds) that # Nagios will look at when automatically rescheduling checks. # Only host and service checks that occur in the next X seconds # (determined by this variable) will be rescheduled. This option # only has an effect if the auto_reschedule_checks option is # enabled. Default is 180 seconds (3 minutes). # WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE # PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY auto_rescheduling_window=180 # SLEEP TIME # This is the number of seconds to sleep between checking for system # events and service checks that need to be run. sleep_time=0.25 # TIMEOUT VALUES # These options control how much time Nagios will allow various # types of commands to execute before killing them off. Options # are available for controlling maximum time allotted for # service checks, host checks, event handlers, notifications, the # ocsp command, and performance data commands. All values are in # seconds. service_check_timeout=60 host_check_timeout=30 event_handler_timeout=30 notification_timeout=30 ocsp_timeout=5 perfdata_timeout=5 # RETAIN STATE INFORMATION # This setting determines whether or not Nagios will save state # information for services and hosts before it shuts down. Upon # startup Nagios will reload all saved service and host state # information before starting to monitor. This is useful for # maintaining long-term data on state statistics, etc, but will # slow Nagios down a bit when it (re)starts. Since its only # a one-time penalty, I think its well worth the additional # startup delay. retain_state_information=1 # STATE RETENTION FILE # This is the file that Nagios should use to store host and # service state information before it shuts down. The state # information in this file is also read immediately prior to # starting to monitor the network when Nagios is restarted. # This file is used only if the preserve_state_information # variable is set to 1. state_retention_file=/usr/local/nagios/var/retention.dat # RETENTION DATA UPDATE INTERVAL # This setting determines how often (in minutes) that Nagios # will automatically save retention data during normal operation. # If you set this value to 0, Nagios will not save retention # data at regular interval, but it will still save retention # data before shutting down or restarting. If you have disabled # state retention, this option has no effect. retention_update_interval=60 # USE RETAINED PROGRAM STATE # This setting determines whether or not Nagios will set # program status variables based on the values saved in the # retention file. If you want to use retained program status # information, set this value to 1. If not, set this value # to 0. use_retained_program_state=1 # USE RETAINED SCHEDULING INFO # This setting determines whether or not Nagios will retain # the scheduling info (next check time) for hosts and services # based on the values saved in the retention file. If you # If you want to use retained scheduling info, set this # value to 1. If not, set this value to 0. use_retained_scheduling_info=1 # RETAINED ATTRIBUTE MASKS (ADVANCED FEATURE) # The following variables are used to specify specific host and # service attributes that should *not* be retained by Nagios during # program restarts. # # The values of the masks are bitwise ANDs of values specified # by the "MODATTR_" definitions found in include/common.h. # For example, if you do not want the current enabled/disabled state # of flap detection and event handlers for hosts to be retained, you # would use a value of 24 for the host attribute mask... # MODATTR_EVENT_HANDLER_ENABLED (8) + MODATTR_FLAP_DETECTION_ENABLED (16) = 24 # This mask determines what host attributes are not retained retained_host_attribute_mask=0 # This mask determines what service attributes are not retained retained_service_attribute_mask=0 # These two masks determine what process attributes are not retained. # There are two masks, because some process attributes have host and service # options. For example, you can disable active host checks, but leave active # service checks enabled. retained_process_host_attribute_mask=0 retained_process_service_attribute_mask=0 # These two masks determine what contact attributes are not retained. # There are two masks, because some contact attributes have host and # service options. For example, you can disable host notifications for # a contact, but leave service notifications enabled for them. retained_contact_host_attribute_mask=0 retained_contact_service_attribute_mask=0 # INTERVAL LENGTH # This is the seconds per unit interval as used in the # host/contact/service configuration files. Setting this to 60 means # that each interval is one minute long (60 seconds). Other settings # have not been tested much, so your mileage is likely to vary... interval_length=60 # CHECK FOR UPDATES # This option determines whether Nagios will automatically check to # see if new updates (releases) are available. It is recommend that you # enable this option to ensure that you stay on top of the latest critical # patches to Nagios. Nagios is critical to you - make sure you keep it in # good shape. Nagios will check once a day for new updates. Data collected # by Nagios Enterprises from the update check is processed in accordance # with our privacy policy - see http://api.nagios.org for details. check_for_updates=1 # BARE UPDATE CHECK # This option deterines what data Nagios will send to api.nagios.org when # it checks for updates. By default, Nagios will send information on the # current version of Nagios you have installed, as well as an indicator as # to whether this was a new installation or not. Nagios Enterprises uses # this data to determine the number of users running specific version of # Nagios. Enable this option if you do not want this information to be sent. bare_update_check=0 # AGGRESSIVE HOST CHECKING OPTION # If you don't want to turn on aggressive host checking features, set # this value to 0 (the default). Otherwise set this value to 1 to # enable the aggressive check option. Read the docs for more info # on what aggressive host check is or check out the source code in # base/checks.c use_aggressive_host_checking=0 # SERVICE CHECK EXECUTION OPTION # This determines whether or not Nagios will actively execute # service checks when it initially starts. If this option is # disabled, checks are not actively made, but Nagios can still # receive and process passive check results that come in. Unless # you're implementing redundant hosts or have a special need for # disabling the execution of service checks, leave this enabled! # Values: 1 = enable checks, 0 = disable checks execute_service_checks=1 # PASSIVE SERVICE CHECK ACCEPTANCE OPTION # This determines whether or not Nagios will accept passive # service checks results when it initially (re)starts. # Values: 1 = accept passive checks, 0 = reject passive checks accept_passive_service_checks=1 # HOST CHECK EXECUTION OPTION # This determines whether or not Nagios will actively execute # host checks when it initially starts. If this option is # disabled, checks are not actively made, but Nagios can still # receive and process passive check results that come in. Unless # you're implementing redundant hosts or have a special need for # disabling the execution of host checks, leave this enabled! # Values: 1 = enable checks, 0 = disable checks execute_host_checks=1 # PASSIVE HOST CHECK ACCEPTANCE OPTION # This determines whether or not Nagios will accept passive # host checks results when it initially (re)starts. # Values: 1 = accept passive checks, 0 = reject passive checks accept_passive_host_checks=1 # NOTIFICATIONS OPTION # This determines whether or not Nagios will sent out any host or # service notifications when it is initially (re)started. # Values: 1 = enable notifications, 0 = disable notifications enable_notifications=1 # EVENT HANDLER USE OPTION # This determines whether or not Nagios will run any host or # service event handlers when it is initially (re)started. Unless # you're implementing redundant hosts, leave this option enabled. # Values: 1 = enable event handlers, 0 = disable event handlers enable_event_handlers=1 # PROCESS PERFORMANCE DATA OPTION # This determines whether or not Nagios will process performance # data returned from service and host checks. If this option is # enabled, host performance data will be processed using the # host_perfdata_command (defined below) and service performance # data will be processed using the service_perfdata_command (also # defined below). Read the HTML docs for more information on # performance data. # Values: 1 = process performance data, 0 = do not process performance data process_performance_data=0 # HOST AND SERVICE PERFORMANCE DATA PROCESSING COMMANDS # These commands are run after every host and service check is # performed. These commands are executed only if the # enable_performance_data option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on performance data. #host_perfdata_command=process-host-perfdata #service_perfdata_command=process-service-perfdata # HOST AND SERVICE PERFORMANCE DATA FILES # These files are used to store host and service performance data. # Performance data is only written to these files if the # enable_performance_data option (above) is set to 1. #host_perfdata_file=/tmp/host-perfdata #service_perfdata_file=/tmp/service-perfdata # HOST AND SERVICE PERFORMANCE DATA FILE TEMPLATES # These options determine what data is written (and how) to the # performance data files. The templates may contain macros, special # characters (\t for tab, \r for carriage return, \n for newline) # and plain text. A newline is automatically added after each write # to the performance data file. Some examples of what you can do are # shown below. #host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$ #service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$ # HOST AND SERVICE PERFORMANCE DATA FILE MODES # This option determines whether or not the host and service # performance data files are opened in write ("w") or append ("a") # mode. If you want to use named pipes, you should use the special # pipe ("p") mode which avoid blocking at startup, otherwise you will # likely want the defult append ("a") mode. #host_perfdata_file_mode=a #service_perfdata_file_mode=a # HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING INTERVAL # These options determine how often (in seconds) the host and service # performance data files are processed using the commands defined # below. A value of 0 indicates the files should not be periodically # processed. #host_perfdata_file_processing_interval=0 #service_perfdata_file_processing_interval=0 # HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING COMMANDS # These commands are used to periodically process the host and # service performance data files. The interval at which the # processing occurs is determined by the options above. #host_perfdata_file_processing_command=process-host-perfdata-file #service_perfdata_file_processing_command=process-service-perfdata-file # OBSESS OVER SERVICE CHECKS OPTION # This determines whether or not Nagios will obsess over service # checks and run the ocsp_command defined below. Unless you're # planning on implementing distributed monitoring, do not enable # this option. Read the HTML docs for more information on # implementing distributed monitoring. # Values: 1 = obsess over services, 0 = do not obsess (default) obsess_over_services=0 # OBSESSIVE COMPULSIVE SERVICE PROCESSOR COMMAND # This is the command that is run for every service check that is # processed by Nagios. This command is executed only if the # obsess_over_services option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on implementing distributed monitoring. #ocsp_command=somecommand # OBSESS OVER HOST CHECKS OPTION # This determines whether or not Nagios will obsess over host # checks and run the ochp_command defined below. Unless you're # planning on implementing distributed monitoring, do not enable # this option. Read the HTML docs for more information on # implementing distributed monitoring. # Values: 1 = obsess over hosts, 0 = do not obsess (default) obsess_over_hosts=0 # OBSESSIVE COMPULSIVE HOST PROCESSOR COMMAND # This is the command that is run for every host check that is # processed by Nagios. This command is executed only if the # obsess_over_hosts option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on implementing distributed monitoring. #ochp_command=somecommand # TRANSLATE PASSIVE HOST CHECKS OPTION # This determines whether or not Nagios will translate # DOWN/UNREACHABLE passive host check results into their proper # state for this instance of Nagios. This option is useful # if you have distributed or failover monitoring setup. In # these cases your other Nagios servers probably have a different # "view" of the network, with regards to the parent/child relationship # of hosts. If a distributed monitoring server thinks a host # is DOWN, it may actually be UNREACHABLE from the point of # this Nagios instance. Enabling this option will tell Nagios # to translate any DOWN or UNREACHABLE host states it receives # passively into the correct state from the view of this server. # Values: 1 = perform translation, 0 = do not translate (default) translate_passive_host_checks=0 # PASSIVE HOST CHECKS ARE SOFT OPTION # This determines whether or not Nagios will treat passive host # checks as being HARD or SOFT. By default, a passive host check # result will put a host into a HARD state type. This can be changed # by enabling this option. # Values: 0 = passive checks are HARD, 1 = passive checks are SOFT passive_host_checks_are_soft=0 # ORPHANED HOST/SERVICE CHECK OPTIONS # These options determine whether or not Nagios will periodically # check for orphaned host service checks. Since service checks are # not rescheduled until the results of their previous execution # instance are processed, there exists a possibility that some # checks may never get rescheduled. A similar situation exists for # host checks, although the exact scheduling details differ a bit # from service checks. Orphaned checks seem to be a rare # problem and should not happen under normal circumstances. # If you have problems with service checks never getting # rescheduled, make sure you have orphaned service checks enabled. # Values: 1 = enable checks, 0 = disable checks check_for_orphaned_services=1 check_for_orphaned_hosts=1 # SERVICE FRESHNESS CHECK OPTION # This option determines whether or not Nagios will periodically # check the "freshness" of service results. Enabling this option # is useful for ensuring passive checks are received in a timely # manner. # Values: 1 = enabled freshness checking, 0 = disable freshness checking check_service_freshness=1 # SERVICE FRESHNESS CHECK INTERVAL # This setting determines how often (in seconds) Nagios will # check the "freshness" of service check results. If you have # disabled service freshness checking, this option has no effect. service_freshness_check_interval=60 # HOST FRESHNESS CHECK OPTION # This option determines whether or not Nagios will periodically # check the "freshness" of host results. Enabling this option # is useful for ensuring passive checks are received in a timely # manner. # Values: 1 = enabled freshness checking, 0 = disable freshness checking check_host_freshness=0 # HOST FRESHNESS CHECK INTERVAL # This setting determines how often (in seconds) Nagios will # check the "freshness" of host check results. If you have # disabled host freshness checking, this option has no effect. host_freshness_check_interval=60 # ADDITIONAL FRESHNESS THRESHOLD LATENCY # This setting determines the number of seconds that Nagios # will add to any host and service freshness thresholds that # it calculates (those not explicitly specified by the user). additional_freshness_latency=15 # FLAP DETECTION OPTION # This option determines whether or not Nagios will try # and detect hosts and services that are "flapping". # Flapping occurs when a host or service changes between # states too frequently. When Nagios detects that a # host or service is flapping, it will temporarily suppress # notifications for that host/service until it stops # flapping. Flap detection is very experimental, so read # the HTML documentation before enabling this feature! # Values: 1 = enable flap detection # 0 = disable flap detection (default) enable_flap_detection=1 # FLAP DETECTION THRESHOLDS FOR HOSTS AND SERVICES # Read the HTML documentation on flap detection for # an explanation of what this option does. This option # has no effect if flap detection is disabled. low_service_flap_threshold=5.0 high_service_flap_threshold=20.0 low_host_flap_threshold=5.0 high_host_flap_threshold=20.0 # DATE FORMAT OPTION # This option determines how short dates are displayed. Valid options # include: # us (MM-DD-YYYY HH:MM:SS) # euro (DD-MM-YYYY HH:MM:SS) # iso8601 (YYYY-MM-DD HH:MM:SS) # strict-iso8601 (YYYY-MM-DDTHH:MM:SS) # date_format=us # TIMEZONE OFFSET # This option is used to override the default timezone that this # instance of Nagios runs in. If not specified, Nagios will use # the system configured timezone. # # NOTE: In order to display the correct timezone in the CGIs, you # will also need to alter the Apache directives for the CGI path # to include your timezone. Example: # # # SetEnv TZ "Australia/Brisbane" # ... # #use_timezone=US/Mountain #use_timezone=Australia/Brisbane # P1.PL FILE LOCATION # This value determines where the p1.pl perl script (used by the # embedded Perl interpreter) is located. If you didn't compile # Nagios with embedded Perl support, this option has no effect. p1_file=/usr/local/nagios/bin/p1.pl # EMBEDDED PERL INTERPRETER OPTION # This option determines whether or not the embedded Perl interpreter # will be enabled during runtime. This option has no effect if Nagios # has not been compiled with support for embedded Perl. # Values: 0 = disable interpreter, 1 = enable interpreter enable_embedded_perl=1 # EMBEDDED PERL USAGE OPTION # This option determines whether or not Nagios will process Perl plugins # and scripts with the embedded Perl interpreter if the plugins/scripts # do not explicitly indicate whether or not it is okay to do so. Read # the HTML documentation on the embedded Perl interpreter for more # information on how this option works. use_embedded_perl_implicitly=1 # ILLEGAL OBJECT NAME CHARACTERS # This option allows you to specify illegal characters that cannot # be used in host names, service descriptions, or names of other # object types. illegal_object_name_chars=`~!$%^&*|'"<>?,()= # ILLEGAL MACRO OUTPUT CHARACTERS # This option allows you to specify illegal characters that are # stripped from macros before being used in notifications, event # handlers, etc. This DOES NOT affect macros used in service or # host check commands. # The following macros are stripped of the characters you specify: # $HOSTOUTPUT$ # $HOSTPERFDATA$ # $HOSTACKAUTHOR$ # $HOSTACKCOMMENT$ # $SERVICEOUTPUT$ # $SERVICEPERFDATA$ # $SERVICEACKAUTHOR$ # $SERVICEACKCOMMENT$ illegal_macro_output_chars=`~$&|'"<> # REGULAR EXPRESSION MATCHING # This option controls whether or not regular expression matching # takes place in the object config files. Regular expression # matching is used to match host, hostgroup, service, and service # group names/descriptions in some fields of various object types. # Values: 1 = enable regexp matching, 0 = disable regexp matching use_regexp_matching=0 # "TRUE" REGULAR EXPRESSION MATCHING # This option controls whether or not "true" regular expression # matching takes place in the object config files. This option # only has an effect if regular expression matching is enabled # (see above). If this option is DISABLED, regular expression # matching only occurs if a string contains wildcard characters # (* and ?). If the option is ENABLED, regexp matching occurs # all the time (which can be annoying). # Values: 1 = enable true matching, 0 = disable true matching use_true_regexp_matching=0 # ADMINISTRATOR EMAIL/PAGER ADDRESSES # The email and pager address of a global administrator (likely you). # Nagios never uses these values itself, but you can access them by # using the $ADMINEMAIL$ and $ADMINPAGER$ macros in your notification # commands. admin_email=nagios@localhost admin_pager=pagenagios@localhost # DAEMON CORE DUMP OPTION # This option determines whether or not Nagios is allowed to create # a core dump when it runs as a daemon. Note that it is generally # considered bad form to allow this, but it may be useful for # debugging purposes. Enabling this option doesn't guarantee that # a core file will be produced, but that's just life... # Values: 1 - Allow core dumps # 0 - Do not allow core dumps (default) daemon_dumps_core=0 # LARGE INSTALLATION TWEAKS OPTION # This option determines whether or not Nagios will take some shortcuts # which can save on memory and CPU usage in large Nagios installations. # Read the documentation for more information on the benefits/tradeoffs # of enabling this option. # Values: 1 - Enabled tweaks # 0 - Disable tweaks (default) use_large_installation_tweaks=0 # ENABLE ENVIRONMENT MACROS # This option determines whether or not Nagios will make all standard # macros available as environment variables when host/service checks # and system commands (event handlers, notifications, etc.) are # executed. Enabling this option can cause performance issues in # large installations, as it will consume a bit more memory and (more # importantly) consume more CPU. # Values: 1 - Enable environment variable macros (default) # 0 - Disable environment variable macros enable_environment_macros=1 # CHILD PROCESS MEMORY OPTION # This option determines whether or not Nagios will free memory in # child processes (processed used to execute system commands and host/ # service checks). If you specify a value here, it will override # program defaults. # Value: 1 - Free memory in child processes # 0 - Do not free memory in child processes #free_child_process_memory=1 # CHILD PROCESS FORKING BEHAVIOR # This option determines how Nagios will fork child processes # (used to execute system commands and host/service checks). Normally # child processes are fork()ed twice, which provides a very high level # of isolation from problems. Fork()ing once is probably enough and will # save a great deal on CPU usage (in large installs), so you might # want to consider using this. If you specify a value here, it will # program defaults. # Value: 1 - Child processes fork() twice # 0 - Child processes fork() just once #child_processes_fork_twice=1 # DEBUG LEVEL # This option determines how much (if any) debugging information will # be written to the debug file. OR values together to log multiple # types of information. # Values: # -1 = Everything # 0 = Nothing # 1 = Functions # 2 = Configuration # 4 = Process information # 8 = Scheduled events # 16 = Host/service checks # 32 = Notifications # 64 = Event broker # 128 = External commands # 256 = Commands # 512 = Scheduled downtime # 1024 = Comments # 2048 = Macros debug_level=0 # DEBUG VERBOSITY # This option determines how verbose the debug log out will be. # Values: 0 = Brief output # 1 = More detailed # 2 = Very detailed debug_verbosity=1 # DEBUG FILE # This option determines where Nagios should write debugging information. debug_file=/usr/local/nagios/var/nagios.debug # MAX DEBUG FILE SIZE # This option determines the maximum size (in bytes) of the debug file. If # the file grows larger than this size, it will be renamed with a .old # extension. If a file already exists with a .old extension it will # automatically be deleted. This helps ensure your disk space usage doesn't # get out of control when debugging Nagios. max_debug_file_size=1000000 Nagios-Object-0.21.20/t/v3_config/httpd.conf000444001750001750 176212220262237 21726 0ustar00dfergusondferguson000000000000# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER # Last Modified: 11-26-2005 # # This file contains examples of entries that need # to be incorporated into your Apache web server # configuration file. Customize the paths, etc. as # needed to fit your system. ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" # SSLRequireSSL Options ExecCGI AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user Alias /nagios "/usr/local/nagios/share" # SSLRequireSSL Options None AllowOverride None Order allow,deny Allow from all # Order deny,allow # Deny from all # Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user Nagios-Object-0.21.20/t/v3_config/resource.cfg.in000444001750001750 244612220262237 22651 0ustar00dfergusondferguson000000000000########################################################################### # # RESOURCE.CFG - Sample Resource File for Nagios @VERSION@ # # Last Modified: 09-10-2003 # # You can define $USERx$ macros in this file, which can in turn be used # in command definitions in your host config file(s). $USERx$ macros are # useful for storing sensitive information such as usernames, passwords, # etc. They are also handy for specifying the path to plugins and # event handlers - if you decide to move the plugins or event handlers to # a different directory in the future, you can just update one or two # $USERx$ macros, instead of modifying a lot of command definitions. # # The CGIs will not attempt to read the contents of resource files, so # you can set restrictive permissions (600 or 660) on them. # # Nagios supports up to 32 $USERx$ macros ($USER1$ through $USER32$) # # Resource files may also be used to store configuration directives for # external data sources like MySQL... # ########################################################################### # Sets $USER1$ to be the path to the plugins $USER1$=@libexecdir@ # Sets $USER2$ to be the path to event handlers #$USER2$=@libexecdir@/eventhandlers # Store some usernames and passwords (hidden from the CGIs) #$USER3$=someuser #$USER4$=somepassword Nagios-Object-0.21.20/t/v3_config/nagios.cfg.in000444001750001750 12507412220262237 22345 0ustar00dfergusondferguson000000000000############################################################################## # # NAGIOS.CFG - Sample Main Config File for Nagios @VERSION@ # # Read the documentation for more information on this configuration # file. I've provided some comments here, but things may not be so # clear without further explanation. # # Last Modified: 12-14-2008 # ############################################################################## # LOG FILE # This is the main log file where service and host events are logged # for historical purposes. This should be the first option specified # in the config file!!! log_file=@localstatedir@/nagios.log # OBJECT CONFIGURATION FILE(S) # These are the object configuration files in which you define hosts, # host groups, contacts, contact groups, services, etc. # You can split your object definitions across several config files # if you wish (as shown below), or keep them all in a single config file. # You can specify individual object config files as shown below: cfg_file=@sysconfdir@/objects/commands.cfg cfg_file=@sysconfdir@/objects/contacts.cfg cfg_file=@sysconfdir@/objects/timeperiods.cfg cfg_file=@sysconfdir@/objects/templates.cfg # Definitions for monitoring the local (Linux) host cfg_file=@sysconfdir@/objects/localhost.cfg # Definitions for monitoring a Windows machine #cfg_file=@sysconfdir@/objects/windows.cfg # Definitions for monitoring a router/switch #cfg_file=@sysconfdir@/objects/switch.cfg # Definitions for monitoring a network printer #cfg_file=@sysconfdir@/objects/printer.cfg # You can also tell Nagios to process all config files (with a .cfg # extension) in a particular directory by using the cfg_dir # directive as shown below: #cfg_dir=@sysconfdir@/servers #cfg_dir=@sysconfdir@/printers #cfg_dir=@sysconfdir@/switches #cfg_dir=@sysconfdir@/routers # OBJECT CACHE FILE # This option determines where object definitions are cached when # Nagios starts/restarts. The CGIs read object definitions from # this cache file (rather than looking at the object config files # directly) in order to prevent inconsistencies that can occur # when the config files are modified after Nagios starts. object_cache_file=@localstatedir@/objects.cache # PRE-CACHED OBJECT FILE # This options determines the location of the precached object file. # If you run Nagios with the -p command line option, it will preprocess # your object configuration file(s) and write the cached config to this # file. You can then start Nagios with the -u option to have it read # object definitions from this precached file, rather than the standard # object configuration files (see the cfg_file and cfg_dir options above). # Using a precached object file can speed up the time needed to (re)start # the Nagios process if you've got a large and/or complex configuration. # Read the documentation section on optimizing Nagios to find our more # about how this feature works. precached_object_file=@localstatedir@/objects.precache # RESOURCE FILE # This is an optional resource file that contains $USERx$ macro # definitions. Multiple resource files can be specified by using # multiple resource_file definitions. The CGIs will not attempt to # read the contents of resource files, so information that is # considered to be sensitive (usernames, passwords, etc) can be # defined as macros in this file and restrictive permissions (600) # can be placed on this file. resource_file=@sysconfdir@/resource.cfg # STATUS FILE # This is where the current status of all monitored services and # hosts is stored. Its contents are read and processed by the CGIs. # The contents of the status file are deleted every time Nagios # restarts. status_file=@localstatedir@/status.dat # STATUS FILE UPDATE INTERVAL # This option determines the frequency (in seconds) that # Nagios will periodically dump program, host, and # service status data. status_update_interval=10 # NAGIOS USER # This determines the effective user that Nagios should run as. # You can either supply a username or a UID. nagios_user=@nagios_user@ # NAGIOS GROUP # This determines the effective group that Nagios should run as. # You can either supply a group name or a GID. nagios_group=@nagios_grp@ # EXTERNAL COMMAND OPTION # This option allows you to specify whether or not Nagios should check # for external commands (in the command file defined below). By default # Nagios will *not* check for external commands, just to be on the # cautious side. If you want to be able to use the CGI command interface # you will have to enable this. # Values: 0 = disable commands, 1 = enable commands check_external_commands=1 # EXTERNAL COMMAND CHECK INTERVAL # This is the interval at which Nagios should check for external commands. # This value works of the interval_length you specify later. If you leave # that at its default value of 60 (seconds), a value of 1 here will cause # Nagios to check for external commands every minute. If you specify a # number followed by an "s" (i.e. 15s), this will be interpreted to mean # actual seconds rather than a multiple of the interval_length variable. # Note: In addition to reading the external command file at regularly # scheduled intervals, Nagios will also check for external commands after # event handlers are executed. # NOTE: Setting this value to -1 causes Nagios to check the external # command file as often as possible. #command_check_interval=15s command_check_interval=-1 # EXTERNAL COMMAND FILE # This is the file that Nagios checks for external command requests. # It is also where the command CGI will write commands that are submitted # by users, so it must be writeable by the user that the web server # is running as (usually 'nobody'). Permissions should be set at the # directory level instead of on the file, as the file is deleted every # time its contents are processed. command_file=@localstatedir@/rw/nagios.cmd # EXTERNAL COMMAND BUFFER SLOTS # This settings is used to tweak the number of items or "slots" that # the Nagios daemon should allocate to the buffer that holds incoming # external commands before they are processed. As external commands # are processed by the daemon, they are removed from the buffer. external_command_buffer_slots=4096 # LOCK FILE # This is the lockfile that Nagios will use to store its PID number # in when it is running in daemon mode. lock_file=@lockfile@ # TEMP FILE # This is a temporary file that is used as scratch space when Nagios # updates the status log, cleans the comment file, etc. This file # is created, used, and deleted throughout the time that Nagios is # running. temp_file=@localstatedir@/nagios.tmp # TEMP PATH # This is path where Nagios can create temp files for service and # host check results, etc. temp_path=@TMPDIR@ # EVENT BROKER OPTIONS # Controls what (if any) data gets sent to the event broker. # Values: 0 = Broker nothing # -1 = Broker everything # = See documentation event_broker_options=-1 # EVENT BROKER MODULE(S) # This directive is used to specify an event broker module that should # by loaded by Nagios at startup. Use multiple directives if you want # to load more than one module. Arguments that should be passed to # the module at startup are seperated from the module path by a space. # #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # # Do NOT overwrite modules while they are being used by Nagios or Nagios # will crash in a fiery display of SEGFAULT glory. This is a bug/limitation # either in dlopen(), the kernel, and/or the filesystem. And maybe Nagios... # # The correct/safe way of updating a module is by using one of these methods: # 1. Shutdown Nagios, replace the module file, restart Nagios # 2. Delete the original module file, move the new module file into place, restart Nagios # # Example: # # broker_module= [moduleargs] #broker_module=/somewhere/module1.o #broker_module=/somewhere/module2.o arg1 arg2=3 debug=0 # LOG ROTATION METHOD # This is the log rotation method that Nagios should use to rotate # the main log file. Values are as follows.. # n = None - don't rotate the log # h = Hourly rotation (top of the hour) # d = Daily rotation (midnight every day) # w = Weekly rotation (midnight on Saturday evening) # m = Monthly rotation (midnight last day of month) log_rotation_method=d # LOG ARCHIVE PATH # This is the directory where archived (rotated) log files should be # placed (assuming you've chosen to do log rotation). log_archive_path=@localstatedir@/archives # LOGGING OPTIONS # If you want messages logged to the syslog facility, as well as the # Nagios log file set this option to 1. If not, set it to 0. use_syslog=1 # NOTIFICATION LOGGING OPTION # If you don't want notifications to be logged, set this value to 0. # If notifications should be logged, set the value to 1. log_notifications=1 # SERVICE RETRY LOGGING OPTION # If you don't want service check retries to be logged, set this value # to 0. If retries should be logged, set the value to 1. log_service_retries=1 # HOST RETRY LOGGING OPTION # If you don't want host check retries to be logged, set this value to # 0. If retries should be logged, set the value to 1. log_host_retries=1 # EVENT HANDLER LOGGING OPTION # If you don't want host and service event handlers to be logged, set # this value to 0. If event handlers should be logged, set the value # to 1. log_event_handlers=1 # INITIAL STATES LOGGING OPTION # If you want Nagios to log all initial host and service states to # the main log file (the first time the service or host is checked) # you can enable this option by setting this value to 1. If you # are not using an external application that does long term state # statistics reporting, you do not need to enable this option. In # this case, set the value to 0. log_initial_states=0 # EXTERNAL COMMANDS LOGGING OPTION # If you don't want Nagios to log external commands, set this value # to 0. If external commands should be logged, set this value to 1. # Note: This option does not include logging of passive service # checks - see the option below for controlling whether or not # passive checks are logged. log_external_commands=1 # PASSIVE CHECKS LOGGING OPTION # If you don't want Nagios to log passive host and service checks, set # this value to 0. If passive checks should be logged, set # this value to 1. log_passive_checks=1 # GLOBAL HOST AND SERVICE EVENT HANDLERS # These options allow you to specify a host and service event handler # command that is to be run for every host or service state change. # The global event handler is executed immediately prior to the event # handler that you have optionally specified in each host or # service definition. The command argument is the short name of a # command definition that you define in your host configuration file. # Read the HTML docs for more information. #global_host_event_handler=somecommand #global_service_event_handler=somecommand # SERVICE INTER-CHECK DELAY METHOD # This is the method that Nagios should use when initially # "spreading out" service checks when it starts monitoring. The # default is to use smart delay calculation, which will try to # space all service checks out evenly to minimize CPU load. # Using the dumb setting will cause all checks to be scheduled # at the same time (with no delay between them)! This is not a # good thing for production, but is useful when testing the # parallelization functionality. # n = None - don't use any delay between checks # d = Use a "dumb" delay of 1 second between checks # s = Use "smart" inter-check delay calculation # x.xx = Use an inter-check delay of x.xx seconds service_inter_check_delay_method=s # MAXIMUM SERVICE CHECK SPREAD # This variable determines the timeframe (in minutes) from the # program start time that an initial check of all services should # be completed. Default is 30 minutes. max_service_check_spread=30 # SERVICE CHECK INTERLEAVE FACTOR # This variable determines how service checks are interleaved. # Interleaving the service checks allows for a more even # distribution of service checks and reduced load on remote # hosts. Setting this value to 1 is equivalent to how versions # of Nagios previous to 0.0.5 did service checks. Set this # value to s (smart) for automatic calculation of the interleave # factor unless you have a specific reason to change it. # s = Use "smart" interleave factor calculation # x = Use an interleave factor of x, where x is a # number greater than or equal to 1. service_interleave_factor=s # HOST INTER-CHECK DELAY METHOD # This is the method that Nagios should use when initially # "spreading out" host checks when it starts monitoring. The # default is to use smart delay calculation, which will try to # space all host checks out evenly to minimize CPU load. # Using the dumb setting will cause all checks to be scheduled # at the same time (with no delay between them)! # n = None - don't use any delay between checks # d = Use a "dumb" delay of 1 second between checks # s = Use "smart" inter-check delay calculation # x.xx = Use an inter-check delay of x.xx seconds host_inter_check_delay_method=s # MAXIMUM HOST CHECK SPREAD # This variable determines the timeframe (in minutes) from the # program start time that an initial check of all hosts should # be completed. Default is 30 minutes. max_host_check_spread=30 # MAXIMUM CONCURRENT SERVICE CHECKS # This option allows you to specify the maximum number of # service checks that can be run in parallel at any given time. # Specifying a value of 1 for this variable essentially prevents # any service checks from being parallelized. A value of 0 # will not restrict the number of concurrent checks that are # being executed. max_concurrent_checks=0 # HOST AND SERVICE CHECK REAPER FREQUENCY # This is the frequency (in seconds!) that Nagios will process # the results of host and service checks. check_result_reaper_frequency=10 # MAX CHECK RESULT REAPER TIME # This is the max amount of time (in seconds) that a single # check result reaper event will be allowed to run before # returning control back to Nagios so it can perform other # duties. max_check_result_reaper_time=30 # CHECK RESULT PATH # This is directory where Nagios stores the results of host and # service checks that have not yet been processed. # # Note: Make sure that only one instance of Nagios has access # to this directory! check_result_path=@CHECKRESULTDIR@ # MAX CHECK RESULT FILE AGE # This option determines the maximum age (in seconds) which check # result files are considered to be valid. Files older than this # threshold will be mercilessly deleted without further processing. max_check_result_file_age=3600 # CACHED HOST CHECK HORIZON # This option determines the maximum amount of time (in seconds) # that the state of a previous host check is considered current. # Cached host states (from host checks that were performed more # recently that the timeframe specified by this value) can immensely # improve performance in regards to the host check logic. # Too high of a value for this option may result in inaccurate host # states being used by Nagios, while a lower value may result in a # performance hit for host checks. Use a value of 0 to disable host # check caching. cached_host_check_horizon=15 # CACHED SERVICE CHECK HORIZON # This option determines the maximum amount of time (in seconds) # that the state of a previous service check is considered current. # Cached service states (from service checks that were performed more # recently that the timeframe specified by this value) can immensely # improve performance in regards to predictive dependency checks. # Use a value of 0 to disable service check caching. cached_service_check_horizon=15 # ENABLE PREDICTIVE HOST DEPENDENCY CHECKS # This option determines whether or not Nagios will attempt to execute # checks of hosts when it predicts that future dependency logic test # may be needed. These predictive checks can help ensure that your # host dependency logic works well. # Values: # 0 = Disable predictive checks # 1 = Enable predictive checks (default) enable_predictive_host_dependency_checks=1 # ENABLE PREDICTIVE SERVICE DEPENDENCY CHECKS # This option determines whether or not Nagios will attempt to execute # checks of service when it predicts that future dependency logic test # may be needed. These predictive checks can help ensure that your # service dependency logic works well. # Values: # 0 = Disable predictive checks # 1 = Enable predictive checks (default) enable_predictive_service_dependency_checks=1 # SOFT STATE DEPENDENCIES # This option determines whether or not Nagios will use soft state # information when checking host and service dependencies. Normally # Nagios will only use the latest hard host or service state when # checking dependencies. If you want it to use the latest state (regardless # of whether its a soft or hard state type), enable this option. # Values: # 0 = Don't use soft state dependencies (default) # 1 = Use soft state dependencies soft_state_dependencies=0 # TIME CHANGE ADJUSTMENT THRESHOLDS # These options determine when Nagios will react to detected changes # in system time (either forward or backwards). #time_change_threshold=900 # AUTO-RESCHEDULING OPTION # This option determines whether or not Nagios will attempt to # automatically reschedule active host and service checks to # "smooth" them out over time. This can help balance the load on # the monitoring server. # WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE # PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY auto_reschedule_checks=0 # AUTO-RESCHEDULING INTERVAL # This option determines how often (in seconds) Nagios will # attempt to automatically reschedule checks. This option only # has an effect if the auto_reschedule_checks option is enabled. # Default is 30 seconds. # WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE # PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY auto_rescheduling_interval=30 # AUTO-RESCHEDULING WINDOW # This option determines the "window" of time (in seconds) that # Nagios will look at when automatically rescheduling checks. # Only host and service checks that occur in the next X seconds # (determined by this variable) will be rescheduled. This option # only has an effect if the auto_reschedule_checks option is # enabled. Default is 180 seconds (3 minutes). # WARNING: THIS IS AN EXPERIMENTAL FEATURE - IT CAN DEGRADE # PERFORMANCE, RATHER THAN INCREASE IT, IF USED IMPROPERLY auto_rescheduling_window=180 # SLEEP TIME # This is the number of seconds to sleep between checking for system # events and service checks that need to be run. sleep_time=0.25 # TIMEOUT VALUES # These options control how much time Nagios will allow various # types of commands to execute before killing them off. Options # are available for controlling maximum time allotted for # service checks, host checks, event handlers, notifications, the # ocsp command, and performance data commands. All values are in # seconds. service_check_timeout=60 host_check_timeout=30 event_handler_timeout=30 notification_timeout=30 ocsp_timeout=5 perfdata_timeout=5 # RETAIN STATE INFORMATION # This setting determines whether or not Nagios will save state # information for services and hosts before it shuts down. Upon # startup Nagios will reload all saved service and host state # information before starting to monitor. This is useful for # maintaining long-term data on state statistics, etc, but will # slow Nagios down a bit when it (re)starts. Since its only # a one-time penalty, I think its well worth the additional # startup delay. retain_state_information=1 # STATE RETENTION FILE # This is the file that Nagios should use to store host and # service state information before it shuts down. The state # information in this file is also read immediately prior to # starting to monitor the network when Nagios is restarted. # This file is used only if the preserve_state_information # variable is set to 1. state_retention_file=@localstatedir@/retention.dat # RETENTION DATA UPDATE INTERVAL # This setting determines how often (in minutes) that Nagios # will automatically save retention data during normal operation. # If you set this value to 0, Nagios will not save retention # data at regular interval, but it will still save retention # data before shutting down or restarting. If you have disabled # state retention, this option has no effect. retention_update_interval=60 # USE RETAINED PROGRAM STATE # This setting determines whether or not Nagios will set # program status variables based on the values saved in the # retention file. If you want to use retained program status # information, set this value to 1. If not, set this value # to 0. use_retained_program_state=1 # USE RETAINED SCHEDULING INFO # This setting determines whether or not Nagios will retain # the scheduling info (next check time) for hosts and services # based on the values saved in the retention file. If you # If you want to use retained scheduling info, set this # value to 1. If not, set this value to 0. use_retained_scheduling_info=1 # RETAINED ATTRIBUTE MASKS (ADVANCED FEATURE) # The following variables are used to specify specific host and # service attributes that should *not* be retained by Nagios during # program restarts. # # The values of the masks are bitwise ANDs of values specified # by the "MODATTR_" definitions found in include/common.h. # For example, if you do not want the current enabled/disabled state # of flap detection and event handlers for hosts to be retained, you # would use a value of 24 for the host attribute mask... # MODATTR_EVENT_HANDLER_ENABLED (8) + MODATTR_FLAP_DETECTION_ENABLED (16) = 24 # This mask determines what host attributes are not retained retained_host_attribute_mask=0 # This mask determines what service attributes are not retained retained_service_attribute_mask=0 # These two masks determine what process attributes are not retained. # There are two masks, because some process attributes have host and service # options. For example, you can disable active host checks, but leave active # service checks enabled. retained_process_host_attribute_mask=0 retained_process_service_attribute_mask=0 # These two masks determine what contact attributes are not retained. # There are two masks, because some contact attributes have host and # service options. For example, you can disable host notifications for # a contact, but leave service notifications enabled for them. retained_contact_host_attribute_mask=0 retained_contact_service_attribute_mask=0 # INTERVAL LENGTH # This is the seconds per unit interval as used in the # host/contact/service configuration files. Setting this to 60 means # that each interval is one minute long (60 seconds). Other settings # have not been tested much, so your mileage is likely to vary... interval_length=60 # CHECK FOR UPDATES # This option determines whether Nagios will automatically check to # see if new updates (releases) are available. It is recommend that you # enable this option to ensure that you stay on top of the latest critical # patches to Nagios. Nagios is critical to you - make sure you keep it in # good shape. Nagios will check once a day for new updates. Data collected # by Nagios Enterprises from the update check is processed in accordance # with our privacy policy - see http://api.nagios.org for details. check_for_updates=1 # BARE UPDATE CHECK # This option deterines what data Nagios will send to api.nagios.org when # it checks for updates. By default, Nagios will send information on the # current version of Nagios you have installed, as well as an indicator as # to whether this was a new installation or not. Nagios Enterprises uses # this data to determine the number of users running specific version of # Nagios. Enable this option if you do not want this information to be sent. bare_update_check=0 # AGGRESSIVE HOST CHECKING OPTION # If you don't want to turn on aggressive host checking features, set # this value to 0 (the default). Otherwise set this value to 1 to # enable the aggressive check option. Read the docs for more info # on what aggressive host check is or check out the source code in # base/checks.c use_aggressive_host_checking=0 # SERVICE CHECK EXECUTION OPTION # This determines whether or not Nagios will actively execute # service checks when it initially starts. If this option is # disabled, checks are not actively made, but Nagios can still # receive and process passive check results that come in. Unless # you're implementing redundant hosts or have a special need for # disabling the execution of service checks, leave this enabled! # Values: 1 = enable checks, 0 = disable checks execute_service_checks=1 # PASSIVE SERVICE CHECK ACCEPTANCE OPTION # This determines whether or not Nagios will accept passive # service checks results when it initially (re)starts. # Values: 1 = accept passive checks, 0 = reject passive checks accept_passive_service_checks=1 # HOST CHECK EXECUTION OPTION # This determines whether or not Nagios will actively execute # host checks when it initially starts. If this option is # disabled, checks are not actively made, but Nagios can still # receive and process passive check results that come in. Unless # you're implementing redundant hosts or have a special need for # disabling the execution of host checks, leave this enabled! # Values: 1 = enable checks, 0 = disable checks execute_host_checks=1 # PASSIVE HOST CHECK ACCEPTANCE OPTION # This determines whether or not Nagios will accept passive # host checks results when it initially (re)starts. # Values: 1 = accept passive checks, 0 = reject passive checks accept_passive_host_checks=1 # NOTIFICATIONS OPTION # This determines whether or not Nagios will sent out any host or # service notifications when it is initially (re)started. # Values: 1 = enable notifications, 0 = disable notifications enable_notifications=1 # EVENT HANDLER USE OPTION # This determines whether or not Nagios will run any host or # service event handlers when it is initially (re)started. Unless # you're implementing redundant hosts, leave this option enabled. # Values: 1 = enable event handlers, 0 = disable event handlers enable_event_handlers=1 # PROCESS PERFORMANCE DATA OPTION # This determines whether or not Nagios will process performance # data returned from service and host checks. If this option is # enabled, host performance data will be processed using the # host_perfdata_command (defined below) and service performance # data will be processed using the service_perfdata_command (also # defined below). Read the HTML docs for more information on # performance data. # Values: 1 = process performance data, 0 = do not process performance data process_performance_data=0 # HOST AND SERVICE PERFORMANCE DATA PROCESSING COMMANDS # These commands are run after every host and service check is # performed. These commands are executed only if the # enable_performance_data option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on performance data. #host_perfdata_command=process-host-perfdata #service_perfdata_command=process-service-perfdata # HOST AND SERVICE PERFORMANCE DATA FILES # These files are used to store host and service performance data. # Performance data is only written to these files if the # enable_performance_data option (above) is set to 1. #host_perfdata_file=/tmp/host-perfdata #service_perfdata_file=/tmp/service-perfdata # HOST AND SERVICE PERFORMANCE DATA FILE TEMPLATES # These options determine what data is written (and how) to the # performance data files. The templates may contain macros, special # characters (\t for tab, \r for carriage return, \n for newline) # and plain text. A newline is automatically added after each write # to the performance data file. Some examples of what you can do are # shown below. #host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$ #service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$ # HOST AND SERVICE PERFORMANCE DATA FILE MODES # This option determines whether or not the host and service # performance data files are opened in write ("w") or append ("a") # mode. If you want to use named pipes, you should use the special # pipe ("p") mode which avoid blocking at startup, otherwise you will # likely want the defult append ("a") mode. #host_perfdata_file_mode=a #service_perfdata_file_mode=a # HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING INTERVAL # These options determine how often (in seconds) the host and service # performance data files are processed using the commands defined # below. A value of 0 indicates the files should not be periodically # processed. #host_perfdata_file_processing_interval=0 #service_perfdata_file_processing_interval=0 # HOST AND SERVICE PERFORMANCE DATA FILE PROCESSING COMMANDS # These commands are used to periodically process the host and # service performance data files. The interval at which the # processing occurs is determined by the options above. #host_perfdata_file_processing_command=process-host-perfdata-file #service_perfdata_file_processing_command=process-service-perfdata-file # OBSESS OVER SERVICE CHECKS OPTION # This determines whether or not Nagios will obsess over service # checks and run the ocsp_command defined below. Unless you're # planning on implementing distributed monitoring, do not enable # this option. Read the HTML docs for more information on # implementing distributed monitoring. # Values: 1 = obsess over services, 0 = do not obsess (default) obsess_over_services=0 # OBSESSIVE COMPULSIVE SERVICE PROCESSOR COMMAND # This is the command that is run for every service check that is # processed by Nagios. This command is executed only if the # obsess_over_services option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on implementing distributed monitoring. #ocsp_command=somecommand # OBSESS OVER HOST CHECKS OPTION # This determines whether or not Nagios will obsess over host # checks and run the ochp_command defined below. Unless you're # planning on implementing distributed monitoring, do not enable # this option. Read the HTML docs for more information on # implementing distributed monitoring. # Values: 1 = obsess over hosts, 0 = do not obsess (default) obsess_over_hosts=0 # OBSESSIVE COMPULSIVE HOST PROCESSOR COMMAND # This is the command that is run for every host check that is # processed by Nagios. This command is executed only if the # obsess_over_hosts option (above) is set to 1. The command # argument is the short name of a command definition that you # define in your host configuration file. Read the HTML docs for # more information on implementing distributed monitoring. #ochp_command=somecommand # TRANSLATE PASSIVE HOST CHECKS OPTION # This determines whether or not Nagios will translate # DOWN/UNREACHABLE passive host check results into their proper # state for this instance of Nagios. This option is useful # if you have distributed or failover monitoring setup. In # these cases your other Nagios servers probably have a different # "view" of the network, with regards to the parent/child relationship # of hosts. If a distributed monitoring server thinks a host # is DOWN, it may actually be UNREACHABLE from the point of # this Nagios instance. Enabling this option will tell Nagios # to translate any DOWN or UNREACHABLE host states it receives # passively into the correct state from the view of this server. # Values: 1 = perform translation, 0 = do not translate (default) translate_passive_host_checks=0 # PASSIVE HOST CHECKS ARE SOFT OPTION # This determines whether or not Nagios will treat passive host # checks as being HARD or SOFT. By default, a passive host check # result will put a host into a HARD state type. This can be changed # by enabling this option. # Values: 0 = passive checks are HARD, 1 = passive checks are SOFT passive_host_checks_are_soft=0 # ORPHANED HOST/SERVICE CHECK OPTIONS # These options determine whether or not Nagios will periodically # check for orphaned host service checks. Since service checks are # not rescheduled until the results of their previous execution # instance are processed, there exists a possibility that some # checks may never get rescheduled. A similar situation exists for # host checks, although the exact scheduling details differ a bit # from service checks. Orphaned checks seem to be a rare # problem and should not happen under normal circumstances. # If you have problems with service checks never getting # rescheduled, make sure you have orphaned service checks enabled. # Values: 1 = enable checks, 0 = disable checks check_for_orphaned_services=1 check_for_orphaned_hosts=1 # SERVICE FRESHNESS CHECK OPTION # This option determines whether or not Nagios will periodically # check the "freshness" of service results. Enabling this option # is useful for ensuring passive checks are received in a timely # manner. # Values: 1 = enabled freshness checking, 0 = disable freshness checking check_service_freshness=1 # SERVICE FRESHNESS CHECK INTERVAL # This setting determines how often (in seconds) Nagios will # check the "freshness" of service check results. If you have # disabled service freshness checking, this option has no effect. service_freshness_check_interval=60 # HOST FRESHNESS CHECK OPTION # This option determines whether or not Nagios will periodically # check the "freshness" of host results. Enabling this option # is useful for ensuring passive checks are received in a timely # manner. # Values: 1 = enabled freshness checking, 0 = disable freshness checking check_host_freshness=0 # HOST FRESHNESS CHECK INTERVAL # This setting determines how often (in seconds) Nagios will # check the "freshness" of host check results. If you have # disabled host freshness checking, this option has no effect. host_freshness_check_interval=60 # ADDITIONAL FRESHNESS THRESHOLD LATENCY # This setting determines the number of seconds that Nagios # will add to any host and service freshness thresholds that # it calculates (those not explicitly specified by the user). additional_freshness_latency=15 # FLAP DETECTION OPTION # This option determines whether or not Nagios will try # and detect hosts and services that are "flapping". # Flapping occurs when a host or service changes between # states too frequently. When Nagios detects that a # host or service is flapping, it will temporarily suppress # notifications for that host/service until it stops # flapping. Flap detection is very experimental, so read # the HTML documentation before enabling this feature! # Values: 1 = enable flap detection # 0 = disable flap detection (default) enable_flap_detection=1 # FLAP DETECTION THRESHOLDS FOR HOSTS AND SERVICES # Read the HTML documentation on flap detection for # an explanation of what this option does. This option # has no effect if flap detection is disabled. low_service_flap_threshold=5.0 high_service_flap_threshold=20.0 low_host_flap_threshold=5.0 high_host_flap_threshold=20.0 # DATE FORMAT OPTION # This option determines how short dates are displayed. Valid options # include: # us (MM-DD-YYYY HH:MM:SS) # euro (DD-MM-YYYY HH:MM:SS) # iso8601 (YYYY-MM-DD HH:MM:SS) # strict-iso8601 (YYYY-MM-DDTHH:MM:SS) # date_format=us # TIMEZONE OFFSET # This option is used to override the default timezone that this # instance of Nagios runs in. If not specified, Nagios will use # the system configured timezone. # # NOTE: In order to display the correct timezone in the CGIs, you # will also need to alter the Apache directives for the CGI path # to include your timezone. Example: # # # SetEnv TZ "Australia/Brisbane" # ... # #use_timezone=US/Mountain #use_timezone=Australia/Brisbane # P1.PL FILE LOCATION # This value determines where the p1.pl perl script (used by the # embedded Perl interpreter) is located. If you didn't compile # Nagios with embedded Perl support, this option has no effect. p1_file=@bindir@/p1.pl # EMBEDDED PERL INTERPRETER OPTION # This option determines whether or not the embedded Perl interpreter # will be enabled during runtime. This option has no effect if Nagios # has not been compiled with support for embedded Perl. # Values: 0 = disable interpreter, 1 = enable interpreter enable_embedded_perl=1 # EMBEDDED PERL USAGE OPTION # This option determines whether or not Nagios will process Perl plugins # and scripts with the embedded Perl interpreter if the plugins/scripts # do not explicitly indicate whether or not it is okay to do so. Read # the HTML documentation on the embedded Perl interpreter for more # information on how this option works. use_embedded_perl_implicitly=1 # ILLEGAL OBJECT NAME CHARACTERS # This option allows you to specify illegal characters that cannot # be used in host names, service descriptions, or names of other # object types. illegal_object_name_chars=`~!$%^&*|'"<>?,()= # ILLEGAL MACRO OUTPUT CHARACTERS # This option allows you to specify illegal characters that are # stripped from macros before being used in notifications, event # handlers, etc. This DOES NOT affect macros used in service or # host check commands. # The following macros are stripped of the characters you specify: # $HOSTOUTPUT$ # $HOSTPERFDATA$ # $HOSTACKAUTHOR$ # $HOSTACKCOMMENT$ # $SERVICEOUTPUT$ # $SERVICEPERFDATA$ # $SERVICEACKAUTHOR$ # $SERVICEACKCOMMENT$ illegal_macro_output_chars=`~$&|'"<> # REGULAR EXPRESSION MATCHING # This option controls whether or not regular expression matching # takes place in the object config files. Regular expression # matching is used to match host, hostgroup, service, and service # group names/descriptions in some fields of various object types. # Values: 1 = enable regexp matching, 0 = disable regexp matching use_regexp_matching=0 # "TRUE" REGULAR EXPRESSION MATCHING # This option controls whether or not "true" regular expression # matching takes place in the object config files. This option # only has an effect if regular expression matching is enabled # (see above). If this option is DISABLED, regular expression # matching only occurs if a string contains wildcard characters # (* and ?). If the option is ENABLED, regexp matching occurs # all the time (which can be annoying). # Values: 1 = enable true matching, 0 = disable true matching use_true_regexp_matching=0 # ADMINISTRATOR EMAIL/PAGER ADDRESSES # The email and pager address of a global administrator (likely you). # Nagios never uses these values itself, but you can access them by # using the $ADMINEMAIL$ and $ADMINPAGER$ macros in your notification # commands. admin_email=@nagios_user@@localhost admin_pager=page@nagios_user@@localhost # DAEMON CORE DUMP OPTION # This option determines whether or not Nagios is allowed to create # a core dump when it runs as a daemon. Note that it is generally # considered bad form to allow this, but it may be useful for # debugging purposes. Enabling this option doesn't guarantee that # a core file will be produced, but that's just life... # Values: 1 - Allow core dumps # 0 - Do not allow core dumps (default) daemon_dumps_core=0 # LARGE INSTALLATION TWEAKS OPTION # This option determines whether or not Nagios will take some shortcuts # which can save on memory and CPU usage in large Nagios installations. # Read the documentation for more information on the benefits/tradeoffs # of enabling this option. # Values: 1 - Enabled tweaks # 0 - Disable tweaks (default) use_large_installation_tweaks=0 # ENABLE ENVIRONMENT MACROS # This option determines whether or not Nagios will make all standard # macros available as environment variables when host/service checks # and system commands (event handlers, notifications, etc.) are # executed. Enabling this option can cause performance issues in # large installations, as it will consume a bit more memory and (more # importantly) consume more CPU. # Values: 1 - Enable environment variable macros (default) # 0 - Disable environment variable macros enable_environment_macros=1 # CHILD PROCESS MEMORY OPTION # This option determines whether or not Nagios will free memory in # child processes (processed used to execute system commands and host/ # service checks). If you specify a value here, it will override # program defaults. # Value: 1 - Free memory in child processes # 0 - Do not free memory in child processes #free_child_process_memory=1 # CHILD PROCESS FORKING BEHAVIOR # This option determines how Nagios will fork child processes # (used to execute system commands and host/service checks). Normally # child processes are fork()ed twice, which provides a very high level # of isolation from problems. Fork()ing once is probably enough and will # save a great deal on CPU usage (in large installs), so you might # want to consider using this. If you specify a value here, it will # program defaults. # Value: 1 - Child processes fork() twice # 0 - Child processes fork() just once #child_processes_fork_twice=1 # DEBUG LEVEL # This option determines how much (if any) debugging information will # be written to the debug file. OR values together to log multiple # types of information. # Values: # -1 = Everything # 0 = Nothing # 1 = Functions # 2 = Configuration # 4 = Process information # 8 = Scheduled events # 16 = Host/service checks # 32 = Notifications # 64 = Event broker # 128 = External commands # 256 = Commands # 512 = Scheduled downtime # 1024 = Comments # 2048 = Macros debug_level=0 # DEBUG VERBOSITY # This option determines how verbose the debug log out will be. # Values: 0 = Brief output # 1 = More detailed # 2 = Very detailed debug_verbosity=1 # DEBUG FILE # This option determines where Nagios should write debugging information. debug_file=@localstatedir@/nagios.debug # MAX DEBUG FILE SIZE # This option determines the maximum size (in bytes) of the debug file. If # the file grows larger than this size, it will be renamed with a .old # extension. If a file already exists with a .old extension it will # automatically be deleted. This helps ensure your disk space usage doesn't # get out of control when debugging Nagios. max_debug_file_size=1000000 Nagios-Object-0.21.20/t/v3_config/template-object000755001750001750 012220262237 22650 5ustar00dfergusondferguson000000000000Nagios-Object-0.21.20/t/v3_config/template-object/printer.cfg000444001750001750 606412220262237 25157 0ustar00dfergusondferguson000000000000############################################################################### # PRINTER.CFG - SAMPLE CONFIG FILE FOR MONITORING A NETWORK PRINTER # # Last Modified: 10-03-2007 # # NOTES: This config file assumes that you are using the sample configuration # files that get installed with the Nagios quickstart guide. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITIONS # ############################################################################### ############################################################################### # Define a host for the printer we'll be monitoring # Change the host_name, alias, and address to fit your situation define host{ use generic-printer ; Inherit default values from a template host_name hplj2605dn ; The name we're giving to this printer alias HP LaserJet 2605dn ; A longer name associated with the printer address 192.168.1.30 ; IP address of the printer hostgroups network-printers ; Host groups this printer is associated with } ############################################################################### ############################################################################### # # HOST GROUP DEFINITIONS # ############################################################################### ############################################################################### # A hostgroup for network printers define hostgroup{ hostgroup_name network-printers ; The name of the hostgroup alias Network Printers ; Long name of the group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Create a service for monitoring the status of the printer # Change the host_name to match the name of the host you defined above # If the printer has an SNMP community string other than "public", change the check_command directive to reflect that define service{ use generic-service ; Inherit values from a template host_name hplj2605dn ; The name of the host the service is associated with service_description Printer Status ; The service description check_command check_hpjd!-C public ; The command used to monitor the service normal_check_interval 10 ; Check the service every 10 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined } # Create a service for "pinging" the printer occassionally. Useful for monitoring RTA, packet loss, etc. define service{ use generic-service host_name hplj2605dn service_description PING check_command check_ping!3000.0,80%!5000.0,100% normal_check_interval 10 retry_check_interval 1 } Nagios-Object-0.21.20/t/v3_config/template-object/localhost.cfg.in000444001750001750 1243312220262237 26106 0ustar00dfergusondferguson000000000000############################################################################### # LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE # # Last Modified: 05-31-2007 # # NOTE: This config file is intended to serve as an *extremely* simple # example of how you can create configuration entries to monitor # the local (Linux) machine. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITION # ############################################################################### ############################################################################### # Define a host for the local machine define host{ use linux-server ; Name of host template to use ; This host definition will inherit all variables that are defined ; in (or inherited by) the linux-server host template definition. host_name localhost alias localhost address 127.0.0.1 } ############################################################################### ############################################################################### # # HOST GROUP DEFINITION # ############################################################################### ############################################################################### # Define an optional hostgroup for Linux machines define hostgroup{ hostgroup_name linux-servers ; The name of the hostgroup alias Linux Servers ; Long name of the group members localhost ; Comma separated list of hosts that belong to this group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Define a service to "ping" the local machine define service{ use local-service ; Name of service template to use host_name localhost service_description PING check_command check_ping!100.0,20%!500.0,60% } # Define a service to check the disk space of the root partition # on the local machine. Warning if < 20% free, critical if # < 10% free space on partition. define service{ use local-service ; Name of service template to use host_name localhost service_description Root Partition check_command check_local_disk!20%!10%!/ } # Define a service to check the number of currently logged in # users on the local machine. Warning if > 20 users, critical # if > 50 users. define service{ use local-service ; Name of service template to use host_name localhost service_description Current Users check_command check_local_users!20!50 } # Define a service to check the number of currently running procs # on the local machine. Warning if > 250 processes, critical if # > 400 users. define service{ use local-service ; Name of service template to use host_name localhost service_description Total Processes check_command check_local_procs!250!400!RSZDT } # Define a service to check the load on the local machine. define service{ use local-service ; Name of service template to use host_name localhost service_description Current Load check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 } # Define a service to check the swap usage the local machine. # Critical if less than 10% of swap is free, warning if less than 20% is free define service{ use local-service ; Name of service template to use host_name localhost service_description Swap Usage check_command check_local_swap!20!10 } # Define a service to check SSH on the local machine. # Disable notifications for this service by default, as not all users may have SSH enabled. define service{ use local-service ; Name of service template to use host_name localhost service_description SSH check_command check_ssh notifications_enabled 0 } # Define a service to check HTTP on the local machine. # Disable notifications for this service by default, as not all users may have HTTP enabled. define service{ use local-service ; Name of service template to use host_name localhost service_description HTTP check_command check_http notifications_enabled 0 } Nagios-Object-0.21.20/t/v3_config/template-object/timeperiods.cfg.in000444001750001750 621112220262237 26417 0ustar00dfergusondferguson000000000000############################################################################### # TIMEPERIODS.CFG - SAMPLE TIMEPERIOD DEFINITIONS # # Last Modified: 05-31-2007 # # NOTES: This config file provides you with some example timeperiod definitions # that you can reference in host, service, contact, and dependency # definitions. # # You don't need to keep timeperiods in a separate file from your other # object definitions. This has been done just to make things easier to # understand. # ############################################################################### ############################################################################### ############################################################################### # # TIME PERIODS # ############################################################################### ############################################################################### # This defines a timeperiod where all times are valid for checks, # notifications, etc. The classic "24x7" support nightmare. :-) define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } # 'workhours' timeperiod definition define timeperiod{ timeperiod_name workhours alias Normal Work Hours monday 09:00-17:00 tuesday 09:00-17:00 wednesday 09:00-17:00 thursday 09:00-17:00 friday 09:00-17:00 } # 'none' timeperiod definition define timeperiod{ timeperiod_name none alias No Time Is A Good Time } # Some U.S. holidays # Note: The timeranges for each holiday are meant to *exclude* the holidays from being # treated as a valid time for notifications, etc. You probably don't want your pager # going off on New Year's. Although you're employer might... :-) define timeperiod{ name us-holidays timeperiod_name us-holidays alias U.S. Holidays january 1 00:00-00:00 ; New Years monday -1 may 00:00-00:00 ; Memorial Day (last Monday in May) july 4 00:00-00:00 ; Independence Day monday 1 september 00:00-00:00 ; Labor Day (first Monday in September) thursday -1 november 00:00-00:00 ; Thanksgiving (last Thursday in November) december 25 00:00-00:00 ; Christmas } # This defines a modified "24x7" timeperiod that covers every day of the # year, except for U.S. holidays (defined in the timeperiod above). define timeperiod{ timeperiod_name 24x7_sans_holidays alias 24x7 Sans Holidays use us-holidays ; Get holiday exceptions from other timeperiod sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } Nagios-Object-0.21.20/t/v3_config/template-object/windows.cfg000444001750001750 766312220262237 25174 0ustar00dfergusondferguson000000000000############################################################################### # WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE # # Last Modified: 06-13-2007 # # NOTES: This config file assumes that you are using the sample configuration # files that get installed with the Nagios quickstart guide. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITIONS # ############################################################################### ############################################################################### # Define a host for the Windows machine we'll be monitoring # Change the host_name, alias, and address to fit your situation define host{ use windows-server ; Inherit default values from a template host_name winserver ; The name we're giving to this host alias My Windows Server ; A longer name associated with the host address 192.168.1.2 ; IP address of the host } ############################################################################### ############################################################################### # # HOST GROUP DEFINITIONS # ############################################################################### ############################################################################### # Define a hostgroup for Windows machines # All hosts that use the windows-server template will automatically be a member of this group define hostgroup{ hostgroup_name windows-servers ; The name of the hostgroup alias Windows Servers ; Long name of the group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Create a service for monitoring the version of NSCLient++ that is installed # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description NSClient++ Version check_command check_nt!CLIENTVERSION } # Create a service for monitoring the uptime of the server # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description Uptime check_command check_nt!UPTIME } # Create a service for monitoring CPU load # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description CPU Load check_command check_nt!CPULOAD!-l 5,80,90 } # Create a service for monitoring memory usage # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description Memory Usage check_command check_nt!MEMUSE!-w 80 -c 90 } # Create a service for monitoring C:\ disk usage # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description C:\ Drive Space check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90 } # Create a service for monitoring the W3SVC service # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description W3SVC check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC } # Create a service for monitoring the Explorer.exe process # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description Explorer check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe } Nagios-Object-0.21.20/t/v3_config/template-object/printer.cfg.in000444001750001750 606412220262237 25564 0ustar00dfergusondferguson000000000000############################################################################### # PRINTER.CFG - SAMPLE CONFIG FILE FOR MONITORING A NETWORK PRINTER # # Last Modified: 10-03-2007 # # NOTES: This config file assumes that you are using the sample configuration # files that get installed with the Nagios quickstart guide. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITIONS # ############################################################################### ############################################################################### # Define a host for the printer we'll be monitoring # Change the host_name, alias, and address to fit your situation define host{ use generic-printer ; Inherit default values from a template host_name hplj2605dn ; The name we're giving to this printer alias HP LaserJet 2605dn ; A longer name associated with the printer address 192.168.1.30 ; IP address of the printer hostgroups network-printers ; Host groups this printer is associated with } ############################################################################### ############################################################################### # # HOST GROUP DEFINITIONS # ############################################################################### ############################################################################### # A hostgroup for network printers define hostgroup{ hostgroup_name network-printers ; The name of the hostgroup alias Network Printers ; Long name of the group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Create a service for monitoring the status of the printer # Change the host_name to match the name of the host you defined above # If the printer has an SNMP community string other than "public", change the check_command directive to reflect that define service{ use generic-service ; Inherit values from a template host_name hplj2605dn ; The name of the host the service is associated with service_description Printer Status ; The service description check_command check_hpjd!-C public ; The command used to monitor the service normal_check_interval 10 ; Check the service every 10 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined } # Create a service for "pinging" the printer occassionally. Useful for monitoring RTA, packet loss, etc. define service{ use generic-service host_name hplj2605dn service_description PING check_command check_ping!3000.0,80%!5000.0,100% normal_check_interval 10 retry_check_interval 1 } Nagios-Object-0.21.20/t/v3_config/template-object/.cvsignore000444001750001750 612220262237 24721 0ustar00dfergusondferguson000000000000*.cfg Nagios-Object-0.21.20/t/v3_config/template-object/contacts.cfg000444001750001750 416612220262237 25313 0ustar00dfergusondferguson000000000000############################################################################### # CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS # # Last Modified: 05-31-2007 # # NOTES: This config file provides you with some example contact and contact # group definitions that you can reference in host and service # definitions. # # You don't need to keep these definitions in a separate file from your # other object definitions. This has been done just to make things # easier to understand. # ############################################################################### ############################################################################### ############################################################################### # # CONTACTS # ############################################################################### ############################################################################### # Just one contact defined by default - the Nagios admin (that's you) # This contact definition inherits a lot of default values from the 'generic-contact' # template which is defined elsewhere. define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } ############################################################################### ############################################################################### # # CONTACT GROUPS # ############################################################################### ############################################################################### # We only have one contact in this simple configuration file, so there is # no need to create more than one contact group. define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagiosadmin } Nagios-Object-0.21.20/t/v3_config/template-object/timeperiods.cfg000444001750001750 621112220262237 26012 0ustar00dfergusondferguson000000000000############################################################################### # TIMEPERIODS.CFG - SAMPLE TIMEPERIOD DEFINITIONS # # Last Modified: 05-31-2007 # # NOTES: This config file provides you with some example timeperiod definitions # that you can reference in host, service, contact, and dependency # definitions. # # You don't need to keep timeperiods in a separate file from your other # object definitions. This has been done just to make things easier to # understand. # ############################################################################### ############################################################################### ############################################################################### # # TIME PERIODS # ############################################################################### ############################################################################### # This defines a timeperiod where all times are valid for checks, # notifications, etc. The classic "24x7" support nightmare. :-) define timeperiod{ timeperiod_name 24x7 alias 24 Hours A Day, 7 Days A Week sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } # 'workhours' timeperiod definition define timeperiod{ timeperiod_name workhours alias Normal Work Hours monday 09:00-17:00 tuesday 09:00-17:00 wednesday 09:00-17:00 thursday 09:00-17:00 friday 09:00-17:00 } # 'none' timeperiod definition define timeperiod{ timeperiod_name none alias No Time Is A Good Time } # Some U.S. holidays # Note: The timeranges for each holiday are meant to *exclude* the holidays from being # treated as a valid time for notifications, etc. You probably don't want your pager # going off on New Year's. Although you're employer might... :-) define timeperiod{ name us-holidays timeperiod_name us-holidays alias U.S. Holidays january 1 00:00-00:00 ; New Years monday -1 may 00:00-00:00 ; Memorial Day (last Monday in May) july 4 00:00-00:00 ; Independence Day monday 1 september 00:00-00:00 ; Labor Day (first Monday in September) thursday -1 november 00:00-00:00 ; Thanksgiving (last Thursday in November) december 25 00:00-00:00 ; Christmas } # This defines a modified "24x7" timeperiod that covers every day of the # year, except for U.S. holidays (defined in the timeperiod above). define timeperiod{ timeperiod_name 24x7_sans_holidays alias 24x7 Sans Holidays use us-holidays ; Get holiday exceptions from other timeperiod sunday 00:00-24:00 monday 00:00-24:00 tuesday 00:00-24:00 wednesday 00:00-24:00 thursday 00:00-24:00 friday 00:00-24:00 saturday 00:00-24:00 } Nagios-Object-0.21.20/t/v3_config/template-object/commands.cfg000444001750001750 1705212220262237 25314 0ustar00dfergusondferguson000000000000############################################################################### # COMMANDS.CFG - SAMPLE COMMAND DEFINITIONS FOR NAGIOS 3.1.2 # # Last Modified: 05-31-2007 # # NOTES: This config file provides you with some example command definitions # that you can reference in host, service, and contact definitions. # # You don't need to keep commands in a separate file from your other # object definitions. This has been done just to make things easier to # understand. # ############################################################################### ################################################################################ # # SAMPLE NOTIFICATION COMMANDS # # These are some example notification commands. They may or may not work on # your system without modification. As an example, some systems will require # you to use "/usr/bin/mailx" instead of "/usr/bin/mail" in the commands below. # ################################################################################ # 'notify-host-by-email' command definition define command{ command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ } # 'notify-service-by-email' command definition define command{ command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ } ################################################################################ # # SAMPLE HOST CHECK COMMANDS # ################################################################################ # This command checks to see if a host is "alive" by pinging it # The check must result in a 100% packet loss or 5 second (5000ms) round trip # average time to produce a critical error. # Note: Five ICMP echo packets are sent (determined by the '-p 5' argument) # 'check-host-alive' command definition define command{ command_name check-host-alive command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5 } ################################################################################ # # SAMPLE SERVICE CHECK COMMANDS # # These are some example service check commands. They may or may not work on # your system, as they must be modified for your plugins. See the HTML # documentation on the plugins for examples of how to configure command definitions. # # NOTE: The following 'check_local_...' functions are designed to monitor # various metrics on the host that Nagios is running on (i.e. this one). ################################################################################ # 'check_local_disk' command definition define command{ command_name check_local_disk command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ } # 'check_local_load' command definition define command{ command_name check_local_load command_line $USER1$/check_load -w $ARG1$ -c $ARG2$ } # 'check_local_procs' command definition define command{ command_name check_local_procs command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$ } # 'check_local_users' command definition define command{ command_name check_local_users command_line $USER1$/check_users -w $ARG1$ -c $ARG2$ } # 'check_local_swap' command definition define command{ command_name check_local_swap command_line $USER1$/check_swap -w $ARG1$ -c $ARG2$ } # 'check_local_mrtgtraf' command definition define command{ command_name check_local_mrtgtraf command_line $USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$ } ################################################################################ # NOTE: The following 'check_...' commands are used to monitor services on # both local and remote hosts. ################################################################################ # 'check_ftp' command definition define command{ command_name check_ftp command_line $USER1$/check_ftp -H $HOSTADDRESS$ $ARG1$ } # 'check_hpjd' command definition define command{ command_name check_hpjd command_line $USER1$/check_hpjd -H $HOSTADDRESS$ $ARG1$ } # 'check_snmp' command definition define command{ command_name check_snmp command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$ } # 'check_http' command definition define command{ command_name check_http command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$ } # 'check_ssh' command definition define command{ command_name check_ssh command_line $USER1$/check_ssh $ARG1$ $HOSTADDRESS$ } # 'check_dhcp' command definition define command{ command_name check_dhcp command_line $USER1$/check_dhcp $ARG1$ } # 'check_ping' command definition define command{ command_name check_ping command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5 } # 'check_pop' command definition define command{ command_name check_pop command_line $USER1$/check_pop -H $HOSTADDRESS$ $ARG1$ } # 'check_imap' command definition define command{ command_name check_imap command_line $USER1$/check_imap -H $HOSTADDRESS$ $ARG1$ } # 'check_smtp' command definition define command{ command_name check_smtp command_line $USER1$/check_smtp -H $HOSTADDRESS$ $ARG1$ } # 'check_tcp' command definition define command{ command_name check_tcp command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$ } # 'check_udp' command definition define command{ command_name check_udp command_line $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$ } # 'check_nt' command definition define command{ command_name check_nt command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$ } ################################################################################ # # SAMPLE PERFORMANCE DATA COMMANDS # # These are sample performance data commands that can be used to send performance # data output to two text files (one for hosts, another for services). If you # plan on simply writing performance data out to a file, consider using the # host_perfdata_file and service_perfdata_file options in the main config file. # ################################################################################ # 'process-host-perfdata' command definition define command{ command_name process-host-perfdata command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /usr/local/nagios/var/host-perfdata.out } # 'process-service-perfdata' command definition define command{ command_name process-service-perfdata command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /usr/local/nagios/var/service-perfdata.out } Nagios-Object-0.21.20/t/v3_config/template-object/commands.cfg.in000444001750001750 1703612220262237 25723 0ustar00dfergusondferguson000000000000############################################################################### # COMMANDS.CFG - SAMPLE COMMAND DEFINITIONS FOR NAGIOS @VERSION@ # # Last Modified: 05-31-2007 # # NOTES: This config file provides you with some example command definitions # that you can reference in host, service, and contact definitions. # # You don't need to keep commands in a separate file from your other # object definitions. This has been done just to make things easier to # understand. # ############################################################################### ################################################################################ # # SAMPLE NOTIFICATION COMMANDS # # These are some example notification commands. They may or may not work on # your system without modification. As an example, some systems will require # you to use "/usr/bin/mailx" instead of "/usr/bin/mail" in the commands below. # ################################################################################ # 'notify-host-by-email' command definition define command{ command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | @MAIL_PROG@ -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ } # 'notify-service-by-email' command definition define command{ command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | @MAIL_PROG@ -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ } ################################################################################ # # SAMPLE HOST CHECK COMMANDS # ################################################################################ # This command checks to see if a host is "alive" by pinging it # The check must result in a 100% packet loss or 5 second (5000ms) round trip # average time to produce a critical error. # Note: Five ICMP echo packets are sent (determined by the '-p 5' argument) # 'check-host-alive' command definition define command{ command_name check-host-alive command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5 } ################################################################################ # # SAMPLE SERVICE CHECK COMMANDS # # These are some example service check commands. They may or may not work on # your system, as they must be modified for your plugins. See the HTML # documentation on the plugins for examples of how to configure command definitions. # # NOTE: The following 'check_local_...' functions are designed to monitor # various metrics on the host that Nagios is running on (i.e. this one). ################################################################################ # 'check_local_disk' command definition define command{ command_name check_local_disk command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ } # 'check_local_load' command definition define command{ command_name check_local_load command_line $USER1$/check_load -w $ARG1$ -c $ARG2$ } # 'check_local_procs' command definition define command{ command_name check_local_procs command_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$ } # 'check_local_users' command definition define command{ command_name check_local_users command_line $USER1$/check_users -w $ARG1$ -c $ARG2$ } # 'check_local_swap' command definition define command{ command_name check_local_swap command_line $USER1$/check_swap -w $ARG1$ -c $ARG2$ } # 'check_local_mrtgtraf' command definition define command{ command_name check_local_mrtgtraf command_line $USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$ } ################################################################################ # NOTE: The following 'check_...' commands are used to monitor services on # both local and remote hosts. ################################################################################ # 'check_ftp' command definition define command{ command_name check_ftp command_line $USER1$/check_ftp -H $HOSTADDRESS$ $ARG1$ } # 'check_hpjd' command definition define command{ command_name check_hpjd command_line $USER1$/check_hpjd -H $HOSTADDRESS$ $ARG1$ } # 'check_snmp' command definition define command{ command_name check_snmp command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$ } # 'check_http' command definition define command{ command_name check_http command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$ } # 'check_ssh' command definition define command{ command_name check_ssh command_line $USER1$/check_ssh $ARG1$ $HOSTADDRESS$ } # 'check_dhcp' command definition define command{ command_name check_dhcp command_line $USER1$/check_dhcp $ARG1$ } # 'check_ping' command definition define command{ command_name check_ping command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5 } # 'check_pop' command definition define command{ command_name check_pop command_line $USER1$/check_pop -H $HOSTADDRESS$ $ARG1$ } # 'check_imap' command definition define command{ command_name check_imap command_line $USER1$/check_imap -H $HOSTADDRESS$ $ARG1$ } # 'check_smtp' command definition define command{ command_name check_smtp command_line $USER1$/check_smtp -H $HOSTADDRESS$ $ARG1$ } # 'check_tcp' command definition define command{ command_name check_tcp command_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$ } # 'check_udp' command definition define command{ command_name check_udp command_line $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$ } # 'check_nt' command definition define command{ command_name check_nt command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$ } ################################################################################ # # SAMPLE PERFORMANCE DATA COMMANDS # # These are sample performance data commands that can be used to send performance # data output to two text files (one for hosts, another for services). If you # plan on simply writing performance data out to a file, consider using the # host_perfdata_file and service_perfdata_file options in the main config file. # ################################################################################ # 'process-host-perfdata' command definition define command{ command_name process-host-perfdata command_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> @localstatedir@/host-perfdata.out } # 'process-service-perfdata' command definition define command{ command_name process-service-perfdata command_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> @localstatedir@/service-perfdata.out } Nagios-Object-0.21.20/t/v3_config/template-object/templates.cfg.in000444001750001750 2507412220262237 26121 0ustar00dfergusondferguson000000000000############################################################################### # TEMPLATES.CFG - SAMPLE OBJECT TEMPLATES # # Last Modified: 10-03-2007 # # NOTES: This config file provides you with some example object definition # templates that are refered by other host, service, contact, etc. # definitions in other config files. # # You don't need to keep these definitions in a separate file from your # other object definitions. This has been done just to make things # easier to understand. # ############################################################################### ############################################################################### ############################################################################### # # CONTACT TEMPLATES # ############################################################################### ############################################################################### # Generic contact definition template - This is NOT a real contact, just a template! define contact{ name generic-contact ; The name of this contact template service_notification_period 24x7 ; service notifications can be sent anytime host_notification_period 24x7 ; host notifications can be sent anytime service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events service_notification_commands notify-service-by-email ; send service notifications via email host_notification_commands notify-host-by-email ; send host notifications via email register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE! } ############################################################################### ############################################################################### # # HOST TEMPLATES # ############################################################################### ############################################################################### # Generic host definition template - This is NOT a real host, just a template! define host{ name generic-host ; The name of this host template notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host 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 notification_period 24x7 ; Send host notifications at any time register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE! } # Linux host definition template - This is NOT a real host, just a template! define host{ name linux-server ; The name of this host template use generic-host ; This template inherits other values from the generic-host template check_period 24x7 ; By default, Linux hosts are checked round the clock check_interval 5 ; Actively check the host every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each Linux host 10 times (max) check_command check-host-alive ; Default command to check Linux hosts notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day ; Note that the notification_period variable is being overridden from ; the value that is inherited from the generic-host template! notification_interval 120 ; Resend notifications every 2 hours notification_options d,u,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE! } # Windows host definition template - This is NOT a real host, just a template! define host{ name windows-server ; The name of this host template use generic-host ; Inherit default values from the generic-host template check_period 24x7 ; By default, Windows servers are monitored round the clock check_interval 5 ; Actively check the server every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each server 10 times (max) check_command check-host-alive ; Default command to check if servers are "alive" notification_period 24x7 ; Send notification out at any time - day or night notification_interval 30 ; Resend notifications every 30 minutes notification_options d,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default hostgroups windows-servers ; Host groups that Windows servers should be a member of register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE } # We define a generic printer template that can be used for most printers we monitor define host{ name generic-printer ; The name of this host template use generic-host ; Inherit default values from the generic-host template check_period 24x7 ; By default, printers are monitored round the clock check_interval 5 ; Actively check the printer every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each printer 10 times (max) check_command check-host-alive ; Default command to check if printers are "alive" notification_period workhours ; Printers are only used during the workday notification_interval 30 ; Resend notifications every 30 minutes notification_options d,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE } # Define a template for switches that we can reuse define host{ name generic-switch ; The name of this host template use generic-host ; Inherit default values from the generic-host template check_period 24x7 ; By default, switches are monitored round the clock check_interval 5 ; Switches are checked every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each switch 10 times (max) check_command check-host-alive ; Default command to check if routers are "alive" notification_period 24x7 ; Send notifications at any time notification_interval 30 ; Resend notifications every 30 minutes notification_options d,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE } ############################################################################### ############################################################################### # # SERVICE TEMPLATES # ############################################################################### ############################################################################### # Generic service definition template - This is NOT a real service, just a template! define service{ name generic-service ; The 'name' of this service template active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled/accepted parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) 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 is_volatile 0 ; The service is not volatile check_period 24x7 ; The service can be checked at any time of the day max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state normal_check_interval 10 ; Check the service every 10 minutes under normal conditions retry_check_interval 2 ; Re-check the service every two minutes until a hard state can be determined contact_groups admins ; Notifications get sent out to everyone in the 'admins' group notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events notification_interval 60 ; Re-notify about service problems every hour notification_period 24x7 ; Notifications can be sent out at any time register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE! } # Local service definition template - This is NOT a real service, just a template! define service{ name local-service ; The name of this service template use generic-service ; Inherit default values from the generic-service definition max_check_attempts 4 ; Re-check the service up to 4 times in order to determine its final (hard) state normal_check_interval 5 ; Check the service every 5 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until a hard state can be determined register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE! } Nagios-Object-0.21.20/t/v3_config/template-object/README000444001750001750 115012220262237 23662 0ustar00dfergusondferguson000000000000================================ SAMPLE OBJECT CONFIG FILE README ================================ This directory contains sample object definition config files. Sample config files have a .cfg extension. Ignore any files with a .in extension, as they are templates used to generate the sample config files. Please note that you can keep all of your object definitions in a single file if you wish. You may also split them up into multiple config files, as is done here. Read the 'Quickstart Installation Guide' in the HTML documentation for instructions on how to install and use these sample config files. Nagios-Object-0.21.20/t/v3_config/template-object/templates.cfg000444001750001750 2507412220262237 25514 0ustar00dfergusondferguson000000000000############################################################################### # TEMPLATES.CFG - SAMPLE OBJECT TEMPLATES # # Last Modified: 10-03-2007 # # NOTES: This config file provides you with some example object definition # templates that are refered by other host, service, contact, etc. # definitions in other config files. # # You don't need to keep these definitions in a separate file from your # other object definitions. This has been done just to make things # easier to understand. # ############################################################################### ############################################################################### ############################################################################### # # CONTACT TEMPLATES # ############################################################################### ############################################################################### # Generic contact definition template - This is NOT a real contact, just a template! define contact{ name generic-contact ; The name of this contact template service_notification_period 24x7 ; service notifications can be sent anytime host_notification_period 24x7 ; host notifications can be sent anytime service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events service_notification_commands notify-service-by-email ; send service notifications via email host_notification_commands notify-host-by-email ; send host notifications via email register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE! } ############################################################################### ############################################################################### # # HOST TEMPLATES # ############################################################################### ############################################################################### # Generic host definition template - This is NOT a real host, just a template! define host{ name generic-host ; The name of this host template notifications_enabled 1 ; Host notifications are enabled event_handler_enabled 1 ; Host 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 notification_period 24x7 ; Send host notifications at any time register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE! } # Linux host definition template - This is NOT a real host, just a template! define host{ name linux-server ; The name of this host template use generic-host ; This template inherits other values from the generic-host template check_period 24x7 ; By default, Linux hosts are checked round the clock check_interval 5 ; Actively check the host every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each Linux host 10 times (max) check_command check-host-alive ; Default command to check Linux hosts notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day ; Note that the notification_period variable is being overridden from ; the value that is inherited from the generic-host template! notification_interval 120 ; Resend notifications every 2 hours notification_options d,u,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE! } # Windows host definition template - This is NOT a real host, just a template! define host{ name windows-server ; The name of this host template use generic-host ; Inherit default values from the generic-host template check_period 24x7 ; By default, Windows servers are monitored round the clock check_interval 5 ; Actively check the server every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each server 10 times (max) check_command check-host-alive ; Default command to check if servers are "alive" notification_period 24x7 ; Send notification out at any time - day or night notification_interval 30 ; Resend notifications every 30 minutes notification_options d,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default hostgroups windows-servers ; Host groups that Windows servers should be a member of register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE } # We define a generic printer template that can be used for most printers we monitor define host{ name generic-printer ; The name of this host template use generic-host ; Inherit default values from the generic-host template check_period 24x7 ; By default, printers are monitored round the clock check_interval 5 ; Actively check the printer every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each printer 10 times (max) check_command check-host-alive ; Default command to check if printers are "alive" notification_period workhours ; Printers are only used during the workday notification_interval 30 ; Resend notifications every 30 minutes notification_options d,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE } # Define a template for switches that we can reuse define host{ name generic-switch ; The name of this host template use generic-host ; Inherit default values from the generic-host template check_period 24x7 ; By default, switches are monitored round the clock check_interval 5 ; Switches are checked every 5 minutes retry_interval 1 ; Schedule host check retries at 1 minute intervals max_check_attempts 10 ; Check each switch 10 times (max) check_command check-host-alive ; Default command to check if routers are "alive" notification_period 24x7 ; Send notifications at any time notification_interval 30 ; Resend notifications every 30 minutes notification_options d,r ; Only send notifications for specific host states contact_groups admins ; Notifications get sent to the admins by default register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE } ############################################################################### ############################################################################### # # SERVICE TEMPLATES # ############################################################################### ############################################################################### # Generic service definition template - This is NOT a real service, just a template! define service{ name generic-service ; The 'name' of this service template active_checks_enabled 1 ; Active service checks are enabled passive_checks_enabled 1 ; Passive service checks are enabled/accepted parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems) 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 is_volatile 0 ; The service is not volatile check_period 24x7 ; The service can be checked at any time of the day max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state normal_check_interval 10 ; Check the service every 10 minutes under normal conditions retry_check_interval 2 ; Re-check the service every two minutes until a hard state can be determined contact_groups admins ; Notifications get sent out to everyone in the 'admins' group notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events notification_interval 60 ; Re-notify about service problems every hour notification_period 24x7 ; Notifications can be sent out at any time register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE! } # Local service definition template - This is NOT a real service, just a template! define service{ name local-service ; The name of this service template use generic-service ; Inherit default values from the generic-service definition max_check_attempts 4 ; Re-check the service up to 4 times in order to determine its final (hard) state normal_check_interval 5 ; Check the service every 5 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until a hard state can be determined register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE! } Nagios-Object-0.21.20/t/v3_config/template-object/switch.cfg000444001750001750 633512220262237 24776 0ustar00dfergusondferguson000000000000############################################################################### # SWITCH.CFG - SAMPLE CONFIG FILE FOR MONITORING A SWITCH # # Last Modified: 10-03-2007 # # NOTES: This config file assumes that you are using the sample configuration # files that get installed with the Nagios quickstart guide. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITIONS # ############################################################################### ############################################################################### # Define the switch that we'll be monitoring define host{ use generic-switch ; Inherit default values from a template host_name linksys-srw224p ; The name we're giving to this switch alias Linksys SRW224P Switch ; A longer name associated with the switch address 192.168.1.253 ; IP address of the switch hostgroups switches ; Host groups this switch is associated with } ############################################################################### ############################################################################### # # HOST GROUP DEFINITIONS # ############################################################################### ############################################################################### # Create a new hostgroup for switches define hostgroup{ hostgroup_name switches ; The name of the hostgroup alias Network Switches ; Long name of the group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Create a service to PING to switch define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p ; The name of the host the service is associated with service_description PING ; The service description check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service normal_check_interval 5 ; Check the service every 5 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined } # Monitor uptime via SNMP define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p service_description Uptime check_command check_snmp!-C public -o sysUpTime.0 } # Monitor Port 1 status via SNMP define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p service_description Port 1 Link Status check_command check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-MIB } # Monitor bandwidth via MRTG logs define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p service_description Port 1 Bandwidth Usage check_command check_local_mrtgtraf!/var/lib/mrtg/192.168.1.253_1.log!AVG!1000000,1000000!5000000,5000000!10 } Nagios-Object-0.21.20/t/v3_config/template-object/localhost.cfg000444001750001750 1243312220262237 25501 0ustar00dfergusondferguson000000000000############################################################################### # LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE # # Last Modified: 05-31-2007 # # NOTE: This config file is intended to serve as an *extremely* simple # example of how you can create configuration entries to monitor # the local (Linux) machine. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITION # ############################################################################### ############################################################################### # Define a host for the local machine define host{ use linux-server ; Name of host template to use ; This host definition will inherit all variables that are defined ; in (or inherited by) the linux-server host template definition. host_name localhost alias localhost address 127.0.0.1 } ############################################################################### ############################################################################### # # HOST GROUP DEFINITION # ############################################################################### ############################################################################### # Define an optional hostgroup for Linux machines define hostgroup{ hostgroup_name linux-servers ; The name of the hostgroup alias Linux Servers ; Long name of the group members localhost ; Comma separated list of hosts that belong to this group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Define a service to "ping" the local machine define service{ use local-service ; Name of service template to use host_name localhost service_description PING check_command check_ping!100.0,20%!500.0,60% } # Define a service to check the disk space of the root partition # on the local machine. Warning if < 20% free, critical if # < 10% free space on partition. define service{ use local-service ; Name of service template to use host_name localhost service_description Root Partition check_command check_local_disk!20%!10%!/ } # Define a service to check the number of currently logged in # users on the local machine. Warning if > 20 users, critical # if > 50 users. define service{ use local-service ; Name of service template to use host_name localhost service_description Current Users check_command check_local_users!20!50 } # Define a service to check the number of currently running procs # on the local machine. Warning if > 250 processes, critical if # > 400 users. define service{ use local-service ; Name of service template to use host_name localhost service_description Total Processes check_command check_local_procs!250!400!RSZDT } # Define a service to check the load on the local machine. define service{ use local-service ; Name of service template to use host_name localhost service_description Current Load check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 } # Define a service to check the swap usage the local machine. # Critical if less than 10% of swap is free, warning if less than 20% is free define service{ use local-service ; Name of service template to use host_name localhost service_description Swap Usage check_command check_local_swap!20!10 } # Define a service to check SSH on the local machine. # Disable notifications for this service by default, as not all users may have SSH enabled. define service{ use local-service ; Name of service template to use host_name localhost service_description SSH check_command check_ssh notifications_enabled 0 } # Define a service to check HTTP on the local machine. # Disable notifications for this service by default, as not all users may have HTTP enabled. define service{ use local-service ; Name of service template to use host_name localhost service_description HTTP check_command check_http notifications_enabled 0 } Nagios-Object-0.21.20/t/v3_config/template-object/contacts.cfg.in000444001750001750 417512220262237 25720 0ustar00dfergusondferguson000000000000############################################################################### # CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS # # Last Modified: 05-31-2007 # # NOTES: This config file provides you with some example contact and contact # group definitions that you can reference in host and service # definitions. # # You don't need to keep these definitions in a separate file from your # other object definitions. This has been done just to make things # easier to understand. # ############################################################################### ############################################################################### ############################################################################### # # CONTACTS # ############################################################################### ############################################################################### # Just one contact defined by default - the Nagios admin (that's you) # This contact definition inherits a lot of default values from the 'generic-contact' # template which is defined elsewhere. define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email @nagios_user@@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } ############################################################################### ############################################################################### # # CONTACT GROUPS # ############################################################################### ############################################################################### # We only have one contact in this simple configuration file, so there is # no need to create more than one contact group. define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagiosadmin } Nagios-Object-0.21.20/t/v3_config/template-object/windows.cfg.in000444001750001750 766312220262237 25601 0ustar00dfergusondferguson000000000000############################################################################### # WINDOWS.CFG - SAMPLE CONFIG FILE FOR MONITORING A WINDOWS MACHINE # # Last Modified: 06-13-2007 # # NOTES: This config file assumes that you are using the sample configuration # files that get installed with the Nagios quickstart guide. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITIONS # ############################################################################### ############################################################################### # Define a host for the Windows machine we'll be monitoring # Change the host_name, alias, and address to fit your situation define host{ use windows-server ; Inherit default values from a template host_name winserver ; The name we're giving to this host alias My Windows Server ; A longer name associated with the host address 192.168.1.2 ; IP address of the host } ############################################################################### ############################################################################### # # HOST GROUP DEFINITIONS # ############################################################################### ############################################################################### # Define a hostgroup for Windows machines # All hosts that use the windows-server template will automatically be a member of this group define hostgroup{ hostgroup_name windows-servers ; The name of the hostgroup alias Windows Servers ; Long name of the group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Create a service for monitoring the version of NSCLient++ that is installed # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description NSClient++ Version check_command check_nt!CLIENTVERSION } # Create a service for monitoring the uptime of the server # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description Uptime check_command check_nt!UPTIME } # Create a service for monitoring CPU load # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description CPU Load check_command check_nt!CPULOAD!-l 5,80,90 } # Create a service for monitoring memory usage # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description Memory Usage check_command check_nt!MEMUSE!-w 80 -c 90 } # Create a service for monitoring C:\ disk usage # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description C:\ Drive Space check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90 } # Create a service for monitoring the W3SVC service # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description W3SVC check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC } # Create a service for monitoring the Explorer.exe process # Change the host_name to match the name of the host you defined above define service{ use generic-service host_name winserver service_description Explorer check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe } Nagios-Object-0.21.20/t/v3_config/template-object/switch.cfg.in000444001750001750 633512220262237 25403 0ustar00dfergusondferguson000000000000############################################################################### # SWITCH.CFG - SAMPLE CONFIG FILE FOR MONITORING A SWITCH # # Last Modified: 10-03-2007 # # NOTES: This config file assumes that you are using the sample configuration # files that get installed with the Nagios quickstart guide. # ############################################################################### ############################################################################### ############################################################################### # # HOST DEFINITIONS # ############################################################################### ############################################################################### # Define the switch that we'll be monitoring define host{ use generic-switch ; Inherit default values from a template host_name linksys-srw224p ; The name we're giving to this switch alias Linksys SRW224P Switch ; A longer name associated with the switch address 192.168.1.253 ; IP address of the switch hostgroups switches ; Host groups this switch is associated with } ############################################################################### ############################################################################### # # HOST GROUP DEFINITIONS # ############################################################################### ############################################################################### # Create a new hostgroup for switches define hostgroup{ hostgroup_name switches ; The name of the hostgroup alias Network Switches ; Long name of the group } ############################################################################### ############################################################################### # # SERVICE DEFINITIONS # ############################################################################### ############################################################################### # Create a service to PING to switch define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p ; The name of the host the service is associated with service_description PING ; The service description check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service normal_check_interval 5 ; Check the service every 5 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined } # Monitor uptime via SNMP define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p service_description Uptime check_command check_snmp!-C public -o sysUpTime.0 } # Monitor Port 1 status via SNMP define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p service_description Port 1 Link Status check_command check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-MIB } # Monitor bandwidth via MRTG logs define service{ use generic-service ; Inherit values from a template host_name linksys-srw224p service_description Port 1 Bandwidth Usage check_command check_local_mrtgtraf!/var/lib/mrtg/192.168.1.253_1.log!AVG!1000000,1000000!5000000,5000000!10 } Nagios-Object-0.21.20/bin000755001750001750 012220262237 16221 5ustar00dfergusondferguson000000000000Nagios-Object-0.21.20/bin/statusdat_demo.pl000555001750001750 223312220262237 21736 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl # $Id$ # $LastChangedDate$ # $Rev$ use lib qw(./lib ../lib); use Nagios::StatusLog; use Benchmark ':hireswallclock'; use Getopt::Std; use Data::Dumper; =head1 NAME statusdat_demo.pl - test the StatusLog module =head1 USAGE perl statusdat_demo.pl -l /var/opt/nagios/status.dat =head1 NOTES Please send the benchmark outputs to duncs@cpan.org so I can see how the performance is on boxes and configs other than my own. =cut our $opt_l; getopt('l:'); die "Must specify location of Nagios status log with -l option." if ( !$opt_l ); my $bench_begin = Benchmark->new; my $log = Nagios::StatusLog->new( Filename => $opt_l, Version => 2.0 ); my $bench_postparse = Benchmark->new; #print Dumper( $log ); foreach my $host ( $log->list_hosts ) { my $obj = $log->host($host); printf "Host: %s Last Update: %d\n", $obj->host_name, $obj->last_update; } my $prog = $log->program; printf "Started at %d", $prog->program_start; my $bench_postprint = Benchmark->new; printf "\nTime to parse: %s\nTime to print: %s\n\n", timestr( timediff( $bench_postparse, $bench_begin ) ), timestr( timediff( $bench_postprint, $bench_postparse ) ); Nagios-Object-0.21.20/bin/decode_flags.pl000555001750001750 466112220262237 21324 0ustar00dfergusondferguson000000000000#!/usr/bin/perl # $Id$ # $LastChangedDate$ # $Rev$ use lib qw(./lib ../lib); use Nagios::Object qw(:all); =head1 NAME decode_flags.pl - decode the flags in Nagios/Object.pm =head1 DESCRIPTION The flags in Nagios/Object.pm are currently encoded into a single integer by setting its individual bits. Usually, I'd just use individual flags for each of them, but it was getting to be too many to manage. This is actually pretty easy to handle once you get used to it and very common in C programming. =head1 SYNOPSIS decode_flags.pl 42 decode_flags.pl NAGIOS_V2 NO_INHERIT =cut if ( @ARGV == 0 || !$ARGV[0] || $ARGV eq '-h' || $ARGV eq '--help' ) { print STDERR "Usage:\n\t$0 42\n\t$0 PERL_ONLY V1\n"; exit 1; } elsif ( $ARGV[0] =~ /[^\d]/ ) { my $flag = 0; foreach my $nf (@ARGV) { if ( $nf =~ /NO_INHERIT$/i ) { $flag = ( $flag | NAGIOS_NO_INHERIT ) } if ( $nf =~ /PERL_ONLY$/i ) { $flag = ( $flag | NAGIOS_PERL_ONLY ) } if ( $nf =~ /V1$/i ) { $flag = ( $flag | NAGIOS_V1 ) } if ( $nf =~ /V2$/i ) { $flag = ( $flag | NAGIOS_V2 ) } if ( $nf =~ /V3$/i ) { $flag = ( $flag | NAGIOS_V3 ) } if ( $nf =~ /V1_ONLY$/i ) { $flag = ( $flag | NAGIOS_V1_ONLY ) } if ( $nf =~ /V2_ONLY$/i ) { $flag = ( $flag | NAGIOS_V2_ONLY ) } if ( $nf =~ /V3_ONLY$/i ) { $flag = ( $flag | NAGIOS_V3_ONLY ) } if ( $nf =~ /NO_DISPLAY$/i ) { $flag = ( $flag | NAGIOS_NO_DISPLAY ) } } printf "Integer for flags '%s' is %d\n", join( ', ', @ARGV ), $flag; } else { my @flags = (); push( @flags, 'NO_INHERIT' ) if ( ( $ARGV[0] & NAGIOS_NO_INHERIT ) == NAGIOS_NO_INHERIT ); push( @flags, 'PERL_ONLY' ) if ( ( $ARGV[0] & NAGIOS_PERL_ONLY ) == NAGIOS_PERL_ONLY ); push( @flags, 'V1' ) if ( ( $ARGV[0] & NAGIOS_V1 ) == NAGIOS_V1 ); push( @flags, 'V2' ) if ( ( $ARGV[0] & NAGIOS_V2 ) == NAGIOS_V2 ); push( @flags, 'V3' ) if ( ( $ARGV[0] & NAGIOS_V3 ) == NAGIOS_V3 ); push( @flags, 'V1_ONLY' ) if ( ( $ARGV[0] & NAGIOS_V1_ONLY ) == NAGIOS_V1_ONLY ); push( @flags, 'V2_ONLY' ) if ( ( $ARGV[0] & NAGIOS_V2_ONLY ) == NAGIOS_V2_ONLY ); push( @flags, 'V3_ONLY' ) if ( ( $ARGV[0] & NAGIOS_V3_ONLY ) == NAGIOS_V3_ONLY ); push( @flags, 'NO_DISPLAY' ) if ( ( $ARGV[0] & NAGIOS_NO_DISPLAY ) == NAGIOS_NO_DISPLAY ); printf "Flags in number %d are '%s'\n", $ARGV[0], join( ', ', @flags ); } Nagios-Object-0.21.20/bin/parse.pl000555001750001750 313212220262237 20027 0ustar00dfergusondferguson000000000000#!/usr/bin/perl -w # $Id$ # $LastChangedDate$ # $Rev$ use strict; use lib qw( ./lib ../lib); use Nagios::Config; use Nagios::Object::Config; use Getopt::Std; use Benchmark qw(:all); use Data::Dumper; our ( $opt_n, $opt_o, $opt_v, $opt_b, $opt_d, $opt_f, $opt_r, $opt_l ); getopt('n:o:v:'); getopt('bdfrl'); if ($opt_f) { Nagios::Config->fast_mode(1); } Nagios::Object::Config->strict_mode(undef); unless ($opt_l) { Nagios::Object::Config->strict_mode(1); } if ( !$opt_n && !$opt_o ) { print "Must specify a filename to parse (either -n or -o).\n"; exit 1; } my $t0 = new Benchmark; my $obj = undef; if ($opt_n) { $obj = Nagios::Config->new( Filename => $opt_n, Version => $opt_v ); } if ($opt_o) { $obj = Nagios::Object::Config->new( Version => $opt_v ); $obj->parse($opt_o); if ($opt_r) { $obj->resolve_objects; $obj->register_objects; } } if ($opt_d) { print Dumper($obj), "\n"; } if ($opt_b) { my $t1 = new Benchmark; my $td = timediff( $t1, $t0 ); printf "Benchmark: %s\n", timestr($td); } =head1 NAME parse.pl =head1 USAGE parse.pl [-n|-o] [-v] [-b] [-d] [-f] =head1 OPTIONS =over 4 =item -n Specify a primary nagios configuration file. This file will be parsed along with any object configuration files referenced inside it. =item -o Parse a single object configuration file. =item -v Specify a Nagios configuration version to parse. i.e. -v 1 or -v 2 =item -b Show some benchmarking information. =item -d Dump out the data structures after parsing (uses Data::Dumper). =item -f Use the new EXPERIMENTAL fast mode. =cut Nagios-Object-0.21.20/bin/config_status_demo.pl000555001750001750 343312220262237 22575 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl # File ID: $Id$ # Last Change: $LastChangedDate$ # Revision: $Rev$ use Nagios::Config; use Nagios::StatusLog; use Benchmark ':hireswallclock'; use Getopt::Std; =head1 NAME config_status_demo.pl - demonstrate using Nagios::Config and Nagios::StatusLog together. =head1 USAGE perl config_status_demo.pl -c /etc/opt/nagios/nagios.cfg -l /var/opt/nagios/status.log =head1 NOTES Please send the benchmark outputs to duncs@cpan.org so I can see how the performance is on boxes and configs other than my own. This setup is very sensitive to mistmatches between the configuration and the status log. =cut our ( $opt_c, $opt_l ) = (); getopt('c:l:'); die "Must specify location of Nagios configuration with -c option." if ( !$opt_c ); die "Must specify location of Nagios status log with -l option." if ( !$opt_l ); my $bench1 = Benchmark->new; my $cf = Nagios::Config->new( Filename => $opt_c ); my $bench2 = Benchmark->new; my $log = Nagios::StatusLog->new( Filename => $opt_l ); my $bench10 = Benchmark->new; foreach my $h ( $cf->list_hosts ) { next if ( !length $h->host_name ); # avoid a bug in Nagios::Object foreach my $s ( $h->list_services ) { my $svcs = $log->service( $h, $s ); if ( $svcs->status ne 'OK' ) { # only print for service not in OK # comment out the if () { } to print everything printf "Service %s on %s has status of %s\n", $s->service_description, $h->host_name, $svcs->status; } } } my $bench11 = Benchmark->new; printf "\nTime to parse: %s\nTime to parse Logfile: %s\nTime to print: %s\n\n", timestr( timediff( $bench2, $bench1 ) ), timestr( timediff( $bench10, $bench2 ) ), timestr( timediff( $bench11, $bench10 ) ); Nagios-Object-0.21.20/bin/test_configuration.pl000555001750001750 177012220262237 22631 0ustar00dfergusondferguson000000000000#!/usr/local/bin/perl # File ID: $Id$ # Last Change: $LastChangedDate$ # Revision: $Rev$ use lib qw(./lib ../lib); use Nagios::Config; use Nagios::Object::Config; use Benchmark ':hireswallclock'; use Getopt::Std; =head1 NAME test_configuration.pl - Load your configuration to verify Nagios::Object is compatible with it. -c: path to your main configuration file -l: "relaxed" mode - allow unrecognized attributes on objects, default is strict =head1 USAGE perl test_configuration.pl -c /etc/opt/nagios/nagios.cfg perl test_configuration.pl -l -c /etc/opt/nagios/nagios.cfg =cut our $opt_c; our $opt_l; getopt('c:l'); die "Must specify location of Nagios configuration with -c option." if ( !$opt_c ); unless ($opt_l) { Nagios::Object::Config->strict_mode(1); } my $bench_start = Benchmark->new; my $cf = Nagios::Config->new( Filename => $opt_c, force_relative_files => 1 ); my $bench_end = Benchmark->new; printf "\nTime to parse: %s\n", timestr( timediff( $bench_end, $bench_start ) ); Nagios-Object-0.21.20/lib000755001750001750 012220262237 16217 5ustar00dfergusondferguson000000000000Nagios-Object-0.21.20/lib/Nagios000755001750001750 012220262237 17437 5ustar00dfergusondferguson000000000000Nagios-Object-0.21.20/lib/Nagios/Object.pm000444001750001750 12552612220262237 21413 0ustar00dfergusondferguson000000000000########################################################################### # # # Nagios::Object # # Maintained by Duncan Ferguson # # Written by Albert Tobey # # Copyright 2003-2009, Albert P Tobey # # Copyright 2009, Albert P Tobey and Duncan Ferguson # # # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the # # Free Software Foundation; either version 2, or (at your option) any # # later version. # # # # This program is distributed in the hope that it will be useful, but # # WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # # General Public License for more details. # # # ########################################################################### package Nagios::Object; use warnings; use strict qw( subs vars ); use Carp; use Exporter; use Data::Dumper; use Scalar::Util qw(blessed); @Nagios::Object::ISA = qw( Exporter ); # NOTE: due to CPAN version checks this cannot currently be changed to a # standard version string, i.e. '0.21' our $VERSION = '47'; our $pre_link = undef; our $fast_mode = undef; our %nagios_setup; # constants for flags in %nagios_setup # note: might ditch version stuff soon (atobey, 2008-02-24) sub NAGIOS_NO_INHERIT { 1 << 1 } # cannot inherit from template sub NAGIOS_PERL_ONLY { 1 << 2 } # perl module only attribute sub NAGIOS_V1 { 1 << 3 } # nagios v1 attribute sub NAGIOS_V2 { 1 << 4 } # nagios v2 attribute sub NAGIOS_V1_ONLY { 1 << 5 } # not valid for nagios v2 sub NAGIOS_V2_ONLY { 1 << 6 } # not valid for nagios v1 sub NAGIOS_NO_DISPLAY { 1 << 7 } # should not be displayed by gui sub NAGIOS_V3 { 1 << 8 } # nagios v3 attribute sub NAGIOS_V3_ONLY { 1 << 9 } # not valid for nagios v1 or v2 sub NAGIOS_GROUP_SYNC { 1 << 10 } # keep sync'ed with members method in group object # export constants - the :all tag will export them all our %EXPORT_TAGS = ( all => [ qw(NAGIOS_NO_INHERIT NAGIOS_PERL_ONLY NAGIOS_V1 NAGIOS_V2 NAGIOS_V3 NAGIOS_V1_ONLY NAGIOS_V2_ONLY NAGIOS_V3_ONLY NAGIOS_NO_DISPLAY NAGIOS_GROUP_SYNC) ] ); Exporter::export_ok_tags('all'); # we also export %nagios_setup only if it is asked for by name push( @Nagios::Object::EXPORT_OK, '%nagios_setup' ); # all the data needed to set up all the objects # Object => { # attribute => [ Type, Flags ] # } # Type: a type for validation _and_ for linking objects, so we know which # fields should point to an object rather than containing a scalar. # If the type is an array reference, it indicates that the entry # may have more than one value assigned. # Flags: Really these are bitwise ORed flags, but recorded here as simple # integers for brevity. The flags are defined as constants toward # the top of this file. %nagios_setup = ( Service => { use => [ 'Nagios::Service', 10 ], service_description => [ 'STRING', 10 ], display_name => [ 'STRING', 280 ], host_name => [ ['Nagios::Host'], 10 ], servicegroups => [ ['Nagios::ServiceGroup'], 280 ], hostgroup_name => [ ['Nagios::HostGroup'], 256 ], is_volatile => [ 'BINARY', 280 ], check_command => [ 'Nagios::Command', 280 ], max_check_attempts => [ 'INTEGER', 280 ], normal_check_interval => [ 'INTEGER', 280 ], retry_check_interval => [ 'INTEGER', 280 ], check_interval => [ 'INTEGER', 280 ], retry_interval => [ 'INTEGER', 280 ], initial_state => [ [qw(o d u)], 280 ], active_checks_enabled => [ 'BINARY', 280 ], passive_checks_enabled => [ 'BINARY', 280 ], check_period => [ 'Nagios::TimePeriod', 280 ], parallelize_check => [ 'BINARY', 280 ], obsess_over_service => [ 'BINARY', 280 ], check_freshness => [ 'BINARY', 280 ], freshness_threshold => [ 'INTEGER', 280 ], event_handler => [ 'Nagios::Command', 280 ], event_handler_enabled => [ 'BINARY', 280 ], low_flap_threshold => [ 'INTEGER', 280 ], high_flap_threshold => [ 'INTEGER', 280 ], flap_detection_enabled => [ 'BINARY', 280 ], flap_detection_options => [ [qw(o d u)], 280 ], process_perf_data => [ 'BINARY', 280 ], retain_status_information => [ 'BINARY', 280 ], retain_nonstatus_information => [ 'BINARY', 280 ], notification_period => [ 'Nagios::TimePeriod', 280 ], notification_interval => [ 'INTEGER', 280 ], notification_options => [ [qw(u w c r)], 280 ], contacts => [ ['Nagios::Contact'], 280 ], contact_groups => [ ['Nagios::ContactGroup'], 280 ], notifications_enabled => [ 'BINARY', 280 ], stalking_options => [ [qw(o w u c)], 280 ], failure_prediction_enabled => [ 'BINARY', 16 ], first_notification_delay => [ 'INTEGER', 280 ], action_url => [ 'STRING', 280 ], notes => [ 'STRING', 280 ], notes_url => [ 'STRING', 280 ], name => [ 'service_description', 134 ], comment => [ 'comment', 280 ], file => [ 'filename', 280 ] }, ServiceGroup => { use => [ 'Nagios::ServiceGroup', 18 ], servicegroup_name => [ 'STRING', 18 ], alias => [ 'STRING', 16 ], members => [ [ 'Nagios::Host', 'Nagios::Service' ], 16 ], servicegroup_members => [ ['Nagios::ServiceGroup'], 280 ], name => [ 'servicegroup_name', 22 ], comment => [ 'comment', 22 ], file => [ 'filename', 22 ] }, Host => { use => [ 'Nagios::Host', 10 ], host_name => [ 'STRING', 10 ], alias => [ 'STRING', 280 ], address => [ 'STRING', 280 ], parents => [ ['Nagios::Host'], 280 ], hostgroups => [ ['Nagios::HostGroup'], 1304 ], check_command => [ 'STRING', 280 ], max_check_attempts => [ 'INTEGER', 280 ], checks_enabled => [ 'BINARY', 280 ], initial_state => [ [qw(o d u)], 280 ], active_checks_enabled => [ 'BINARY', 280 ], passive_checks_enabled => [ 'BINARY', 280 ], check_freshness => [ 'BINARY', 280 ], check_interval => [ 'INTEGER', 280 ], retry_interval => [ 'INTEGER', 768 ], obsess_over_host => [ 'BINARY', 280 ], freshness_threshold => [ 'INTEGER', 280 ], event_handler => [ 'STRING', 280 ], event_handler_enabled => [ 'BINARY', 280 ], check_period => [ 'Nagios::TimePeriod', 280 ], low_flap_threshold => [ 'INTEGER', 280 ], high_flap_threshold => [ 'INTEGER', 280 ], flap_detection_enabled => [ 'BINARY', 280 ], flap_detection_options => [ [qw(o d u)], 280 ], process_perf_data => [ 'BINARY', 280 ], retain_status_information => [ 'BINARY', 280 ], retain_nonstatus_information => [ 'BINARY', 280 ], notification_period => [ 'Nagios::TimePeriod', 280 ], notification_interval => [ 'INTEGER', 280 ], notification_options => [ [qw(d u r)], 280 ], notifications_enabled => [ 'BINARY', 280 ], stalking_options => [ [qw(o d u)], 280 ], contacts => [ ['Nagios::Contact'], 280 ], contact_groups => [ ['Nagios::ContactGroup'], 16 ], failure_prediction_enabled => [ 'BINARY', 16 ], first_notification_delay => [ 'INTEGER', 280 ], action_url => [ 'STRING', 280 ], notes => [ 'STRING', 280 ], notes_url => [ 'STRING', 280 ], name => [ 'host_name', 280 ], comment => [ 'comment', 280 ], file => [ 'filename', 280 ] }, HostGroup => { use => [ 'Nagios::HostGroup', 280 ], hostgroup_name => [ 'STRING', 280 ], alias => [ 'STRING', 280 ], contact_groups => [ ['Nagios::ContactGroup'], 40 ], members => [ ['Nagios::Host'], 1304 ], hostgroup_members => [ ['Nagios::HostGroup'], 280 ], name => [ 'hostgroup_name', 280 ], comment => [ 'comment', 280 ], file => [ 'filename', 280 ] }, Contact => { use => [ 'Nagios::Contact', 280 ], contact_name => [ 'STRING', 280 ], alias => [ 'STRING', 280 ], host_notification_period => [ 'Nagios::TimePeriod', 280 ], service_notification_period => [ 'Nagios::TimePeriod', 280 ], host_notification_options => [ [qw(d u r n)], 280 ], service_notification_options => [ [qw(w u c r n)], 280 ], host_notification_commands => [ ['Nagios::Command'], 280 ], service_notification_commands => [ ['Nagios::Command'], 280 ], email => [ 'STRING', 280 ], pager => [ 'STRING', 280 ], host_notifications_enabled => [ 'BINARY', 280 ], service_notifications_enabled => [ 'BINARY', 280 ], can_submit_commands => [ 'BINARY', 280 ], retain_status_information => [ 'BINARY', 280 ], retain_nonstatus_information => [ 'BINARY', 280 ], address1 => [ 'STRING', 16 ], address2 => [ 'STRING', 16 ], address3 => [ 'STRING', 16 ], address4 => [ 'STRING', 16 ], address5 => [ 'STRING', 16 ], address6 => [ 'STRING', 16 ], contactgroups => [ ['Nagios::ContactGroup'], 1040 ], name => [ 'contact_name', 280 ], comment => [ 'comment', 280 ], file => [ 'filename', 280 ] }, ContactGroup => { use => [ 'Nagios::ContactGroup', 280 ], contactgroup_name => [ 'STRING', 280 ], alias => [ 'STRING', 280 ], members => [ ['Nagios::Contact'], 1304 ], contactgroup_members => [ ['Nagios::ContactGroup'], 280 ], name => [ 'contactgroup_name', 280 ], comment => [ 'comment', 280 ], file => [ 'filename', 280 ] }, Command => { use => [ 'Nagios::Command', 280 ], command_name => [ 'STRING', 280 ], command_line => [ 'STRING', 280 ], name => [ 'command_name', 280 ], comment => [ 'comment', 280 ], file => [ 'filename', 280 ] }, TimePeriod => { use => [ 'Nagios::TimePeriod', 280 ], timeperiod_name => [ 'STRING', 280 ], alias => [ 'STRING', 280 ], sunday => [ 'TIMERANGE', 280 ], monday => [ 'TIMERANGE', 280 ], tuesday => [ 'TIMERANGE', 280 ], wednesday => [ 'TIMERANGE', 280 ], thursday => [ 'TIMERANGE', 280 ], friday => [ 'TIMERANGE', 280 ], saturday => [ 'TIMERANGE', 280 ], january => [ 'TIMERANGE', 768 ], february => [ 'TIMERANGE', 768 ], march => [ 'TIMERANGE', 768 ], april => [ 'TIMERANGE', 768 ], may => [ 'TIMERANGE', 768 ], june => [ 'TIMERANGE', 768 ], july => [ 'TIMERANGE', 768 ], august => [ 'TIMERANGE', 768 ], september => [ 'TIMERANGE', 768 ], october => [ 'TIMERANGE', 768 ], november => [ 'TIMERANGE', 768 ], december => [ 'TIMERANGE', 768 ], name => [ 'timeperiod_name', 280 ], comment => [ 'comment', 280 ], file => [ 'filename', 280 ] }, ServiceEscalation => { use => [ 'Nagios::ServiceEscalation', 280 ], host_name => [ ['Nagios::Host'], 280 ], hostgroup_name => [ ['Nagios::HostGroup'], 280 ], service_description => [ 'Nagios::Service', 280 ], contacts => [ ['Nagios::Contact'], 280 ], contact_groups => [ ['Nagios::ContactGroup'], 280 ], first_notification => [ 'INTEGER', 280 ], last_notification => [ 'INTEGER', 280 ], notification_interval => [ 'INTEGER', 280 ], escalation_period => [ 'Nagios::TimePeriod', 16 ], escalation_options => [ [qw(w u c r)], 16 ], name => [ 'generated', 280 ], comment => [ 'comment', 280 ], file => [ 'filename', 280 ] }, ServiceDependency => { use => [ 'Nagios::ServiceDependency', 280 ], dependent_host_name => [ ['Nagios::Host'], 280 ], dependent_service_description => [ 'Nagios::Service', 280 ], hostgroup_name => [ ['Nagios::HostGroup'], 280 ], dependent_hostgroup_name => [ ['Nagios::HostGroup'], 280 ], host_name => [ ['Nagios::Host'], 280 ], service_description => [ 'Nagios::Service', 280 ], inherits_parent => [ 'INTEGER', 280 ], execution_failure_criteria => [ [qw(o w u c n)], 280 ], execution_failure_options => [ [qw(o w u c n)], 280 ], notification_failure_criteria => [ [qw(o w u c n)], 280 ], notification_failure_options => [ [qw(o w u c n)], 280 ], name => [ 'generated', 280 ], comment => [ 'comment', 280 ], file => [ 'filename', 280 ] }, HostEscalation => { use => [ 'Nagios::HostEscalation', 280 ], host_name => [ ['Nagios::Host'], 280 ], hostgroup => [ ['Nagios::HostGroup'], 280 ], contacts => [ ['Nagios::Contact'], 280 ], contact_groups => [ ['Nagios::ContactGroup'], 280 ], first_notification => [ 'INTEGER', 280 ], last_notification => [ 'INTEGER', 280 ], notification_interval => [ 'INTEGER', 280 ], name => [ 'host_name', 280 ], comment => [ 'comment', 280 ], escalation_options => [ [qw(d u r)], 280 ], file => [ 'filename', 280 ] }, HostDependency => { use => [ 'Nagios::HostDependency', 280 ], dependent_host_name => [ ['Nagios::Host'], 280 ], dependent_hostgroup_name => [ ['Nagios::HostGroup'], 280 ], host_name => [ ['Nagios::Host'], 280 ], hostgroup_name => [ ['Nagios::HostGroup'], 280 ], inherits_parent => [ 'INTEGER', 16 ], notification_failure_criteria => [ [qw(o w u c n)], 280 ], notification_failure_options => [ [qw(o w u c n)], 280 ], execution_failure_criteria => [ [qw(o w u c n)], 16 ], execution_failure_options => [ [qw(o w u c n)], 280 ], name => [ 'generated', 280 ], comment => [ 'comment', 280 ], file => [ 'filename', 280 ] }, # Nagios 1.0 only HostGroupEscalation => { use => [ 'Nagios::HostGroupEscalation', 40 ], hostgroup => [ 'Nagios::HostGroup', 40 ], contact_groups => [ ['Nagios::ContactGroup'], 40 ], first_notification => [ 'INTEGER', 40 ], last_notification => [ 'INTEGER', 40 ], notification_interval => [ 'INTEGER', 40 ], name => [ 'hostgroup', 44 ], comment => [ 'comment', 44 ], file => [ 'filename', 44 ] }, # Nagios 2.0 only HostExtInfo => { use => [ 'HostExtInfo', 18 ], host_name => [ 'Nagios::Host', 18 ], hostgroup => [ ['Nagios::HostGroup'], 18 ], notes => [ 'STRING', 16 ], notes_url => [ 'STRING', 16 ], action_url => [ 'STRING', 16 ], icon_image => [ 'STRING', 16 ], icon_image_alt => [ 'STRING', 16 ], vrml_image => [ 'STRING', 16 ], statusmap_image => [ 'STRING', 16 ], '2d_coords' => [ 'STRING', 16 ], '3d_coords' => [ 'STRING', 16 ], name => [ 'host_name', 20 ], comment => [ 'comment', 20 ], file => [ 'filename', 20 ] }, # Nagios 2.0 only ServiceExtInfo => { use => [ 'ServiceExtInfo', 18 ], host_name => [ ['Nagios::Host'], 18 ], hostgroup => [ ['Nagios::HostGroup'], 18 ], service_description => [ 'Nagios::Service', 18 ], notes => [ 'STRING', 16 ], notes_url => [ 'STRING', 16 ], action_url => [ 'STRING', 16 ], icon_image => [ 'STRING', 16 ], icon_image_alt => [ 'STRING', 16 ], name => [ 'generated', 20 ], comment => [ 'comment', 20 ], file => [ 'filename', 20 ] } ); # create a package for every key in %nagios_setup foreach ( keys(%nagios_setup) ) { create_object_and_methods($_); } =head1 NAME Nagios::Object - Creates perl objects to represent Nagios objects =head1 DESCRIPTION This module contains the code for creating perl objects to represent any of the Nagios objects. All of the perl classes are auto-generated at compile-time, so it's pretty trivial to add new attributes or even entire objects. The following is a list of currently supported classes: Nagios::TimePeriod Nagios::Command Nagios::Contact Nagios::ContactGroup Nagios::Host Nagios::Service Nagios::HostGroup Nagios::ServiceEscalation Nagios::HostDependency Nagios::HostEscalation Nagios::HostGroupEscalation Nagios::ServiceDependency -- next two are for status.dat in Nagios 2.x Nagios::Info Nagios::Program =head1 EXAMPLE use Nagios::Object; my $generic_host = Nagios::Host->new( register => 0, parents => undef, check_command => $some_command, max_check_attempts => 3, checks_enabled => 1, event_handler => $some_command, event_handler_enabled => 0, low_flap_threshold => 0, high_flap_threshold => 0, flap_detection_enabled => 0, process_perf_data => 1, retain_status_information => 1, retain_nonstatus_information => 1, notification_interval => $timeperiod, notification_options => [qw(d u r)], notifications_enabled => 1, stalking_options => [qw(o d u)] ); # this will automatically 'use' $generic_host my $localhost = $generic_host->new( host_name => "localhost", alias => "Loopback", address => "127.0.0.1" ); my $hostname = $localhost->host_name(); printf "max check attempts for $hostname is %s.\n", $localhost->max_check_attempts; $localhost->set_event_handler( Nagios::Command->new( command_name => "new_event_handler", command_line => "/bin/true" ) ); =head1 METHODS =over 4 =item new() Create a new object of one of the types listed above. Calling new() on an existing object will use the LHS object as the template for the object being created. This is mainly useful for creating objects without involving Nagios::Object::Config (like in the test suite). Nagios::Host->new( ... ); =cut # ---------------------------------------------------------------------------- # sub new { my $parent = shift; my $type = ref($parent) ? ref($parent) : $parent; croak "single argument form of new() no longer supported" if ( @_ % 2 == 1 ); my %args = @_; # passed-in arguments hash if ( $type eq 'Nagios::Object' && $args{Type} ) { $type = delete $args{Type}; } # for referencing %nagios_setup my $nagios_setup_key = ( split( /::/, $type ) )[1]; #print "type: $type, key: $nagios_setup_key\n"; confess "invalid type '$type' for Nagios::Object - does not exist in \%nagios_setup" if ( !exists $nagios_setup{$nagios_setup_key} ); # set everything to undef by default my %default = map { $_ => undef } keys %{ $nagios_setup{$nagios_setup_key} }; # if pre_link is set, don't set objects' resolved/registered flag if ($pre_link) { $default{_has_been_resolved} = undef; $default{_has_been_registered} = undef; } # _validate will be called by _set, which will croak if this is wrong else { $default{_has_been_resolved} = 1; $default{_has_been_registered} = 1; } # instantiate an object my $self = bless( \%default, $type ); $self->{_nagios_setup_key} = $nagios_setup_key; # fill in the object with it's data from %args # if $pre_link is set, it is expected it will mostly be filled in # after instantiation, so probably not much will happen here foreach my $key ( keys %default ) { if ( exists( $args{$key} ) && defined( $args{$key} ) ) { # timeranges must be parsed into ARRAYs, so parse it here so that # users don't have to figure out the arrays and so we don't have # to export parse_time_range if ( $nagios_setup{$nagios_setup_key}->{$key}[0] eq 'TIMERANGE' ) { $args{$key} = parse_time_range( $args{$key} ); } $default{$key} = $args{$key}; } } # this lets Nagios::Object sanely build heirarchies without Object::Config # by letting the caller say $parent->new() rather than, e.g. # Nagios::TimePeriod->new( use => 'parent name' ) if ( ref($parent) ) { $self->{_use} = $parent; $self->{use} = $parent->name; } return $self; } sub setup_key { $_[0]->{_nagios_setup_key} } # ---------------------------------------------------------------------------- # # parse the time range text sub parse_time_range ($) { my $text = shift; return $text if ( !defined($text) || ref($text) ); $text =~ s/\s+//g; return undef if ( !$text ); my @retval = (); # convert time to seconds since midnight sub t2s { my $t = shift; my ( $h, $m, $s ) = split /:/, $t, 3; $s = 0 if ( !$s ); $s += $h * 3600; $s += $m * 60; return $s; } foreach my $range ( split /,/, $text ) { my ( $start, $end ) = split /-/, $range; push( @retval, [ t2s($start), t2s($end) ] ); } return wantarray ? @retval : \@retval; } # ---------------------------------------------------------------------------- # # opposite of parse_time_range sub dump_time_range ($) { my $range = shift; return undef if ( !$range ); return $range if ( !ref($range) ); # convert seconds from midnight to Nagios time format sub s2t { my $s = shift; my $hr = sprintf "%02d", int( $s / 3600 ); my $min = $s % 3600; my $sec = $min % 60; $min = sprintf "%02d", int( $min / 60 ); return $sec == 0 ? "$hr:$min" : "$hr:$min:$sec"; } my @retval = (); foreach (@$range) { push( @retval, s2t( $_->[0] ) . '-' . s2t( $_->[1] ) ); } return join ',', @retval; } =item dump() Output a Nagios define { } block from an object. This is still EXPERIMENTAL, but may eventually be robust enough to use for a configuration GUI. Passing in a single true argument will tell it to flatten the object inheritance on dump. print $object->dump(); print $object->dump(1); # flatten =cut # ---------------------------------------------------------------------------- # sub dump { my ( $self, $flatten ) = @_; my $retval = 'define '; $retval .= lc( ( split /::/, ref($self) )[1] ) . " {\n"; foreach my $attribute ( $self->list_valid_attributes ) { my $value = $self->$attribute(); next if ( $attribute eq 'register' && !defined $value ); my $attrtype = $self->attribute_type($attribute); if ( blessed $value && UNIVERSAL::can( $value, 'name' ) ) { # maybe add an additional check against %nagios_setup $value = $value->name; } elsif ( $attrtype eq 'TIMERANGE' ) { $value = dump_time_range($value); } elsif ( ref($value) eq 'ARRAY' ) { $value = join ',', map { blessed $_ ? $_->name : $_ } @$value; } if ( exists $self->{$attribute} && defined $self->{$attribute} ) { $retval .= "\t$attribute $value\n"; } elsif ($flatten) { $retval .= "\t$attribute " . $value . "\n"; } } $retval .= "}\n"; } sub template { my $self = shift; if ( exists $self->{_use} && blessed $self->{_use} ) { return $self->{_use}; } # when objects are built by Nagios::Object::Config, it's necessary # to run another step after parsing to link up all of the objects # this method does it on-demand elsif ( $self->{use} ) { if ( my $parser = $self->{object_config_object} ) { $parser->resolve($self); return $self->{_use}; } else { confess "Unable to walk object heirarchy without object configuration."; } } } =item name() This method is common to all classes created by this module. It should always return the textual name for an object. It is used internally by the Nagios::Object modules to allow polymorphism (which is what makes this module so compact). This is the only way to retrieve the name of a template, since they are identified by their "name" field. my $svc_desc = $service->name; my $hostname = $host->name; Which is just short for: my $svc_desc = $service->service_description; my $hostname = $service->host_name; =cut # ---------------------------------------------------------------------------- # my $_name_hack; sub name { my $self = shift; if ( !$self->register ) { return $self->{name}; } else { my $name_method = $self->_name_attribute; if ( $name_method eq 'generated' ) { $_name_hack++; return ref($self) . '-' . $_name_hack; # FIXME: this should work but feels wrong } my $name = $self->$name_method(); # recurse down on references to get the names, then generate something # more sensible if ( ref($name) && UNIVERSAL::can( $name, 'name' ) ) { $name = lc( ref($self) ) . '-' . $name->name; $name =~ s/^nagios:://; $name =~ s/::/_/g; } return $name; } } # ---------------------------------------------------------------------------- # # not autogenerated, but needs to exist sub set_name { my ( $self, $val ) = @_; confess "cannot set name of objects with multi-key identity" if ( ref $self->{name} eq 'ARRAY' ); $self->{name} = $val; } =item register() Returns true/undef to indicate whether the calling object is registerable or not. if ( $object->register ) { print $object->name, " is registerable." } =cut # ---------------------------------------------------------------------------- # sub register { my $self = shift; return undef if ( defined $self->{register} && $self->{register} == 0 ); return 1; } # not autogenerated, but needs to exist sub set_register { my ( $self, $value ) = @_; $self->{register} = $value; } # ---------------------------------------------------------------------------- # =item has_attribute() Returns true/undef to indicate whether the calling object has the attribute specified as the only argument. # check to see if $object has attribute "command_line" die if ( !$object->has_attribute("command_line") ); =cut sub has_attribute { exists $nagios_setup{ $_[0]->setup_key }->{ $_[1] } } =item list_attributes() Returns a list of valid attributes for the calling object. my @host_attributes = $host->list_attributes(); =cut sub list_attributes { keys( %{ $nagios_setup{ $_[0]->setup_key } } ) } sub list_valid_attributes { my $self = shift; my $package = $nagios_setup{ $self->setup_key }; my @valid; foreach my $key ( keys %$package ) { if ( ( $package->{$key}[1] & NAGIOS_PERL_ONLY ) == 0 ) { push @valid, $key; } } return sort @valid; } =item attribute_type() Returns the type of data expected by the object's set_ method for the given attribute. For some fields like notification_options, it may return "char_flag." For "name" attributes, it will simply return whatever %setup_data contains. This method needs some TLC ... my $type = $host->attribute_type("notification_period"); =cut sub attribute_type { my $self = $_[0]; # self field type my $type = $nagios_setup{ $_[0]->setup_key }->{ $_[1] }[0]; if ( ref($type) eq 'ARRAY' ) { if ( @$type == 1 ) { return $type->[0]; } elsif ( @$type > 1 && length( $type->[0] ) == 1 ) { return "char_flag"; } #elsif ( $_[1] eq 'name' || @$type > 1 ) { else { return $type; } } else { return $type; } } =item attribute_is_list() Returns true if the attribute is supposed to be a list (ARRAYREF). if ( $object->attribute_is_list("members") ) { $object->set_members( [$member] ); } else { $object->set_members( $member ); } =cut sub attribute_is_list { my $type = ref( $_[0] ) ? ref( $_[0] ) : $_[0]; return 1 if ( ref $nagios_setup{ $_[0]->setup_key }->{ $_[1] }[0] eq 'ARRAY' ); undef; } # ---------------------------------------------------------------------------- # # mostly these are only for use by other Nagios::Modules sub resolved { if ( $_[1] ) { $_[0]->{_has_been_resolved} = $_[1] } return $_[0]->{_has_been_resolved}; } sub registered { if ( $_[1] ) { $_[0]->{_has_been_registered} = $_[1] } return $_[0]->{_has_been_registered}; } sub validate_object_type { my $type = lc( ref( $_[1] ) ? ref( $_[1] ) : $_[1] ); $type =~ s/^nagios:://; my ($result) = grep {/^$type$/i} keys %nagios_setup; return defined $result ? "Nagios::$result" : undef; } sub list_valid_fields { my $type = ref( $_[0] ) ? ref(shift) : shift; $type =~ s/^Nagios:://; foreach my $key ( keys %nagios_setup ) { if ( lc $key eq lc $type ) { return keys %{ $nagios_setup{$key} }; } } return undef; } # ---------------------------------------------------------------------------- # # a validating set routine used by all of the autogenerated methods sub _set ($ $ $) { my ( $self, $key, $value ) = @_; croak "$key does not exist for this object ... template?" if ( !exists( $self->{$key} ) ); my $vf = $nagios_setup{ $self->setup_key }; if ( !$pre_link && !$fast_mode && exists $vf->{$key} ) { # validate passed in arugments against arrayref in $vf (\%valid_fields) $self->_validate( $key, $value, @{ $vf->{$key} } ); } # Nagios allows the usage of a '+' sign. This breaks member lists. # Ignore the '+' sign completely for now. if ( ref $vf->{$key}[0] eq 'ARRAY' && $value =~/^\+(.+)$/ ) { $value = $1; } if ( ref $vf->{$key}[0] eq 'ARRAY' && $value =~ /,/ ) { $value = [ split /\s*,\s*/, $value ]; } # set the value (which is an anonymous subroutine) if ( defined($value) ) { $self->{$key} = $value; } else { $self->{$key} = undef; } } # ---------------------------------------------------------------------------- # # verfiy that the type of an object is what it is supposed to be as specified # in the hash in BEGIN sub _validate { my ( $self, $key, $value, $type, $flags ) = @_; croak "$key is required but is ($value) undefined" if ( !defined $value && ( $flags & NAGIOS_NO_INHERIT ) == NAGIOS_NO_INHERIT ); return $value if ( !defined $value ); # types in an arrayref indicate that the value may be a list as well # lists may only be of single characters or objects for now if ( ref $type eq 'ARRAY' ) { # only 1 entry in $type list, so it's probably a class if ( @$type == 1 && $type->[0] =~ /^Nagios::.*$/ ) { # process single values as an arrayref anyways for consistency if ( ref($value) ne 'ARRAY' ) { $value = [$value] } foreach my $val (@$value) { croak "object isa '" . ref($val) . "' when it should be a '$type'" if ( ref($val) ne $type->[0] ); } } # all other list entries must be single character type - a,s,d,f style else { # map valid entries onto a hash for easy comparison my %possible = map { $_ => 1 } @$type; # autosplit if ( ref($value) ne 'ARRAY' ) { $value = [ split /,/, $value ]; } foreach my $v (@$value) { croak "\"$v\" is an invalid entry for $key" unless ( exists $possible{$v} ); } } } elsif ( $type =~ /^Nagios::.*$/ ) { croak "object isa '" . ref($value) . "' when it should be a '$type'" if ( ref($value) ne $type ); } elsif ( ref($value) eq 'ARRAY' && $type ne 'TIMERANGE' ) { croak "$key cannot have multiple " . ref($value) . " values."; } elsif ( $type eq 'BINARY' ) { confess "argument to set_$key must NOT be a reference" if ( ref($value) ); croak "$key must be 1 or 0" if ( $value != 0 && $value != 1 ); } elsif ( $type eq 'STRING' || $type eq 'INTEGER' ) { confess "argument to set_$key must NOT be a reference" if ( ref($value) ); croak "$key must have a length greater than 0" if ( length($value) < 1 ); croak "$key must be an INTEGER" if ( $type eq 'INTEGER' && $value =~ /[^\d]/ ); } elsif ( $type eq 'TIMERANGE' ) { croak "TIMERANGE must be an ARRAY refrerence" if ( ref($value) ne 'ARRAY' ); foreach my $rng (@$value) { croak "elements of TIMERANGE must be ARRAY refrerences" if ( ref($rng) ne 'ARRAY' ); croak "start/end times in ranges must be an integer of seconds" if ( $rng->[0] =~ /[^\d]/ || $rng->[1] =~ /[^\d]/ ); } } else { confess "invalid call to _validate"; } return $value; } # support "hostgroup" alongside "hostgroups" by piggybacking it sub hostgroup_name { my $self = shift; # Since this method is available in all objects, perform a check in # the config to see if its actually valid on the object (my $type = ref $self) =~ s/.*:://; if(!$nagios_setup{$type}{hostgroup_name}) { return; } if ( $self->can('hostgroup') ) { return $self->hostgroup(@_); } else { confess "Called hostgroup() on an object that doesn't support it."; } } sub set_hostgroup_name { my $self = shift; if ( $self->can('hostgroup') ) { my @existing = $self->hostgroup; return $self->set_hostgroup( [ @existing, shift ] ); } else { confess "Called set_hostgroup() on an object that doesn't support it."; } } # support shorthand "host" for "host_name" ... this is really annoying and # can probably also be automated, but for now it just needs to be fixed sub host { my $self = shift; if ( $self->can('host_name') ) { return $self->host_name(@_); } else { confess "Called host() on an object that doesn't support it."; } } sub set_host { my $self = shift; if ( $self->can('set_host_name') ) { return $self->set_host_name(@_); } else { confess "Called set_host() on an object that doesn't support it."; } } # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # # use %nagios_setup to create all of the known methods at compile time GENESIS: { no warnings; # this function can be called externally to create another object # type inside Nagios::Object with all the same capabilities as # those created at BEGIN - a hash like the one above will have # to be created and have the exact same name. It'll also have to # be a global within the namespace sub create_object_and_methods { my $object = shift; # create a package name my $pkg = 'Nagios::' . $object; # fill in @ISA for each class my $isa = do { \@{ $pkg . '::ISA' } }; push( @$isa, 'Nagios::Object' ); # save off this list of naming (think primary key) attributes # access them via method $obj->_name_attribute my $name_attr_list = $nagios_setup{$object}->{name}[0]; *{"$pkg\::_name_attribute"} = sub {$name_attr_list}; # create methods for each entry in $nagios_setup{$object} foreach my $method ( keys( %{ $nagios_setup{$object} } ) ) { # name() is a special case and is implemented by hand next if ( $method eq 'name' ); # the members() method in ServiceGroup is implemented manually (below) next if ( $pkg eq 'Nagios::ServiceGroup' && $method eq 'members' ); $pkg->_make_method($method); } *{"$pkg\::AUTOLOAD"} = \&Nagios::Object::AUTOLOAD; *{"$pkg\::DESTROY"} = sub { }; } # create methods on-the-fly sub _make_method { my ( $pkg, $method ) = @_; # create set_ method *{"$pkg\::set_$method"} = sub { shift->_set( $method, @_ ); }; # create get method *{"$pkg\::$method"} = sub { my $self = shift; my $value = $self->{$method}; if ( defined $value || $method eq 'use' ) { return $value; } else { my $template = $self->template; if ( $template && $template->can($method) ) { return $template->$method; } } return undef; }; # end of anonymous "get" subroutine } } sub DESTROY { } sub AUTOLOAD { our $AUTOLOAD; # this will break if there are ever more than 3 parts to a package name my ( $top, $setup_key, $method ) = split /::/, $AUTOLOAD; my $pkg = $top . '::' . $setup_key; my $setup_field = $method; if ( $method =~ /^set_(.*)$/ ) { $setup_field = $1; } if ( exists $nagios_setup{$setup_key}->{$setup_field} ) { $pkg->_make_method($setup_field); } else { confess "Invalid method call. $pkg does not know about method $method."; } goto \&{$AUTOLOAD}; } # ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- # # special-case methods coded straight into their packages 1; package Nagios::Host; our $VERSION = $Nagios::Object::VERSION; # aliases sub hostgroups { shift->hostgroup(@_); } sub set_hostgroups { shift->set_hostgroup(@_); } 1; package Nagios::HostGroup; our $VERSION = $Nagios::Object::VERSION; # aliases sub hostgroup { shift->hostgroup_name(@_); } sub set_hostgroup { shift->set_hostgroup_name(@_); } 1; package Nagios::ServiceGroup; use Carp; our $VERSION = $Nagios::Object::VERSION; sub members { my $self = shift; if ( $self->{members} ) { my @copy = @{ $self->{members} }; return \@copy; } else { return []; } } sub set_members { my $self = shift; my ( @objects, @members ); # @members will be an arrayref of [ host_name => service_description ] # or Service objects, depending on whether Nagios::Object::Config # has resolved yet if ( $self->resolved ) { foreach my $item (@_) { confess "set_members() arguments must be objects after resolve_objects() has been called." unless ( ref($item) ); push @members, $item; } } # also, before resolution, append to the list rather than replace it else { @members = @{ $self->{members} } if $self->{members}; foreach my $item (@_) { if ( ref($item) eq 'ARRAY' && @$item == 2 ) { push @members, $item; } elsif ( defined($item) && length($item) ) { push @members, $self->_split_members($item); } else { confess "Don't know what to do with a $item!"; } } } $self->{members} = \@members; } sub _split_members { my ( $self, $string ) = @_; my @out; my @pieces = split /\s*,\s*/, $string; for ( my $i = 0; $i < @pieces; $i += 2 ) { push @out, [ $pieces[$i] => $pieces[ $i + 1 ] ]; } #warn Data::Dumper::Dumper(\@out); return @out; } 1; package Nagios::Service; our $VERSION = $Nagios::Object::VERSION; 1; __END__ =back =head1 AUTHOR Al Tobey Thank you to the fine people of #perl on freenode.net for helping me with some hairy code and silly optimizations. =head1 WARNINGS See AUTHOR. =cut Nagios-Object-0.21.20/lib/Nagios/Config.pm000444001750001750 1363412220262237 21366 0ustar00dfergusondferguson000000000000########################################################################### # # # Nagios::Config # # Maintained by Duncan Ferguson # # Written by Albert Tobey # # Copyright 2003-2009, Albert P Tobey # # Copyright 2009, Albert P Tobey and Duncan Ferguson # # # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the # # Free Software Foundation; either version 2, or (at your option) any # # later version. # # # # This program is distributed in the hope that it will be useful, but # # WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # # General Public License for more details. # # # ########################################################################### package Nagios::Config; use warnings; use strict qw( subs vars ); use Carp; use Nagios::Object::Config; use Nagios::Config::File; use Nagios::Object qw(%nagios_setup); use Symbol qw(gensym); use File::Basename; @Nagios::Config::ISA = qw( Nagios::Object::Config Nagios::Config::File ); # NOTE: due to CPAN version checks this cannot currently be changed to a # standard version string, i.e. '0.21' our $VERSION = '36'; our $fast_mode = undef; =head1 NAME Nagios::Config - Parser for the Nagios::Object set of perl modules =head1 DESCRIPTION Ties all of the Nagios::Object modules together, doing all the parsing and background stuff so you don't have to. All of the methods of Nagios::Object::Config and Nagios::Config::File are inherited by this module. =head1 SYNOPSIS my $nagios_cfg = Nagios::Config->new( "nagios.cfg" ); my @host_objects = $nagios_cfg->list_hosts(); =head1 METHODS =over 4 =item new() Create a new Nagios::Config object, which will parse a Nagios main configuration file and all of it's object configuration files. The resource configuration file is not parsed - for that, use Nagios::Config::File. my $cf = Nagios::Config->new( Filename => $configfile ); my $cf = Nagios::Config->new( Filename => $configfile, Version => 1 ); my $cf = Nagios::Config->new( Filename => $configfile, Version => 2 ); =cut sub new { my $class = ref( $_[0] ) ? ref(shift) : shift; my $filename = undef; my $version = undef; my $allow_missing_files = undef; my $force_relative_files = undef; if ( @_ % 2 == 0 ) { my %args = (); for ( my $i = 0; $i <= @_ && defined $_[$i]; $i += 2 ) { $args{ lc $_[$i] } = $_[ $i + 1 ]; } if ( $args{filename} ) { $filename = $args{filename}; } if ( $args{version} ) { $version = $args{version}; } if ( $args{allow_missing_files} ) { $allow_missing_files = 1; } if ( $args{force_relative_files} ) { $force_relative_files = 1; } } else { croak "single argument form of new() no longer supported\n", "try Nagios::Config->new( Filename => \$file );"; } my $main_cfg = Nagios::Config::File->new($filename); my $obj_cfgs = Nagios::Object::Config->new( Version => $version ); # parse all object configuration files if ( my $files = $main_cfg->get('cfg_file') ) { foreach my $file (@$files) { if ($force_relative_files) { $file = _modpath( $filename, $file ); } next if ( $allow_missing_files && !-e $file ); $obj_cfgs->parse($file); } } # parse all files in cfg_dir(s) if ( my $dir = $main_cfg->get('cfg_dir') ) { my @dir_files = (); foreach my $cfgdir (@$dir) { recurse_dir( \@dir_files, $cfgdir ); } foreach my $file (@dir_files) { if ($force_relative_files) { $file = _modpath( $filename, $file ); } next if ( $allow_missing_files && !-e $file ); $obj_cfgs->parse($file); } } # set up the important parts of the Nagios::Config::File instance $obj_cfgs->{filename} = $filename; $obj_cfgs->{file_attributes} = $main_cfg->{file_attributes}; # resolve and register Nagios::Object tree if ( !$fast_mode ) { $obj_cfgs->resolve_objects(); $obj_cfgs->register_objects(); } else { warn "EXPERIMENTAL: possible breakage with fast_mode enabled"; } return bless $obj_cfgs, $class; } sub recurse_dir { my ( $file_list, $dir ) = @_; my $fh = gensym; opendir( $fh, $dir ); while ( my $file = readdir $fh ) { if ( !-d "$dir/$file" && $file =~ /\.cfg$/ ) { push( @$file_list, "$dir/$file" ); } elsif ( -d "$dir/$file" && $file !~ /^\./ && $file ne 'CVS' ) { recurse_dir( $file_list, "$dir/$file" ); } } } sub _modpath { my ( $main_cfg, $sub_cfg ) = @_; my $cfgfile = File::Basename::basename($sub_cfg); my $subdir = File::Basename::dirname($main_cfg); return $subdir . '/' . $cfgfile; } sub fast_mode { if ( $_[1] ) { $fast_mode = $_[1] } $Nagios::Object::fast_mode = $fast_mode; $Nagios::Object::Config::fast_mode = $fast_mode; return $fast_mode; } 1; __END__ =back =head1 AUTHOR Al Tobey =head1 SEE ALSO Nagios::Config::File, Nagios::Object::Config, Nagios::Object =cut Nagios-Object-0.21.20/lib/Nagios/StatusLog.pm000444001750001750 10353212220262237 22123 0ustar00dfergusondferguson000000000000########################################################################### # # # Nagios::StatusLog, Nagios::(Service|Host|Program)::Status # # Maintained by Duncan Ferguson # # Written by Albert Tobey # # Copyright 2003-2009, Albert P Tobey # # Copyright 2009, Albert P Tobey and Duncan Ferguson # # # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the # # Free Software Foundation; either version 2, or (at your option) any # # later version. # # # # This program is distributed in the hope that it will be useful, but # # WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # # General Public License for more details. # # # ########################################################################### package Nagios::StatusLog; use Carp; use strict qw( subs vars ); use warnings; use Symbol; use Scalar::Util; # NOTE: due to CPAN version checks this cannot currently be changed to a # standard version string, i.e. '0.21' our $VERSION = '45'; # this is going to be rewritten to use AUTOLOAD + method caching in a future version BEGIN { # first block of items is from Nagios v1, second is new stuff in Nagios v2 my %_tags = ( Service => [ qw( host_name description status current_attempt state_type last_check next_check check_type checks_enabled accept_passive_service_checks event_handler_enabled last_state_change problem_has_been_acknowledged last_hard_state time_ok time_unknown time_warning time_critical last_notification current_notification_number notifications_enabled latency execution_time flap_detection_enabled is_flapping percent_state_change scheduled_downtime_depth failure_prediction_enabled process_performance_data obsess_over_service plugin_output service_description modified_attributes check_command event_handler has_been_checked should_be_scheduled check_execution_time check_latency current_state max_attempts last_hard_state_change last_time_ok last_time_warning last_time_unknown last_time_critical performance_data next_notification no_more_notifications active_checks_enabled passive_checks_enabled acknowledgement_type last_update check_interval check_options check_period current_event_id current_notification_id current_problem_id last_event_id last_problem_id long_plugin_output notification_period retry_interval ) ], Host => [ qw( host_name status last_check last_state_change problem_has_been_acknowledged time_up time_down time_unreachable last_notification current_notification_number notifications_enabled event_handler_enabled checks_enabled flap_detection_enabled is_flapping percent_state_change scheduled_downtime_depth failure_prediction_enabled process_performance_data plugin_output modified_attributes check_command event_handler has_been_checked should_be_scheduled check_execution_time check_latency current_state last_hard_state check_type performance_data next_check current_attempt max_attempts state_type last_hard_state_change last_time_up last_time_down last_time_unreachable next_notification no_more_notifications acknowledgement_type active_checks_enabled passive_checks_enabled obsess_over_host last_update check_interval check_options check_period current_event_id current_notification_id current_problem_id last_event_id last_problem_id long_plugin_output notification_period retry_interval ) ], Program => [ qw( program_start nagios_pid daemon_mode last_command_check last_log_rotation enable_notifications execute_service_checks accept_passive_service_checks enable_event_handlers obsess_over_services enable_flap_detection enable_failure_prediction process_performance_data modified_host_attributes modified_service_attributes active_service_checks_enabled passive_service_checks_enabled active_host_checks_enabled passive_host_checks_enabled obsess_over_hosts check_service_freshness check_host_freshness global_host_event_handler global_service_event_handler active_ondemand_host_check_stats active_ondemand_service_check_stats active_scheduled_host_check_stats active_scheduled_service_check_stats cached_host_check_stats cached_service_check_stats external_command_stats high_external_command_buffer_slots next_comment_id next_downtime_id next_event_id next_notification_id next_problem_id parallel_host_check_stats passive_host_check_stats passive_service_check_stats serial_host_check_stats total_external_command_buffer_slots used_external_command_buffer_slots ) ], Contact => [ qw( contact_name modified_attributes modified_host_attributes modified_service_attributes host_notification_period service_notification_period last_host_notification last_service_notification host_notifications_enabled service_notifications_enabled ) ], Servicecomment => [ qw( host_name service_description entry_type comment_id source persistent entry_time expires expire_time author comment_data ) ], Hostcomment => [ qw( host_name entry_type comment_id source persistent entry_time expires expire_time author comment_data ) ], Servicedowntime => [ qw( host_name service_description downtime_id entry_time start_time end_time triggered_by fixed duration author comment ) ], Hostdowntime => [ qw( host_name downtime_id entry_time start_time end_time triggered_by fixed duration author comment ) ], Info => [qw( created version )] ); GENESIS: { no warnings; # create the Nagios::*::Status packages at compile time foreach my $key ( keys(%_tags) ) { my $pkg = 'Nagios::' . $key . '::Status::'; # store the list of tags for this package to access later do { ${"${pkg}tags"} = $_tags{$key} }; # modify @ISA for each class my $isa = do { \@{"${pkg}ISA"} }; push( @$isa, 'Nagios::StatusLog' ); foreach my $method ( @{ $_tags{$key} } ) { # the manually implemented status method is described below *{"$pkg$method"} = sub { $_[0]->{$method} } unless $method eq 'status'; } } } } =head1 NAME Nagios::StatusLog, Nagios::(Service|Host|Program)::Status - Perl objects to represent the Nagios status file =head1 DESCRIPTION Reads the Nagios status log and returns ::Status objects that can be used to get status information about a host. For Nagios version 2.x logs, pass in the Version => 2.0 parameter to new(). And similarly, pass in the Version => 3.0 parameter to new() for Nagios version 3.x logs. my $log = Nagios::StatusLog->new( Filename => "/var/opt/nagios/status.log", Version => 1.0 ); $localhost = $log->host( "localhost" ); print "status of localhost is now ",$localhost->status(),"\n"; $log->update(); print "status of localhost is now ",$localhost->status(),"\n"; # for Nagios v2.0 my $log = Nagios::StatusLog->new( Filename => "/var/opt/nagios/status.dat", Version => 2.0 ); # for Nagios v3.0 my $log = Nagios::StatusLog->new( Filename => "/var/opt/nagios/status.dat", Version => 3.0 ); =head1 METHODS =over 4 =item new() Create a new Nagios::StatusLog instance. The object will be initialized for you (using $self->update()). Nagios::StatusLog->new( "/var/opt/nagios/status.log" ); =cut sub new { my $type = shift; my $logfile = $_[0] if ( @_ == 1 ); my $version = 1; if ( @_ % 2 == 0 ) { my %args = @_; while ( my ( $param, $value ) = each %args ) { if ( lc $param eq 'filename' ) { $logfile = $value; } elsif ( lc $param eq 'version' ) { $version = int($value); } } } if ( !defined($logfile) || !-r $logfile ) { die "could not open $logfile for reading: $!"; } my $self = bless( { LOGFILE => $logfile, VERSION => $version, INFO => {}, CONTACT => {}, PROGRAM => {}, HOST => {}, HOSTCOMMENT => {}, HOSTDOWNTIME => {}, SERVICE => {}, SERVICECOMMENT => {}, SERVICEDOWNTIME => {} }, $type ); $self->update(); return $self; } =item update() Updates the internal data structures from the logfile. $log->update(); =cut sub update { my $self = shift; if ( $self->{VERSION} >= 3 ) { return $self->update_v3(@_); } if ( $self->{VERSION} == 2 ) { return $self->update_v2(@_); } return $self->update_v1(@_); } sub update_v1 ($) { my $self = shift; # break the line down into a hash, return a reference sub hashline ($ $ $) { my ( $line, $no, $ar ) = @_; my @parts = split( /;/, $$line, $no + 1 ); # create the hash using the constant array (defined at top # of this file) and the split line my %data = map { $ar->[$_] => $parts[$_] } 0 .. $no; return \%data; } my $log_fh = gensym; open( $log_fh, "<$self->{LOGFILE}" ) || croak "could not open file $self->{LOGFILE} for reading: $!"; my @LOG = <$log_fh>; close($log_fh); for ( my $i = 0; $i < @LOG; $i++ ) { chomp( $LOG[$i] ); $LOG[$i] =~ s/#.*$//; next if ( !defined( $LOG[$i] ) || !length( $LOG[$i] ) ); $LOG[$i] =~ m/^(\[\d+])\s+([A-Z]+);(.*)$/; my ( $ts, $type, $line ) = ( $1, $2, $3 ); # set some variables to switch between SERVICES|HOST|PROGRAM # $no must be the number of elements - 1 (because arrays start on 0) my ( $ldata, $ref ) = ( {}, undef ); if ( $type eq 'SERVICE' ) { # let the hashline() function do the work of creating the hashref $ldata = hashline( \$line, 30, Nagios::Service::Status->list_tags() ); # if it already exists, we'll copy data after this if/else tree if (!exists( $self->{$type}{ $ldata->{host_name} } { $ldata->{description} } ) ) { $self->{$type}{ $ldata->{host_name} }{ $ldata->{description} } = $ldata; } # 1st time we've seen this combination, use the new svc hashref else { $ref = $self->{$type}{ $ldata->{host_name} } { $ldata->{description} }; } } elsif ( $type eq 'HOST' ) { $ldata = hashline( \$line, 19, Nagios::Host::Status->list_tags() ); if ( !exists( $self->{$type}{ $ldata->{host_name} } ) ) { $self->{$type}{ $ldata->{host_name} } = $ldata; } else { $ref = $self->{$type}{ $ldata->{host_name} }; } } elsif ( $type eq 'PROGRAM' ) { $ldata = hashline( \$line, 12, Nagios::Program::Status->list_tags() ); if ( !defined( $self->{$type} ) ) { $self->{$type} = $ldata; } else { $ref = $self->{$type}; } } else { croak "unknown tag ($type) in logfile"; } # update existing data without changing the location the reference points to if ( defined($ref) ) { foreach my $key ( keys(%$ldata) ) { $ref->{$key} = $ldata->{$key}; } } } 1; } # be compatible with StatusLog which makes sure that references # held in client code remain valid during update (also prevents # some memory leaks) sub _copy { %{ $_[1] } = %{ $_[0] }; } sub update_v2 ($) { my $self = shift; my %handlers = ( host => sub { my $item = shift; my $host = $item->{host_name}; if ( !exists $self->{HOST}{$host} ) { $self->{HOST}{$host} = {}; } _copy( $item, $self->{HOST}{$host} ); }, service => sub { my $item = shift; my $host = $item->{host_name}; my $svc = $item->{service_description}; if ( !exists $self->{SERVICE}{$host}{$svc} ) { $self->{SERVICE}{$host}{$svc} = {}; } _copy( $item, $self->{SERVICE}{$host}{$svc} ); }, info => sub { _copy( shift, $self->{INFO} ); }, program => sub { _copy( shift, $self->{PROGRAM} ); } ); my $log_fh = gensym; open( $log_fh, "<$self->{LOGFILE}" ) || croak "could not open file $self->{LOGFILE} for reading: $!"; # change the first line of the RE to this: # (info|program|host|service) \s* {( # to make it a bit more careful, but it has a measurable cost on runtime my $entry_re = qr/ # capture the type into $1 (\w+) \s* # capture all of the text between the brackets into $2 {( .*? )} /xs; my @lines = <$log_fh>; my $file = "@lines"; #Drop comments if we don't need them as it should speed things up a little bit. #Comment out the line below if you do want to keep comments $file =~ s/#.*\n//mg; $file =~ s/[\r\n]+\s*/\n/g; # clean up whitespace and newlines while ( $file =~ /$entry_re/g ) { ( my $type, my $text ) = ( $1, $2 ); my %item = map { split /\s*=\s*/, $_, 2 } split /\n/, $text; $handlers{$type}->( \%item ); } close($log_fh); 1; } sub update_v3 ($) { my $self = shift; my %handlers = ( hoststatus => sub { my $item = shift; my $host = $item->{host_name}; if ( !exists $self->{HOST}{$host} ) { $self->{HOST}{$host} = {}; } _copy( $item, $self->{HOST}{$host} ); }, servicestatus => sub { my $item = shift; my $host = $item->{host_name}; my $svc = $item->{service_description}; if ( !exists $self->{SERVICE}{$host}{$svc} ) { $self->{SERVICE}{$host}{$svc} = {}; } _copy( $item, $self->{SERVICE}{$host}{$svc} ); }, contactstatus => sub { my $item = shift; my $contact = $item->{contact_name}; if ( !exists $self->{CONTACT}{$contact} ) { $self->{CONTACT}{$contact} = {}; } _copy( $item, $self->{CONTACT}{$contact} ); }, info => sub { _copy( shift, $self->{INFO} ); }, programstatus => sub { _copy( shift, $self->{PROGRAM} ); }, # Hosts & services can each have multiple comments & downtime, distinguished only by their Id: servicecomment => sub { my $item = shift; my $host = $item->{host_name}; my $svc = $item->{service_description}; my $id = $item->{comment_id}; if ( !exists $self->{SERVICECOMMENT}{$host}{$svc}{$id} ) { $self->{SERVICECOMMENT}{$host}{$svc}{$id} = {}; } _copy( $item, $self->{SERVICECOMMENT}{$host}{$svc}{$id} ); }, hostcomment => sub { my $item = shift; my $host = $item->{host_name}; my $id = $item->{comment_id}; if ( !exists $self->{HOSTCOMMENT}{$host}{$id} ) { $self->{HOSTCOMMENT}{$host}{$id} = {}; } _copy( $item, $self->{HOSTCOMMENT}{$host}{$id} ); }, servicedowntime => sub { my $item = shift; my $host = $item->{host_name}; my $svc = $item->{service_description}; my $id = $item->{downtime_id}; if ( !exists $self->{SERVICEDOWNTIME}{$host}{$svc}{$id} ) { $self->{SERVICEDOWNTIME}{$host}{$svc}{$id} = {}; } _copy( $item, $self->{SERVICEDOWNTIME}{$host}{$svc}{$id} ); }, hostdowntime => sub { my $item = shift; my $host = $item->{host_name}; my $id = $item->{downtime_id}; if ( !exists $self->{HOSTDOWNTIME}{$host}{$id} ) { $self->{HOSTDOWNTIME}{$host}{$id} = {}; } _copy( $item, $self->{HOSTDOWNTIME}{$host}{$id} ); }, ); my $log_fh = gensym; open( $log_fh, "<$self->{LOGFILE}" ) || croak "could not open file $self->{LOGFILE} for reading: $!"; my %valid_types = map { ( $_ => 1 ) } qw(info programstatus hoststatus servicestatus contactstatus servicecomment hostcomment servicedowntime hostdowntime); my $entry = ''; my %attributes; my $type = 0; while ( my $line = <$log_fh> ) { next if ( $line =~ /^\s*#|^\s*$/ ); if ( $line =~ /\s*(\w+)=(.*)$/ ) { $attributes{$1} = $2; } elsif ( $line =~ /^\s*(\w+)\s*{\s*$/ ) { %attributes = (); if ( exists $valid_types{$1} ) { $type = $1; } else { $type = 0; } } elsif ( $line =~ /^\s*}\s*$/ ) { # Only save the object if it is a valid type if ($type) { $handlers{$type}->( \%attributes ); } } } close($log_fh); 1; } sub list_tags { my $type = ref( $_[0] ) ? ref( $_[0] ) : $_[0]; my $listref = ${"$type\::tags"}; return wantarray ? @$listref : $listref; } =item service() Returns a Nagios::Service::Status object. Input arguments can be a host_name and description list, or a Nagios::Service object. my $svc_stat = $log->service( "localhost", "SSH" ); my $svc_stat = $log->service( $localhost_ssh_svc_object ); Nagios::Service::Status has the following accessor methods (For V1): host_name description status current_attempt state_type last_check next_check check_type checks_enabled accept_passive_service_checks event_handler_enabled last_state_change problem_has_been_acknowledged last_hard_state time_ok current_notification_number time_warning time_critical process_performance_data notifications_enabled latency scheduled_downtime_depth is_flapping plugin_output percent_state_change execution_time time_unknown failure_prediction_enabled last_notification obsess_over_service flap_detection_enabled =cut sub service { my ( $self, $host, $service ) = @_; if ( ref($host) eq 'Nagios::Host' ) { $host = $host->host_name; } # allow just a service to be passed in if ( ref($host) eq 'Nagios::Service' ) { $service = $host; $host = $service->host_name; } if ( ref($service) eq 'Nagios::Service' ) { $service = $service->service_description; } confess "host \"$host\" does not seem to be valid" if ( !$self->{SERVICE}{$host} ); confess "service \"$service\" does not seem to be valid on host \"$host\"" if ( !$self->{SERVICE}{$host}{$service} ); $self->{SERVICE}{$host}{$service}{__parent} = $self; Scalar::Util::weaken($self->{SERVICE}{$host}{$service}{__parent}); bless( $self->{SERVICE}{$host}{$service}, 'Nagios::Service::Status' ); } =item list_services() Returns an array of all service descriptions in the status log. Services that may be listed on more than one host are only listed once here. my @all_services = $log->list_services; =cut sub list_services { my $self = shift; my %list = (); foreach my $host ( keys %{ $self->{SERVICE} } ) { foreach my $service ( keys %{ $self->{SERVICE}{$host} } ) { $list{$service} = 1; } } return keys %list; } =item list_services_on_host() Returns an array of services descriptions for a given host. my @host_services = $log->list_services_on_host($hostname); my @host_services = $log->list_services_on_host($nagios_object); =cut sub list_services_on_host { my ( $self, $host ) = @_; if ( ref($host) && UNIVERSAL::can( $host, 'host_name' ) ) { $host = $host->host_name; } return keys %{ $self->{SERVICE}{$host} }; } =item serviceproblems() Returns a hash of all services that are not in an OK state my %serviceproblems = $log->serviceproblems(); =cut sub serviceproblems { my ( $self, $host, $service ) = @_; my %list = (); $self->{SERVICE}{$host}{$service}{__parent} = $self; Scalar::Util::weaken($self->{SERVICE}{$host}{$service}{__parent}); foreach my $host ( keys %{ $self->{SERVICE} } ) { foreach my $service ( keys %{ $self->{SERVICE}{$host} } ) { $list{$host}{$service} = $self->{SERVICE}{$host}{$service} unless $self->{SERVICE}{$host}{$service}{current_state} == 0; } } return %list; } =item host() Returns a Nagios::Host::Status object. Input can be a simple host_name, a Nagios::Host object, or a Nagios::Service object. my $hst_stat = $log->host( 'localhost' ); my $hst_stat = $log->host( $host_object ); my $hst_stat = $log->host( $svc_object ); Nagios::Host::Status has the following accessor methods (for V1): host_name status last_check last_state_change problem_has_been_acknowledged time_up time_down time_unreachable last_notification current_notification_number notifications_enabled event_handler_enabled checks_enabled flap_detection_enabled is_flapping percent_state_change scheduled_downtime_depth failure_prediction_enabled process_performance_data plugin_output =cut sub host { my ( $self, $host ) = @_; if ( ref($host) =~ /^Nagios::(Host|Service)$/ ) { $host = $host->host_name; } confess "host \"$host\" does not seem to be valid" if ( !$self->{HOST}{$host} ); $self->{HOST}{$host}{__parent} = $self; Scalar::Util::weaken($self->{HOST}{$host}{__parent}); bless( $self->{HOST}{$host}, 'Nagios::Host::Status' ); } =item list_hosts() Returns a simple array of host names (no objects). my @hosts = $log->list_hosts; =cut sub list_hosts { keys %{ $_[0]->{HOST} }; } =item list_hostdowntime() Returns a simple array of host downtimes (no objects) my @hostdowntimes = $log->list_hostdowntime; =cut sub list_hostdowntime { keys %{ $_[0]->{HOSTDOWNTIME} }; } =item info() [Nagios v2 & v3 logs only] Returns a Nagios::Info::Status object. It only has two methods, created() and version(). my $i = $log->info; printf "Logfile created at %s unix epoch time for Nagios verion %s\n", $i->created, $i->version; =cut sub info { my $self = shift; return bless $self->{INFO}, 'Nagios::Info::Status'; } =item contact() [Nagios v3 logs only] Returns a Nagios::Contact::Status object. Input can be a simple contact_name, or a Nagios::Contact object. my $c = $log->contact( 'john' ); my $c = $log->contact( $contact_object ); Nagios::Contact::Status has the following accessor methods (for v3): contact_name modified_attributes modified_host_attributes modified_service_attributes host_notification_period service_notification_period last_host_notification last_service_notification host_notifications_enabled service_notifications_enabled =cut sub contact { my ( $self, $name ) = @_; $name = $name->contact_name if ( ref($name) eq 'Nagios::Contact' ); return undef if ( !$self->{CONTACT}{$name} ); bless( $self->{CONTACT}{$name}, 'Nagios::Contact::Status' ); } =item hostcomment() [Nagios v3 logs only] Returns a Nagios::Hostcomment::Status object. Input can be a simple host_name, or a Nagios::Host or Nagios::Service object. my $c = $log->hostcomment( 'localhost' ); my $c = $log->hostcomment( $localhost_object ); my $c = $log->hostcomment( $localhost_service_object ); foreach my $id (sort keys %$c) { printf "Host %s has a comment[$id] made by %s on %s: %s", $c->{$id}->host_name, $c->{$id}->author, scalar localtime $c->{$id}->entry_time, $c->{$id}->comment_data; } Nagios::Hostcomment::Status is a perl HASH, keyed with the Nagios comment IDs, where each ID has the following accessor methods (for v3): host_name entry_type comment_id source persistent entry_time expires expire_time author comment_data =cut sub hostcomment { my ( $self, $host ) = @_; $host = $host->host_name if ( ref($host) =~ /^Nagios::(Host|Service)$/ ); return undef if ( !$self->{HOSTCOMMENT}{$host} ); foreach my $id ( keys %{ $self->{HOSTCOMMENT}{$host} } ) { bless( $self->{HOSTCOMMENT}{$host}{$id}, 'Nagios::Hostcomment::Status' ); } return $self->{HOSTCOMMENT}{$host}; } =item servicecomment() [Nagios v3 logs only] Returns a Nagios::Servicecomment::Status object. Input can be a simple host_name or Nagios::Host object with a service description or Nagios::Service object, or just a Nagios::Service object by itself. my $c = $log->servicecomment( 'localhost', 'SSH' ); my $c = $log->servicecomment( $localhost_object, $localhost_ssh_svc_object ); my $c = $log->servicecomment( $localhost_ssh_svc_object ); foreach my $id (sort keys %$c) { printf "Service %s on %s has a comment[$id] made by %s on %s: %s", $c->{$id}->service_description, $c->{$id}->host_name, $c->{$id}->author, scalar localtime $c->{$id}->entry_time, $c->{$id}->comment_data; } Nagios::Servicecomment::Status is a perl HASH, keyed with the Nagios comment IDs, where each ID has the following accessor methods (for v3): host_name service_description entry_type comment_id source persistent entry_time expires expire_time author comment_data =cut sub servicecomment { my ( $self, $host, $service ) = @_; $host = $host->host_name if ( ref($host) eq 'Nagios::Host' ); # allow just a service to be passed in if ( ref($host) eq 'Nagios::Service' ) { $service = $host; $host = $service->host_name; } $service = $service->service_description if ( ref($service) eq 'Nagios::Service' ); return undef if ( !$host || !$service || !$self->{SERVICECOMMENT}{$host}{$service} ); foreach my $id ( keys %{ $self->{SERVICECOMMENT}{$host}{$service} } ) { bless( $self->{SERVICECOMMENT}{$host}{$service}{$id}, 'Nagios::Servicecomment::Status' ); } return $self->{SERVICECOMMENT}{$host}{$service}; } =item hostdowntime() [Nagios v3 logs only] Returns a Nagios::Hostdowntime::Status object. Input can be a simple host_name, or a Nagios::Host or Nagios::Service object. my $d = $log->hostdowntime( 'localhost' ); my $d = $log->hostdowntime( $localhost_object ); my $d = $log->hostdowntime( $localhost_service_object ); foreach my $id (sort keys %$d) { printf "Host %s has scheduled downtime[$id] made by %s on %s for %.1f hours [%s - %s]: %s", $d->{$id}->host_name, $d->{$id}->author, scalar localtime $d->{$id}->entry_time, ($d->{$id}->duration)/3600.0, scalar localtime $d->{$id}->start_time, scalar localtime $d->{$id}->end_time, $d->{$id}->comment; } Nagios::Hostdowntime::Status is a perl HASH, keyed with the Nagios downtime IDs, where each ID has the following accessor methods (for v3): host_name downtime_id entry_time start_time end_time triggered_by fixed duration author comment =cut sub hostdowntime { my ( $self, $host ) = @_; $host = $host->host_name if ( ref($host) =~ /^Nagios::(Host|Service)$/ ); return undef if ( !$self->{HOSTDOWNTIME}{$host} ); foreach my $id ( keys %{ $self->{HOSTDOWNTIME}{$host} } ) { bless( $self->{HOSTDOWNTIME}{$host}{$id}, 'Nagios::Hostdowntime::Status' ); } return $self->{HOSTDOWNTIME}{$host}; } =item servicedowntime() [Nagios v3 logs only] Returns a Nagios::Servicedowntime::Status object. Input can be a simple host_name or Nagios::Host object with a service description or Nagios::Service object, or just a Nagios::Service object by itself. my $c = $log->servicedowntime( 'localhost', 'SSH' ); my $c = $log->servicedowntime( $localhost_object, $localhost_ssh_svc_object ); my $c = $log->servicedowntime( $localhost_ssh_svc_object ); foreach my $id (sort keys %$d) { printf "Service %s on %s has scheduled downtime[$id] made by %s on %s for %.1f hours [%s - %s]: %s", $d->{$id}->service_description, $d->{$id}->host_name, $d->{$id}->author, scalar localtime $d->{$id}->entry_time, ($d->{$id}->duration)/3600.0, scalar localtime $d->{$id}->start_time, scalar localtime $d->{$id}->end_time, $d->{$id}->comment; } Nagios::Servicedowntime::Status is a perl HASH, keyed with the Nagios downtime IDs, where each ID has the following accessor methods (for v3): host_name service_description downtime_id entry_time start_time end_time triggered_by fixed duration author comment =cut sub servicedowntime { my ( $self, $host, $service ) = @_; $host = $host->host_name if ( ref($host) eq 'Nagios::Host' ); # allow just a service to be passed in if ( ref($host) eq 'Nagios::Service' ) { $service = $host; $host = $service->host_name; } $service = $service->service_description if ( ref($service) eq 'Nagios::Service' ); return undef if ( !$self->{SERVICEDOWNTIME}{$host}{$service} ); foreach my $id ( keys %{ $self->{SERVICEDOWNTIME}{$host}{$service} } ) { bless( $self->{SERVICEDOWNTIME}{$host}{$service}{$id}, 'Nagios::Servicedowntime::Status' ); } return $self->{SERVICEDOWNTIME}{$host}{$service}; } =item program() Returns a Nagios::Program::Status object. No arguments. my $prog_st = $log->program; Nagios::Program::Status has the following accessor methods (For V1): program_start nagios_pid daemon_mode last_command_check last_log_rotation enable_notifications execute_service_checks accept_passive_service_checks enable_event_handlers obsess_over_services enable_flap_detection enable_failure_prediction process_performance_data =cut sub program ($) { bless( $_[0]->{PROGRAM}, 'Nagios::Program::Status' ); } sub write { my ( $self, $filename ) = @_; my $ts = time; my $fh = gensym; open( $fh, ">$filename" ) || die "could not open file \"$filename\" for writing: $!"; print $fh, "[$ts] PROGRAM;", Nagios::Program::Status->csvline( $self->{PROGRAM} ), "\n"; foreach my $host ( keys %{ $self->{HOST} } ) { print $fh "[$ts] HOST;", Nagios::Host::Status->csvline( $self->{HOST}{$host} ), "\n"; } foreach my $host ( keys %{ $self->{SERVICE} } ) { foreach my $svc ( keys %{ $self->{SERVICE}{$host} } ) { my $ref = $self->{SERVICE}{$host}{$svc}; print $fh "[$ts] SERVICE;", Nagios::Service::Status->csvline($ref), "\n"; } } close($fh); } sub csvline { my $self = shift; my $data = shift || $self; join( ';', map { $data->{$_} } ( $self->list_tags ) ); } =back =head1 STRUCTURE This module contains 4 packages: Nagios::StatusLog, Nagios::Host::Status, Nagios::Service::Status, and Nagios::Program::Status. The latter 3 of them are mostly generated at compile-time in the BEGIN block. The accessor methods are real subroutines, not AUTOLOAD, so making a ton of calls to this module should be fairly quick. Also, update() is set up to only do what it says - updating from a fresh logfile should not invalidate your existing ::Status objects. =head1 AUTHOR Al Tobey =head1 SEE ALSO Nagios::Host Nagios::Service =cut package Nagios::Service::Status; our $VERSION = '0.1'; # Nagios 2.x has current_state instead of status, but since anybody # using this module is probably using status and does not want to # mess around with converting the integer, this method wraps it up # to return like Nagios 1.x did. sub status { my $self = shift; if ( $self->{__parent}{VERSION} > 1.9999999 ) { if ( $self->{current_state} == 0 ) { if ( $self->{has_been_checked} == 0 ) { return 'PENDING'; } else { return 'OK'; } } elsif ( $self->{current_state} == 1 ) { return 'WARNING'; } elsif ( $self->{current_state} == 2 ) { return 'CRITICAL'; } elsif ( $self->{current_state} == 3 ) { return 'UNKNOWN'; } else { return "Unknown Status '$self->{current_state}'"; } } else { return $self->{status}; } } package Nagios::Host::Status; our $VERSION = '0.1'; # same deal as Nagios::Service::Status::status() sub status { my $self = shift; if ( $self->{__parent}{VERSION} > 1.9999999 ) { if ( $self->{current_state} == 0 ) { if ( $self->{has_been_checked} == 0 ) { return 'PENDING'; } else { return 'OK'; } } elsif ( $self->{current_state} == 1 ) { return 'DOWN'; } elsif ( $self->{current_state} == 2 ) { return 'UNREACHABLE'; } else { return "Unknown Status '$self->{current_state}'"; } } else { return $self->{status}; } } package Nagios::Program::Status; our $VERSION = '0.1'; package Nagios::Info::Status; our $VERSION = '0.1'; 1; Nagios-Object-0.21.20/lib/Nagios/Object000755001750001750 012220262237 20645 5ustar00dfergusondferguson000000000000Nagios-Object-0.21.20/lib/Nagios/Object/Config.pm000444001750001750 7765112220262237 22605 0ustar00dfergusondferguson000000000000########################################################################### # # # Nagios::Object::Config # # Maintained by Duncan Ferguson # # Written by Albert Tobey # # Copyright 2003-2009, Albert P Tobey # # Copyright 2009, Albert P Tobey and Duncan Ferguson # # # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the # # Free Software Foundation; either version 2, or (at your option) any # # later version. # # # # This program is distributed in the hope that it will be useful, but # # WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # # General Public License for more details. # # # ########################################################################### package Nagios::Object::Config; use strict; use warnings; use Nagios::Object qw(:all %nagios_setup); use Scalar::Util qw(blessed); use File::Basename qw(dirname); use File::Find qw(find); use Symbol; use Carp; # NOTE: due to CPAN version checks this cannot currently be changed to a # standard version string, i.e. '0.21' our $VERSION = '41'; our $fast_mode = undef; our $strict_mode = undef; =head1 NAME Nagios::Object::Config - Perl objects to represent Nagios configuration =head1 DESCRIPTION This is a module for parsing and processing Nagios object configuration files into perl objects. =head1 METHODS =over 4 =item new() Create a new configuration object. If Version is not specified, the already weak validation will be weakened further to allow mixing of Nagios 1.0 and 2.0 configurations. For now, the minor numbers of Version are ignored. Do not specify any letters as in '2.0a1'. To enable regular expression matching, use either the "regexp_matching" or "true_regexp_matching" arguments to new(). See enable_regexp_matching() and enable_true_regexp_matching() below. my $objects = Nagios::Object::Config->new(); my $objects = Nagios::Object::Config->new( Version => 1.2 ); my $objects = Nagios::Object::Config->new( Version => 2.0, regexp_matching => 1, true_regexp_matching => 2 ); =cut sub new { my $class = ref( $_[0] ) ? ref(shift) : shift; my $self = { regexp_matching => undef, true_regexp_matching => undef, config_files => [] }; # initialize lists and indexes e.g. host_list, command_index, etc. foreach my $class ( keys %nagios_setup ) { $self->{ lc($class) . '_list' } = []; $self->{ lc($class) . '_index' } = {}; } # parse arguments passed in if ( @_ % 2 == 0 ) { my %args = (); for ( my $i = 0; $i < @_; $i += 2 ) { $args{ lc $_[$i] } = $_[ $i + 1 ]; } # set up limited Nagios v1/v2 validation if ( !$fast_mode && $args{version} ) { if ( $args{version} >= 2 ) { $self->{nagios_version} = NAGIOS_V2; # remove keys from nagios_setup that are invalid for V2 foreach my $key ( keys %nagios_setup ) { if ( ( $nagios_setup{$key}->{use}[1] & NAGIOS_V1_ONLY ) == NAGIOS_V1_ONLY ) { delete $nagios_setup{$key}; } } } elsif ( $args{version} < 2 ) { $self->{nagios_version} = NAGIOS_V1; # remove keys from nagios_setup that are invalid for V1 foreach my $key ( keys %nagios_setup ) { if ( ( $nagios_setup{$key}->{use}[1] & NAGIOS_V2 ) == NAGIOS_V2 ) { delete $nagios_setup{$key}; } } } } else { $self->{nagios_version} = undef; } if ( $args{regexp_matching} ) { $self->{_regexp_matching_enabled} = 1; } elsif ( $args{true_regexp_matching} ) { $self->{_regexp_matching_enabled} = 1; $self->{_true_regexp_matching_enabled} = 1; } } else { croak "Single argument form of this constructor is not supported.\n", "Try: Nagios::Object::Config->new( Version => 2 );"; } return bless( $self, $class ); } sub fast_mode { if ( $_[1] ) { $fast_mode = $_[1] } return $fast_mode; } sub strict_mode { if ( $_[1] ) { $strict_mode = $_[1] } return $strict_mode; } =item parse() Parse a nagios object configuration file into memory. Although Nagios::Objects will be created, they are not really usable until the register() method is called. $parser->parse( "myfile.cfg" ); =cut # TODO: add checks for undefined values where prohibited in %nagios_setup # Note: many things that look a little inefficient or weird can probably # be traced back to the C source for Nagios, since the original parser # was a perl-ized version of that code. I'm (tobeya) working on a new # one that should be faster and more tolerant of broken configs, but it # needs a lot of testing before going to CPAN. sub parse { my ( $self, $filename ) = @_; $Nagios::Object::pre_link = 1; my $fh = gensym(); open( $fh, "<$filename" ) || croak "could not open $filename for reading: $!"; our $line_no = 0; my $dirname = dirname($filename); sub strippedline { $line_no++; return undef if ( eof( $_[0] ) ); my $line = readline( $_[0] ); $line =~ s/[\r\n\s]+$//; # remove trailing whitespace and CRLF $line =~ s/^\s+//; # remove leading whitespace return ' ' if ( $line =~ /^[#;]/ ); # skip/delete comments return $line || ' '; # empty lines are a single space } my ( $append, $type, $current, $in_definition ) = ( '', '', {}, undef ); while ( my $line = strippedline($fh) ) { # append saved text to the current line if ($append) { $line = '' unless $line; if ( $append !~ / $/ && $line !~ /^ / ) { $append .= ' ' } $line = $append . $line; $append = undef; } if ( $line && $line =~ /\\$/ ) { #Continued line (ends in a '\') #Remove \, append to $append, and let next iteration handle it $line =~ s/\s*\\$//; $append = $line; next; } # skip empty lines (don't do earlier because may get stuff prepended) next if ( $line eq ' ' ); if ( $line =~ /(include|cfg)_file\s*=\s*([\w\-\/\\\:\.]+)/ ) { my $incfile = $2; $self->parse("$dirname/$incfile") if -f "$dirname/$incfile"; next; } if ( $line =~ /(include|cfg)_dir\s*=\s*([\w\-\/\\\:\.]+)/ ) { my $incdir = $2; find(sub { $self->parse($_) if ($_=~/\.cfg$/ && -f $_); }, "$dirname/$incdir") if -d "$dirname/$incdir"; next; } # end of object definition # Some object attributes are strings, which can contain a right-curly bracket and confuse this parser: # - The proper fix would be to make the parser sensitive to arbitrary string attributes, but I will just # do it the easy way for now and assume there is no more text on the same line after the right-curly # bracket that closes the object definition. #if ( $line =~ /}(.*)$/ ) { if ( $line =~ /}(\s*)$/ ) { $in_definition = undef; # continue parsing after closing object with text following the '}' $append = $1; next; } # beginning of object definition elsif ( $line =~ /define\s+(\w+)\s*{?(.*)$/ ) { $type = $1; if ($in_definition) { croak "Error: Unexpected start of object definition in file " . "'$filename' on line $line_no. Make sure you close " . "preceding objects before starting a new one.\n"; } elsif ( !Nagios::Object->validate_object_type($type) ) { croak "Error: Invalid object definition type '$type' in file '$filename' on line $line_no.\n"; } else { $current = Nagios::Object->new( Type => Nagios::Object->validate_object_type($type) ); push( @{ $self->{ $type . '_list' } }, $current ); $in_definition = 1; $append = $2; # save a reference to this Nagios::Object::Config for later use # outside this module (it's needed for accessing the big linked data # structure) $current->{object_config_object} = $self; next; } } # save whatever's left in the buffer for the next iteration elsif ( !$in_definition ) { $append = $line; next; } # this is an attribute inside an object definition elsif ($in_definition) { $line =~ s/\s*;(.*)$//; my $comment = $1; # the comment stripped off of $line is saved in $1 due to the () # around .*, so it's saved in the object if supported if ( !$fast_mode && $1 && $current->can('set_comment') ) { $current->set_comment($comment); } my ( $key, $val ) = split( /\s+/, $line, 2 ); my $set_method = 'set_' . $key; if ( $current->can($set_method) ) { # Put back the comment if we have a notes key. $val .= ';' . $comment if ( $key eq 'notes' && defined $comment ); $current->$set_method($val); } elsif ($strict_mode) { confess "Invalid attribute: \"$key\". Could not find " . ref($current) . "::$set_method. Try disabling strict_mode? (see: perldoc Nagios::Object::Config)"; } # fall back to simple scalar storage with even less verification # - this is the bit that lets me slack off between Nagios releases # because it'll let new options "just work" for most cases - the # rest can send in bug reports, rather than the majority else { $nagios_setup{ $current->setup_key }->{$key} = [ 'STRING', 0 ]; $current->{$key} = $val; } # Add to the find_object search hash. if ( $key eq 'name' || $key eq $nagios_setup{ $current->setup_key }->{'name'}[0] ) { push( @{ $self->{ lc($current->setup_key) . '_index' }->{$val} }, $current ); } } else { croak "Error: Unexpected token in file '$filename' on line $line_no.\n"; } } if ($in_definition) { croak "Error: Unexpected EOF in file '$filename' on line $line_no - check for a missing closing bracket.\n"; } close($fh); return 1; } =item find_object() Search through the list of objects' names and return the first match. The second argument is optional. Always using it can considerably reduce the size of the list to be searched, so it is recommended. my $object = $parser->find_object( "localhost" ); my $object = $parser->find_object( "oracle", "Nagios::Service" ); =cut sub find_object { my ( $self, $name, $type ) = @_; my $searchlist; if ( $type && $type =~ /^Nagios::/ ) { my @objl = $self->find_objects($name, $type); return $objl[0] if ( scalar @objl ); } elsif ( !$type ) { $searchlist = $self->all_objects; foreach my $obj (@$searchlist) { #printf STDERR "obj name '%s', name searched '%s'\n", $obj->name, $name; my $n = $obj->name; if ( $n && $n eq $name ) { return $obj; } } } } =item find_objects() Search through the list of objects' names and return all the matches. The second argument is required. my @object_list = $parser->find_objects( "load", "Nagios::Service" ); =cut sub find_objects { my ( $self, $name, $type ) = @_; if ( $type && $type =~ /^Nagios::(.*)/ ) { my $index_type = lc($1) . '_index'; if ( exists $self->{$index_type} && exists $self->{$index_type}->{$name} ) { return @{$self->{$index_type}->{$name}}; } } return (); } =item find_objects_by_regex() Search through the list of objects' names and return a list of matches. The first argument will be evaluated as a regular expression. The second argument is required and specifies what kind of object to search for. The regular expressions are created by translating the "*" to ".*?" and "?" to ".". For now (v0.9), this code completely ignores Nagios's use_regexp_matching and use_true_regexp_matching and does full RE matching all the time. my @objects = $parser->find_objects_by_regex( "switch_*", "Nagios::Host" ); my @objects = $parser->find_objects_by_regex( "server0?", "Nagios::Host" ); =cut sub find_objects_by_regex { my ( $self, $re, $type ) = @_; my @retval; my $searchlist; if ( !$type ) { $searchlist = $self->all_objects; } else { $searchlist = $self->all_objects_for_type($type); } foreach my $obj (@$searchlist) { my $objname = $obj->name; if ( $objname && $objname =~ /$re/ ) { push @retval, $obj; } } return @retval; } =item all_objects_for_type() Obtain a reference to all objects of the specified Nagios object type. Usage: $objects = all_objects_for_type($object_type) Parameters: $object_type - A specific Nagios object type, i.e. "Nagios::Contact".. Returns: A reference to an array of references to all objects of the specified type associated with this configuration. Objects of this type added to the configuration following the call to this method _will_ be accessible through this reference after the fact. Note that the array reference by the return value may be empty. Example: my $contacts = $config->all_objects_for_type("Nagios::Contact"); if (scalar(@$contacts) == 0) { print "No contacts have yet been defined\n"; } else { foreach $contact (@$contacts) { ... } } =cut sub all_objects_for_type { my ( $self, $obj_type ) = @_; my $ret_array = []; confess "must specify Nagios object type to all_objects_for_type('$obj_type')" unless ( $obj_type =~ /^Nagios::(.*)$/ ); # e.g. service_list is an arrayref in $self - just return it my $list_type = lc($1) . '_list'; if ( exists $self->{$list_type} ) { $ret_array = $self->{$list_type}; } return $ret_array; } =item all_objects() Returns an arrayref with all objects parsed from the config in it. my $everything = $config->all_objects; =cut sub all_objects { my $self = shift; my @ret_array; # a little cheesy, but less maintenance goofups foreach my $key ( keys %$self ) { next unless $key =~ /_list$/ && ref $self->{$key} eq 'ARRAY'; push @ret_array, @{ $self->{$key} }; } return \@ret_array; } =item find_attribute() Search through the objects parsed thus far, looking for a particular textual name. When found, return that object. If called with two arguments, it will search through all objects currently loaded until a match is found. A third argument may specify the type of object to search for, which may speed up the search considerably. my $object = $parser->find_attribute( "command_name", "check_host_alive" ); my $object = $parser->find_attribute( "command_name", "check_host_alive", 'Nagios::Host' ); =cut sub find_attribute { my ( $self, $attribute, $what, $type ) = @_; confess "must specify what string to find_attribute" if ( !$what && $what != 0 ); my @to_search = (); if ( defined $type && $type =~ /^Nagios::(.*)$/ ) { $to_search[0] = lc($1); } else { # brute-force search through all objects of all types @to_search = map { lc $_ } keys %nagios_setup; } foreach my $type (@to_search) { foreach my $obj ( @{ $self->{"${type}_list"} } ) { if ( $obj->has_attribute($attribute) && $obj->$attribute() eq $what ) { return $obj; } #if ( $obj->has_attribute($attribute) ) { # my $match_attr = $obj->$attribute(); # if ( ref $match_attr && $match_attr->name eq $what ) { # warn "Woot! $obj"; # return $obj; # } # elsif ( $match_attr eq $what ) { # return $obj; # } #} #return $obj if ( $obj->name eq $what ); } } } =item resolve() Resolve the template for the specified object. Templates will not work until this has been done. $parser->resolve( $object ); =cut sub resolve { my ( $self, $object ) = @_; # return if this object has already been resolved return 1 if ( $object->resolved ); # set the resolved flag $object->resolved(1); if ( exists $object->{use} && defined $object->{use} && !exists $object->{_use} ) { my $template = $self->find_object( $object->use, ref $object ); $object->{_use} = $template; } 1; } =item register() Examine all attributes of an object and link all of it's references to other Nagios objects to their respective perl objects. If this isn't called, some methods will return the textual name instead of a perl object. $parser->register( $host_object ); my $timeperiod_object = $host_object->notification_period; =cut sub register { my ( $self, $object ) = @_; # bail out if this object has already been registered return 1 if ( $object->registered ); # bail out if we shouldn't register this object return 1 if ( !$object->register ); # bad things(tm) will happen if resolve hasn't been called croak "must call resolve() method on object before registering" if ( !$object->resolved ); # go through all of the object's attributes and link them to objects # where appropriate foreach my $attribute ( $object->list_attributes ) { next if ( $attribute eq 'use' || $attribute eq 'register' ); next unless defined $object->$attribute(); my $attr_type = $object->attribute_type($attribute); # all done unless the attribute is supposed to point to another object next unless $attr_type =~ /^Nagios::.*$/ or ref $attr_type eq 'ARRAY'; # deal with lists types if ( !ref $attr_type && $object->attribute_is_list($attribute) ) { # pushed out to subroutine to keep things readable my @refs = $self->register_object_list( $object, $attribute, $attr_type ); $object->_set( $attribute, \@refs ); } # multi-type lists, like Nagios::ServiceGroup elsif ( ref $attr_type eq 'ARRAY' ) { my $values = $object->$attribute(); confess "invalid element in attribute \"$attribute\" ($values)" unless ref($values) eq 'ARRAY'; my @new_list; foreach my $value (@$values) { my @mapped; for ( my $i = 0; $i < @$attr_type; $i++ ) { push @mapped, $self->find_object( $value->[$i], $attr_type->[$i] ); } push @new_list, \@mapped; } my $set = 'set_' . $attribute; $object->$set(@new_list); } else { my @refl = $self->find_objects( $object->$attribute(), $attr_type ); if ( scalar @refl == 1 ) { $object->_set( $attribute, $refl[0] ); } # If we have found multiple hits, then we most likely have a Nagios::Service # Need to pick the correct one. Use the Nagios::Host object to help pick it. elsif ( scalar @refl > 1 && ( $object->can('host_name') || $object->can('hostgroup_name') )) { sub _host_list { my ($self, $method, $h) = @_; if ( $self->can($method) ) { if ( ref $self->$method eq 'ARRAY' ) { map { if ( ref $_ eq '' ) { $h->{$_}++; } else { $h->{$_->host_name}++; } } @{$self->$method}; } elsif ( defined $self->$method ) { $h->{ $self->$method }++; } } } sub get_host_list { my $self = shift; my $obj = $self->{'object_config_object'}; my %h; &_host_list($self, 'host_name', \%h); if ( $self->can('hostgroup_name') ) { if ( ref $self->hostgroup_name eq 'ARRAY' ) { foreach my $hg ( @{$self->hostgroup_name} ) { my $hg2 = ( ref $hg eq '' ? $obj->find_object($hg, 'Nagios::HostGroup') : $hg); &_host_list($hg2, 'members', \%h); } } elsif ( defined $self->hostgroup_name ) { my $hg2 = ( ref $self->hostgroup_name eq '' ? $obj->find_object($self->hostgroup_name, 'Nagios::HostGroup') : $self->hostgroup_name); &_host_list($hg2, 'members', \%h); } } return keys %h; } my @h1 = &get_host_list($object); my $old_found = 0; foreach my $o ( @refl ) { my @h2 = &get_host_list($o); next if ( ! scalar @h2 ); my $found = 0; foreach my $h ( @h1 ) { $found++ if ( grep {$h eq $_} @h2 ); } # Use the service which had the max hosts found. if ( $found > $old_found ) { $object->_set( $attribute, $o ); $old_found = $found; } } } } # This field is marked as to be synced with it's group members object if ( ( $nagios_setup{ $object->setup_key }->{ $attribute }[1] & NAGIOS_GROUP_SYNC ) == NAGIOS_GROUP_SYNC ) { my $method = ( $attribute eq 'members' ? lc($object->{'_nagios_setup_key'}) . 's' : 'members'); my $setmethod = 'set_' . $method; foreach my $o ( @{$object->$attribute()} ) { next if ( ! $o->can($method) ); my $members = $o->$method(); # If the object has not yet been registered, just add the name if ( ! $o->registered ) { if ( defined $members && ref $members eq '' ) { $members = [ $members, $object->name ]; } else { push @$members, $object->name; } $o->$setmethod($members); } # otherwise add the object itself. elsif ( ! $members || ! grep ({$object eq $_} @$members )) { push @$members, $object; $o->$setmethod($members); } } } } $object->registered(1); } sub register_object_list { my ( $self, $object, $attribute, $attr_type ) = @_; # split on comma surrounded by whitespace or by just whitespace # - don't try splitting it if it has already been split by the Nagios::Object::_set function! # - same bug reported in CPAN's RT: http://rt.cpan.org/Public/Bug/Display.html?id=31291 my @to_find; my $value = $object->$attribute(); if ( ref $value eq 'ARRAY' ) { @to_find = @{$value}; } else { @to_find = split /\s*,\s*|\s+/, $value; } my @found = (); # handle splat '*' matching of all objects of a type (optimization) if ( @to_find == 1 && $to_find[0] eq '*' ) { @found = @{ $self->all_objects_for_type($attr_type); }; confess "Wildcard matching failed. Have you defined any $attr_type objects?" unless ( @found > 0 ); return @found; } # now back to our regularly scheduled search ... my %wildcard_finds = (); foreach my $item (@to_find) { # no regular expression matching if both flags are false OR # only "regexp_matching" is enabled and the string does not contain ? or * if (( !$self->{_regexp_matching_enabled} && !$self->{_true_regexp_matching_enabled} ) || ( !$self->{_true_regexp_matching_enabled} && $item !~ /[\*\?]/ ) ) { my $ref = $self->find_object( $item, $attr_type ); push( @found, $ref ) if ($ref); } # otherwise, use RE's (I bet most people have this turned on) else { my $re = $item; $re =~ s/(<=\.)\*/.*?/g; # convert "*" to ".*?" $re =~ s/\?/./g; # convert "?" to "." # when true_regexp... isn't on, the RE is anchored if ( !$self->{_true_regexp_matching_enabled} ) { $re = "^$re\$"; # anchor the RE for Nagios "light" RE's } my @ret = $self->find_objects_by_regex( $re, $attr_type ); croak "Wildcard match failed. The generated regular expression was '$re'. Maybe you meant to enable_true_regexp_matching?" unless @ret > 0; push @found, @ret; } } return @found; } =item resolve_objects() Resolve all objects currently loaded into memory. This can be called any number of times without corruption. $parser->resolve_objects(); =cut sub resolve_objects { my $self = shift; foreach my $obj_type ( map { lc $_ } keys %nagios_setup ) { foreach my $object ( @{ $self->{ $obj_type . '_list' } } ) { $self->resolve($object); } } return 1; } =item register_objects() Same deal as resolve_objects(), but as you'd guess, it registers all objects currently loaded into memory. $parser->register_objects(); =cut sub register_objects { my $self = shift; # Order we process the Object is important. We need the Host/HostGroups # processed before the Service and the Service before the ServiceEescalation foreach my $obj_type ( map { lc $_ } sort keys %nagios_setup ) { foreach my $object ( @{ $self->{ $obj_type . '_list' } } ) { $self->register($object); } } $Nagios::Object::pre_link = undef; return 1; } =item enable_regexp_matching()/disable_regexp_matching() This correlates to the "use_regexp_matching" option in nagios.cfg. When this option is enabled, Nagios::Object::Config will translate "*" to ".*?" and "?" to "." and evaluate the result as a perl RE, anchored at both ends for any value that can point to multiple other objects (^ and $ are added to either end). $parser->enable_regexp_matching; $parser->disable_regexp_matching; =cut sub enable_regexp_matching { shift->{_regexp_matching_enabled} = 1 } sub disable_regexp_matching { shift->{_regexp_matching_enabled} = undef } =item enable_true_regexp_matching()/disable_true_regexp_matching() This correlates to the "use_true_regexp_matching" option in nagios.cfg. This is very similar to the enable_regexp_matching() option, but matches more data and allows more powerful RE syntax. These modules will allow you the full power of perl RE's - this is probably more than is available in Nagios, so don't blame me if something works here but not in Nagios (it's usually the other way around anyways). The generated RE's have the same translation as above, but do not have the anchors to ^ and $. This option always supercedes enable_regexp_matching. $parser->enable_true_regexp_matching; $parser->disable_true_regexp_matching; =cut sub enable_true_regexp_matching { shift->{_true_regexp_matching_enabled} = 1 } sub disable_true_regexp_matching { shift->{_true_regexp_matching_enabled} = undef; } =item list_hosts(), list_hostgroups(), etc. Returns an array/arrayref of objects of the given type. $config->list_hosts $config->list_hostgroups $config->list_services $config->list_timeperiods $config->list_commands $config->list_contacts $config->list_contactgroups $config->list_hostdependencies $config->list_servicedependencies $config->list_hostescalations $config->list_hostgroupescalations $config->list_serviceescalations $config->list_servicegroups $config->list_hostextinfo $config->list_serviceextinfo =cut # may want to change this eventually to return a copy of the array # instead of the array referenced in $self sub _list { my ( $self, $type ) = @_; my $key = $type . '_list'; wantarray ? @{ $self->{$key} } : $self->{$key}; } sub list_hosts { shift->_list('host') } sub list_hostgroups { shift->_list('hostgroup') } sub list_services { shift->_list('service') } sub list_timeperiods { shift->_list('timeperiod') } sub list_commands { shift->_list('command') } sub list_contacts { shift->_list('contact') } sub list_contactgroups { shift->_list('contactgroup') } sub list_hostdependencies { shift->_list('hostdependency') } sub list_servicedependencies { shift->_list('servicedependency') } sub list_hostescalations { shift->_list('hostescalation') } sub list_hostgroupescalations { shift->_list('hostgroupescalation') } sub list_serviceescalations { shift->_list('serviceescalation') } sub list_servicegroups { shift->_list('servicegroup') } sub list_hostextinfo { shift->_list('hostextinfo') } sub list_serviceextinfo { shift->_list('serviceextinfo') } # --------------------------------------------------------------------------- # # extend Nagios::Host - requires methods provided in this file # --------------------------------------------------------------------------- # # really slow, brute force way of listing services sub Nagios::Host::list_services { my $self = shift; my $conf = $self->{object_config_object}; my @retval = (); foreach my $s ( $conf->list_services ) { next if ( !$s->service_description ); if ( $s->host_name ) { foreach my $h ( @{ $s->host_name } ) { if ( $h->host_name eq $self->host_name ) { push( @retval, $s ); } } } if ( $s->hostgroup_name ) { foreach my $hg ( @{ $s->hostgroup_name } ) { foreach my $h ( @{ $hg->members } ) { if ( $h->host_name eq $self->host_name ) { push( @retval, $s ); } } } } } return @retval; } # I use a patched version of Nagios right now, so I need these to # keep the parser from bombing when I test on my config. (Al Tobey) sub Nagios::Host::snmp_community { } sub Nagios::Host::set_snmp_community { } =back =head1 AUTHOR Al Tobey Contributions From: Lynne Lawrence (API & bugs) =cut 1; Nagios-Object-0.21.20/lib/Nagios/Config000755001750001750 012220262237 20644 5ustar00dfergusondferguson000000000000Nagios-Object-0.21.20/lib/Nagios/Config/File.pm000444001750001750 702312220262237 22220 0ustar00dfergusondferguson000000000000package Nagios::Config::File; use strict; use warnings; use Carp; use Symbol; # NOTE: due to CPAN version checks this cannot currently be changed to a # standard version string, i.e. '0.21' our $VERSION = '35'; my %DUPLICATES_ALLOWED = ( cfg_file => 1, cfg_dir => 1, ); =head1 NAME Nagios::Config::File - Base class for Nagios configuration files =head1 SYNOPSIS use Nagios::Config ; my $nc = new Nagios::Config("/usr/local/nagios/etc/nagios.cfg") ; my $resource = $nc->get_resource_cfg() ; print $resource->get_attr('$USER1$') . "\n" ; =head1 DESCRIPTION C is the base class for all Nagios configuration files. You should not need to create these yourself. =cut =head1 CONSTRUCTOR =over 4 =item new ([FILE]) Creates a C. =back =cut sub new { my $class = shift; my $file = shift; croak "Missing argument: must specify a configuration file to parse." if ( !$file ); my $this = {}; bless( $this, $class ); my $fh = undef; if ( ref($file) ) { $fh = $file; } else { $fh = gensym; open( $fh, "<$file" ) || croak("Can't open $file for reading: $!"); $this->{filename} = $file; } $this->{file_attributes} = {}; $this->{fh} = $fh; $this->parse(); close($fh); return $this; } sub parse { my $this = shift; my $fh = $this->{fh}; while (<$fh>) { my $line = $this->strip($_); if ( $this->is_comment($line) ) { next; } elsif ( my ( $name, $value ) = $this->is_attribute($line) ) { if ( $DUPLICATES_ALLOWED{$name} ) { push @{ $this->{file_attributes}->{$name} }, $value; } else { $this->{file_attributes}->{$name} = $value; } } } } sub strip { my $this = shift; my $line = shift; $line =~ s/^\s+//; $line =~ s/\s+$//; return $line; } sub is_comment { my $this = shift; my $line = shift; if ( ( $line eq '' ) || ( $line =~ /^#/ ) ) { return 1; } return 0; } sub is_attribute { my $this = shift; my $line = shift; if ( $line =~ /^([\w\$]+)\s*=\s*(.+)$/ ) { return ( $1, $2 ); } return (); } =head1 METHODS =over 4 =item get ([NAME], [SPLIT]) Returns the value of the attribute C for the current file. If C is true, returns a list of all the values split on /\s*,\s*/. This is useful for attributes that can have more that one value. =cut sub get { my ( $this, $name, $split ) = @_; my $val = $this->{file_attributes}->{$name}; return $split ? split( /\s*,\s*/, $val ) : $val; } sub get_attr { &get; } =item filename() Returns the filename for the current object. =cut sub filename { $_[0]->{filename} } =item dump () Returns a scalar with the full configuration text ready to parse again. =cut sub dump { my $this = shift; my $outtxt = "# filename: $this->{filename}\n"; foreach my $attr ( keys( %{ $this->{file_attributes} } ) ) { if ( $DUPLICATES_ALLOWED{$attr} ) { foreach my $element ( @{ $this->{file_attributes}{$attr} } ) { $outtxt .= $attr . '=' . $element . "\n"; } } else { $outtxt .= $attr . '=' . $this->{file_attributes}{$attr} . "\n"; } } return $outtxt; } 1; =back =head1 AUTHOR Patrick LeBoutillier, patl@cpan.org Al Tobey, tobeya@cpan.org =head1 SEE ALSO Nagios::Config, Nagios::Config::Object =cut