| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- # Utility drawer for Nagios plugins.
- # $Id$
- #
- # $Log$
- # Revision 1.2 2002/05/08 05:10:35 sghosh
- # is_hostname added, update CODES to POSIX
- #
- #
- package utils;
- require Exporter;
- @ISA = qw(Exporter);
- @EXPORT_OK = qw($TIMEOUT %ERRORS &print_revision &support &usage);
- #use strict;
- #use vars($TIMEOUT %ERRORS);
- sub print_revision ($$);
- sub usage;
- sub support();
- sub is_hostname;
- $TIMEOUT = 15;
- %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
- sub print_revision ($$) {
- my $commandName = shift;
- my $pluginRevision = shift;
- $pluginRevision =~ s/^\$Revision: //;
- $pluginRevision =~ s/ \$\s*$//;
- print "$commandName (@PACKAGE@ @VERSION@) $pluginRevision\n";
- print "@WARRANTY@";
- }
- sub support () {
- my $support='@SUPPORT@';
- $support =~ s/@/\@/g;
- $support =~ s/\\n/\n/g;
- print $support;
- }
- sub usage {
- my $format=shift;
- printf($format,@_);
- exit $ERRORS{'UNKNOWN'};
- }
- sub is_hostname {
- my $host1 = shift;
- if ($host1 && $host1 =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]+(\.[a-zA-Z][-a-zA-Z0-9]+)*)$/) {
- return 1;
- }else{
- return 0;
- }
- }
- 1;
|