NAME
Nagios::Status::Service - Nagios 3.0 Container Class for Status Services.
VERSION
Version 0.02
SYNOPSIS
# Import Module
use Nagios::Status::Service;
# Instantiate the Service object.
my $serv = Nagios::Status::Service->new($nagios_status_log_path);
# OR
my $serv = Nagios::Status::Service->new($nagios_status_log_path, $host_name);
# You can set single attributes.
$serv->set_attribute('hostname=testserver');
# You can get single attributes.
my $attr = $serv->get_attribute('host_name');
# OR
my $attr = $serv->get_attribute('all');
# Check if service is warning, unknown, critical, or up.
if ($serv->is_warning) {
print 'Service is warning...';
} elsif ($serv->is_unknown) {
print 'Service is unknown...';
} elsif ($serv->is_critical) {
print 'Service is critical...';
} else {
print 'Service is up...';
}
# Simple method for obtaining hostname
my $name = $serv->get_hostname;
# Get warning time
my $warning_time = $serv->get_warning_time if $serv->is_warning;
# Get unknown time
my $unknown_time = $serv->get_unknown_time if $serv->is_unknown;
# Get critical time
my $critical_time = $serv->get_critical_time if $serv->is_critical;
DESCRIPTION
This module is an object oriented approach to Nagios 3.0 status services.
OBJECT CREATION METHOD
- new
-
my $serv = Nagios::Status::Service->new($nagios_status_log_path [, $host_name]);
This class constructs a
Nagios::Status::Service
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 service object. If no hostname is specified, subroutines must be used to populate the service.
METHODS
- set_attribute
-
print 'Attribute added...' if $serv->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 = $serv->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_warning
-
print 'Service is warning...' if $serv->is_warning;
This method take no parameters. Returns TRUE if service is warning. Otherwise, returns FALSE.
- is_unknown
-
print 'Service unknown...' if $serv->is_unknown;
This method take no parameters. Returns TRUE if service is unknown. Otherwise, returns FALSE.
- is_critical
-
print 'Service critical...' if $serv->is_critical;
This method take no parameters. Returns TRUE if service is critical. Otherwise, returns FALSE.
- get_hostname
-
my $name = $serv->get_hostname;
This method takes no parameters. Returns hostname of service.
- get_warning_time
-
my $warning_time = $serv->get_warning_time;
This method takes no parameters. Returns warning time in seconds if service is warning. Otherwise, returns 0 seconds;
- get_unknown_time
-
my $utime = $serv->get_unknown_time;
This method takes no parameters. Returns unknown time in seconds if service is unknown. Otherwise, returns 0 seconds.
- get_critical_time
-
my $ctime = $serv->get_critical_time;
This method takes no parameters. Returns critical time in seconds if service is critical. Otherwise, returns 0 seconds.
AUTHOR
Roy Crowder, <rcrowder at cpan.org>
Thanks to Jeremy Krieg for patch on release 0.02.
SEE ALSO
BUGS
Please report any bugs or feature requests to bug-nagios-status-service at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Nagios-Status-Service. 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::Service
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Nagios-Status-Service
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.