diff options
Diffstat (limited to 'plugins-scripts/utils.pm.in')
-rw-r--r-- | plugins-scripts/utils.pm.in | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in new file mode 100644 index 0000000..361bfe9 --- /dev/null +++ b/plugins-scripts/utils.pm.in | |||
@@ -0,0 +1,38 @@ | |||
1 | package utils; | ||
2 | |||
3 | require Exporter; | ||
4 | @ISA = qw(Exporter); | ||
5 | @EXPORT_OK = qw($TIMEOUT %ERRORS &print_revision &support &usage); | ||
6 | |||
7 | #use strict; | ||
8 | #use vars($TIMEOUT %ERRORS); | ||
9 | sub print_revision ($$); | ||
10 | sub usage; | ||
11 | sub support(); | ||
12 | |||
13 | $TIMEOUT = 15; | ||
14 | %ERRORS=('UNKNOWN'=>-1,'OK'=>0,'WARNING'=>1,'CRITICAL'=>2); | ||
15 | |||
16 | sub print_revision ($$) { | ||
17 | my $commandName = shift; | ||
18 | my $pluginRevision = shift; | ||
19 | $pluginRevision =~ s/^\$Revision: //; | ||
20 | $pluginRevision =~ s/ \$\s*$//; | ||
21 | print "$commandName (@PACKAGE@ @VERSION@) $pluginRevision\n"; | ||
22 | print "@WARRANTY@"; | ||
23 | } | ||
24 | |||
25 | sub support () { | ||
26 | my $support='@SUPPORT@'; | ||
27 | $support =~ s/@/\@/g; | ||
28 | $support =~ s/\\n/\n/g; | ||
29 | print $support; | ||
30 | } | ||
31 | |||
32 | sub usage { | ||
33 | my $format=shift; | ||
34 | printf($format,@_); | ||
35 | exit $ERRORS{'UNKNOWN'}; | ||
36 | } | ||
37 | |||
38 | 1; | ||