Nagios::Status::Host - Nagios 3.0 Container Class for Status Hosts.
Version 0.01
# Import Module use Nagios::Status::Host; # Instantiate the Host object. my $host = Nagios::Status::Host->new($nagios_status_log_path); # OR my $host = Nagios::Status::Host->new($nagios_status_log_path, $host_name); # You can set single attributes. $host->set_attribute('hostname=testserver'); # You can get single attributes. my $attr = $host->get_attribute('host_name'); # OR my $attr = $host->get_attribute('all'); # Check if host is down, unreachable, or up. if ($host->is_down) { print 'Host is down...'; } elsif ($host->is_unreachable) { print 'Host is unreachable...'; } else { print 'Host is up...'; } # Simple method for obtaining hostname my $name = $host->get_hostname; # Get downtime my $downtime = $host->get_downtime if $host->is_down; # Get unreachable time my $unreach_time = $host->get_unreachable_time if $host->is_unreachable;
This module is an object oriented approach to Nagios 3.0 status hosts.
my $host = Nagios::Status::Host->new($nagios_status_log_path [, $host_name]);
This class constructs a Nagios::Status::Host object. It requires one parameter. A file path containing the path to the Nagios status.log file. There is one optional parameter. A hostname can be specified to populate the host object. If no hostname is specified, subroutines must be used to populate the host.
Nagios::Status::Host
print 'Attribute added...' if $host->set_attribute('host_name=testserver');
This method takes one required parameter, a string (attribute=value). Returns TRUE if attribute was added successfully otherwise returns undefined.
my $attr = $host->get_attribute($attribute);
This method takes one required parameter, an attribute or 'all'. If 'all' is specified, a hash reference of attributes(keys) and values is returned. If an attribute is specified and is found, the value is returned. Otherwise, undefined is returned.
print 'Host down...' if $host->is_down;
This method take no parameters. Returns TRUE if host is down. Otherwise, returns FALSE.
print 'Host unreachable...' if $host->is_unreachable;
This method take no parameters. Returns TRUE if host is unreachable. Otherwise, returns FALSE.
my $name = $host->get_hostname;
This method takes no parameters. Returns hostname of host.
my $downtime = $host->get_downtime;
This method takes no parameters. Returns downtime in seconds if host is down. Otherwise, returns 0 seconds;
my $utime = $host->get_unreachable_time;
This method takes no parameters. Returns unreachable time in seconds if host is unreachable. Otherwise, returns 0 seconds.
Roy Crowder, <rcrowder at cpan.org>
<rcrowder at cpan.org>
perl, Changes
Please report any bugs or feature requests to bug-nagios-status-host at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Nagios-Status-Host. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-nagios-status-host at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Nagios::Status::Host
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Nagios-Status-Host
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Nagios-Status-Host
CPAN Ratings
http://cpanratings.perl.org/d/Nagios-Status-Host
Search CPAN
http://search.cpan.org/dist/Nagios-Status-Host/
Copyright (c) 2009 WorldSpice Technologies, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Nagios::Status::Host, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Nagios::Status::Host
CPAN shell
perl -MCPAN -e shell install Nagios::Status::Host
For more information on module installation, please visit the detailed CPAN module installation guide.