diff options
author | makefu <github@syntax-fehler.de> | 2013-01-14 14:46:22 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2013-01-14 14:46:22 +0100 |
commit | dbe2d838ba6834788265029162b2dd7d82473335 (patch) | |
tree | a4eb38f7fc91d91269b6f83453de62242c6ddc23 /god/Monitoring/nagios/plugins/utils.pm | |
parent | 5a782f6c8f7923f9f415afd504ce6e71acbc7fef (diff) | |
parent | abf9916bc1add17888308877fa4eb9da330297ef (diff) |
Merge branch 'master' of github.com:krebscode/painload
Conflicts:
god/temper/Makefile
god/temper/collectd-temper.sh
Diffstat (limited to 'god/Monitoring/nagios/plugins/utils.pm')
-rw-r--r-- | god/Monitoring/nagios/plugins/utils.pm | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/god/Monitoring/nagios/plugins/utils.pm b/god/Monitoring/nagios/plugins/utils.pm new file mode 100644 index 00000000..676a06fe --- /dev/null +++ b/god/Monitoring/nagios/plugins/utils.pm @@ -0,0 +1,67 @@ +# Utility drawer for Nagios plugins. +# +# This will be deprecated soon. Please use Nagios::Plugin from CPAN +# for new plugins + +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; + +## updated by autoconf +$PATH_TO_RPCINFO = "/usr/bin/rpcinfo" ; +$PATH_TO_LMSTAT = "" ; +$PATH_TO_SMBCLIENT = "/usr/bin/smbclient" ; +$PATH_TO_MAILQ = "/usr/bin/mailq"; +$PATH_TO_QMAIL_QSTAT = ""; + +## common variables +$TIMEOUT = 15; +%ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); + +## utility subroutines +sub print_revision ($$) { + my $commandName = shift; + my $pluginRevision = shift; + print "$commandName v$pluginRevision (nagios-plugins 1.4.15)\n"; + print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\ncopies of the plugins under the terms of the GNU General Public License.\nFor more information about these matters, see the file named COPYING.\n"; +} + +sub support () { + my $support='Send email to nagios-users@lists.sourceforge.net if you have questions\nregarding use of this software. To submit patches or suggest improvements,\nsend email to nagiosplug-devel@lists.sourceforge.net.\nPlease include version information with all correspondence (when possible,\nuse output from the --version option of the plugin itself).\n'; + $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; + return 0 unless defined $host1; + if ($host1 =~ m/^[\d\.]+$/ && $host1 !~ /\.$/) { + if ($host1 =~ m/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) { + return 1; + } else { + return 0; + } + } elsif ($host1 =~ m/^[a-zA-Z0-9][-a-zA-Z0-9]*(\.[a-zA-Z0-9][-a-zA-Z0-9]*)*\.?$/) { + return 1; + } else { + return 0; + } +} + +1; |