|
/Users/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Nagios-Cmd/blib/lib/Nagios/Cmd.pm |
Nagios::Cmd
Nagios::Cmd is a module to take care of the logistics involved in submitting a command to Nagios's command pipe. flock(2) is used to insure that parallel calls to this module don't corrupt each other (unlikely in any case).
To turn on this module's debugging, set $Nagios::Cmd::debug to a value greater than 0 before calling any methods: $Nagios::Cmd::debug = 1;
To get a list of valid commands and their arguments, run the following command: perl -MNagios::Cmd -e 'Nagios::Cmd::Help' perl -MNagios::Cmd -e 'Nagios::Cmd::Help(ADD_HOST_COMMENT)'
You might need to specify an include path for Nagios::Cmd since it most likely won't be in your standard perl include directories: perl -I/opt/nagios/libexec -MNagios::Cmd -e 'Nagios::Cmd::Help'
use lib '/opt/nagios/libexec'; use Nagios::Cmd; my $cmd = Nagios::Cmd->new( "/var/opt/nagios/rw/nagios.cmd" ); # -- OR -- $cmd = Nagios::Cmd->new_anyfile( "/var/tmp/test_file.txt" );
my $cmd_args = {
host => $host,
persistent => 1,
author => "Al Tobey",
comment => "This host is very stable."
};
$cmd->ADD_HOST_COMMENT( $cmd_args );
$cmd->ADD_HOST_COMMENT(
host => $host,
persistent => 1,
author => "Al Tobey",
comment => "This host is very stable."
);
$cmd->ADD_HOST_COMMENT( $host, 1, "Al Tobey", "This host is very stable." );
# -- OR --
use lib '/opt/nagios/libexec'; use Nagios::Cmd; my $time = CORE::time(); # use CORE:: if you have Time::HiRes overriding time()
# submit a custom command to the pipe $cmd->nagios_cmd( "[$time] DEL_ALL_HOST_COMMENTS;localhost" );
new()mknod(1) command.
mknod -m 600 /var/tmp/nagios_cmd p
The cat(1) command works well as a reader on a fifo.
my $cmd = Nagios::Cmd->new( "/usr/local/nagios/var/rw/cmd.pipe" );
new_anyfile()my $cmd = Nagios::Cmd->new_anyfile( "/dev/null" ); my $cmd = Nagios::Cmd->new_anyfile( "/tmp/commands.txt" );
host_check()Passive host checks don't work with Nagios 1.0, but should be available for 2.0, so keep that in mind if you're thinking about using host_check. **WARNING** It's mainly here to play with. Your code may need twiddling with to work with future releases of this module.
$cmd->service_check( "PING", "localhost", 1, "PING CRITICAL - Packet loss = 100%" ); $cmd->host_check( "localhost", 1, "CRITICAL - Host Down!" );
nagios_cmd()
$cmd->nagios_cmd( "[".time()."] " . join(";", $COMMAND_NAME, @ARGS) );
$cmd->nagios_cmd( "[1063919882] DISABLE_HOST_SVC_NOTIFICATIONS;localhost" );
GPL
Albert P Tobey <albert.tobey@priority-health.com>
|
/Users/cpanrun/depot/main/contrib-patched/perl/CPAN/src/Nagios-Cmd/blib/lib/Nagios/Cmd.pm |