Nagios::Status::Service - Nagios 3.0 Container Class for Status Services.
Version 0.02
# 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;
This module is an object oriented approach to Nagios 3.0 status services.
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.
Nagios::Status::Service
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.
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.
print 'Service is warning...' if $serv->is_warning;
This method take no parameters. Returns TRUE if service is warning. Otherwise, returns FALSE.
print 'Service unknown...' if $serv->is_unknown;
This method take no parameters. Returns TRUE if service is unknown. Otherwise, returns FALSE.
print 'Service critical...' if $serv->is_critical;
This method take no parameters. Returns TRUE if service is critical. Otherwise, returns FALSE.
my $name = $serv->get_hostname;
This method takes no parameters. Returns hostname of service.
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;
my $utime = $serv->get_unknown_time;
This method takes no parameters. Returns unknown time in seconds if service is unknown. Otherwise, returns 0 seconds.
my $ctime = $serv->get_critical_time;
This method takes no parameters. Returns critical time in seconds if service is critical. Otherwise, returns 0 seconds.
Roy Crowder, <rcrowder at cpan.org>
<rcrowder at cpan.org>
Thanks to Jeremy Krieg for patch on release 0.02.
perl, Changes
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.
bug-nagios-status-service at rt.cpan.org
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
http://annocpan.org/dist/Nagios-Status-Service
CPAN Ratings
http://cpanratings.perl.org/d/Nagios-Status-Service
Search CPAN
http://search.cpan.org/dist/Nagios-Status-Service/
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::Service, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Nagios::Status::Service
CPAN shell
perl -MCPAN -e shell install Nagios::Status::Service
For more information on module installation, please visit the detailed CPAN module installation guide.