NAME
Nagios::Status::Host - Nagios 3.0 Container Class for Status Hosts.
VERSION
Version 0.01
SYNOPSIS
# 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;
DESCRIPTION
This module is an object oriented approach to Nagios 3.0 status hosts.
OBJECT CREATION METHOD
- new
-
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.
METHODS
- set_attribute
-
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.
- get_attribute
-
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.
- is_down
-
print 'Host down...' if $host->is_down;
This method take no parameters. Returns TRUE if host is down. Otherwise, returns FALSE.
- is_unreachable
-
print 'Host unreachable...' if $host->is_unreachable;
This method take no parameters. Returns TRUE if host is unreachable. Otherwise, returns FALSE.
- get_hostname
-
my $name = $host->get_hostname;
This method takes no parameters. Returns hostname of host.
- get_downtime
-
my $downtime = $host->get_downtime;
This method takes no parameters. Returns downtime in seconds if host is down. Otherwise, returns 0 seconds;
- get_unreachable_time
-
my $utime = $host->get_unreachable_time;
This method takes no parameters. Returns unreachable time in seconds if host is unreachable. Otherwise, returns 0 seconds.
AUTHOR
Roy Crowder, <rcrowder at cpan.org>
SEE ALSO
BUGS
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.
SUPPORT
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
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
COPYRIGHT & LICENSE
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.