summaryrefslogtreecommitdiffstats
path: root/plugins-scripts
diff options
context:
space:
mode:
authorSubhendu Ghosh <sghosh@users.sourceforge.net>2003-02-04 06:16:16 +0000
committerSubhendu Ghosh <sghosh@users.sourceforge.net>2003-02-04 06:16:16 +0000
commit4c605d8cf2237669206a53395ff46df8121d0702 (patch)
treeb18a4e3c2c641430584ca8d8b8e6463763222fab /plugins-scripts
parent1c2cd8fdca8c82218c7a88844479c5b8fe063a9a (diff)
downloadmonitoring-plugins-4c605d8cf2237669206a53395ff46df8121d0702.tar.gz
lmstat output update
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@287 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-xplugins-scripts/check_flexlm.pl173
1 files changed, 134 insertions, 39 deletions
diff --git a/plugins-scripts/check_flexlm.pl b/plugins-scripts/check_flexlm.pl
index dccb6fe1..ade5843c 100755
--- a/plugins-scripts/check_flexlm.pl
+++ b/plugins-scripts/check_flexlm.pl
@@ -28,13 +28,16 @@
28# License: GPL 28# License: GPL
29# $Id$ 29# $Id$
30# 30#
31# lmstat output patches from Steve Rigler/Cliff Rice 13-Apr-2002
32# srigler@marathonoil.com,cerice@marathonoil.com
33
31 34
32 35
33use strict; 36use strict;
34use Getopt::Long; 37use Getopt::Long;
35use vars qw($opt_V $opt_h $opt_F $verbose $PROGNAME); 38use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME);
36use lib utils.pm; 39use lib utils.pm;
37use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); 40use utils qw(%ERRORS &print_revision &support &usage);
38 41
39$PROGNAME="check_flexlm"; 42$PROGNAME="check_flexlm";
40 43
@@ -50,21 +53,32 @@ GetOptions
50 ("V" => \$opt_V, "version" => \$opt_V, 53 ("V" => \$opt_V, "version" => \$opt_V,
51 "h" => \$opt_h, "help" => \$opt_h, 54 "h" => \$opt_h, "help" => \$opt_h,
52 "v" => \$verbose, "verbose" => \$verbose, 55 "v" => \$verbose, "verbose" => \$verbose,
53 "F=s" => \$opt_F, "filename=s" => \$opt_F); 56 "F=s" => \$opt_F, "filename=s" => \$opt_F,
57 "t=i" => \$opt_t, "timeout=i" => \$opt_t);
54 58
55if ($opt_V) { 59if ($opt_V) {
56 print_revision($PROGNAME,'$Revision$'); 60 print_revision($PROGNAME,'$Revision$');
57 exit $ERRORS{'OK'}; 61 exit $ERRORS{'OK'};
58} 62}
59 63
64unless (defined $opt_t) {
65 $opt_t = $utils::TIMEOUT ; # default timeout
66}
67
68
60if ($opt_h) {print_help(); exit $ERRORS{'OK'};} 69if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
61 70
71unless (defined $opt_F) {
72 print "Missing license.dat file\n";
73 print_usage();
74 exit $ERRORS{'UNKNOWN'};
75}
62# Just in case of problems, let's not hang Nagios 76# Just in case of problems, let's not hang Nagios
63$SIG{'ALRM'} = sub { 77$SIG{'ALRM'} = sub {
64 print "No Answer from Client\n"; 78 print "Timeout: No Answer from Client\n";
65 exit 2; 79 exit $ERRORS{'UNKNOWN'};
66}; 80};
67alarm($TIMEOUT); 81alarm($opt_t);
68 82
69my $lmstat = $utils::PATH_TO_LMSTAT ; 83my $lmstat = $utils::PATH_TO_LMSTAT ;
70unless (-x $lmstat ) { 84unless (-x $lmstat ) {
@@ -78,50 +92,125 @@ my $licfile = $1 if ($opt_F =~ /^(.*)$/);
78 92
79print "$licfile\n" if $verbose; 93print "$licfile\n" if $verbose;
80 94
81open CMD,"$lmstat -c $licfile |"; 95if ( ! open(CMD,"$lmstat -c $licfile |") ) {
96 print "ERROR: Could not open \"$lmstat -c $licfile\" ($!)\n";
97 exit exit $ERRORS{'UNKNOWN'};
98}
82 99
83my $serverup = 0; 100my $serverup = 0;
84my ($ls1,$ls2,$ls3,$lf1,$lf2,$lf3,$servers); 101my @upsrv;
102my @downsrv; # list of servers up and down
103
104#my ($ls1,$ls2,$ls3,$lf1,$lf2,$lf3,$servers);
105
106# key off of the term "license server" and
107# grab the status. Keep going until "Vendor" is found
108#
109
110#
111# Collect list of license servers by their status
112# Vendor daemon status is ignored for the moment.
85 113
86while ( <CMD> ) { 114while ( <CMD> ) {
87 if ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*)/ ) { 115 next if (/^lmstat/); # ignore 1st line - copyright
88 $ls1 = $1; 116 next if (/^Flexible/); # ignore 2nd line - timestamp
89 $ls2 = $2; 117 (/^Vendor/) && last; # ignore Vendor daemon status
90 $ls3 = $3; 118 print $_ if $verbose;
91 $lf1 = $lf2 = $lf3 = 0; 119
92 $servers = 3; 120 if ($_ =~ /license server /) { # matched 1 (of possibly 3) license server
93 } elsif ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*)/ ) { 121 s/^\s*//; #some servers start at col 1, other have whitespace
94 $ls1 = $1; 122 # strip staring whitespace if any
95 $ls2 = $ls3 = ""; 123 if ( $_ =~ /UP/) {
96 $lf1 = $lf2 = $lf3 = 0; 124 $_ =~ /^(.*):/ ;
97 $servers = 1; 125 push(@upsrv, $1);
98 } elsif ( / *$ls1: license server UP/ ) { 126 print "up:$1:\n" if $verbose;
99 print "$ls1 UP, "; 127 } else {
100 $lf1 = 1 128 $_ =~ /^(.*):/;
101 } elsif ( / *$ls2: license server UP/ ) { 129 push(@downsrv, $1);
102 print "$ls2 UP, "; 130 print "down:$1:\n" if $verbose;
103 $lf2 = 1 131 }
104 } elsif ( / *$ls3: license server UP/ ) { 132
105 print "$ls3 UP, "; 133 }
106 $lf3 = 1 134
107 } elsif ( / *([^:]*: UP .*)/ ) { 135
108 print " license server for $1\n"; 136# if ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*)/ ) {
109 $serverup = 1; 137# $ls1 = $1;
110 } 138# $ls2 = $2;
139# $ls3 = $3;
140# $lf1 = $lf2 = $lf3 = 0;
141# $servers = 3;
142# } elsif ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*)/ ) {
143# $ls1 = $1;
144# $ls2 = $ls3 = "";
145# $lf1 = $lf2 = $lf3 = 0;
146# $servers = 1;
147# } elsif ( / *$ls1: license server UP/ ) {
148# print "$ls1 UP, ";
149# $lf1 = 1
150# } elsif ( / *$ls2: license server UP/ ) {
151# print "$ls2 UP, ";
152# $lf2 = 1
153# } elsif ( / *$ls3: license server UP/ ) {
154# print "$ls3 UP, ";
155# $lf3 = 1
156# } elsif ( / *([^:]*: UP .*)/ ) {
157# print " license server for $1\n";
158# $serverup = 1;
159# }
160
161}
162
163#if ( $serverup == 0 ) {
164# print " license server not running\n";
165# exit 2;
166#}
167
168close CMD;
169
170if ($verbose) {
171 print "License Servers running: ".scalar(@upsrv) ."\n";
172 foreach my $upserver (@upsrv) {
173 print "$upserver\n";
174 }
175 print "License servers not running: ".scalar(@downsrv)."\n";
176 foreach my $downserver (@downsrv) {
177 print "$downserver\n";
178 }
179}
180
181#
182# print list of servers which are up.
183#
184if (scalar(@upsrv) > 0) {
185 print "License Servers running:";
186 foreach my $upserver (@upsrv) {
187 print "$upserver,";
188 }
111} 189}
112if ( $serverup == 0 ) { 190#
113 print " license server not running\n"; 191# Ditto for those which are down.
114 exit 2; 192#
193if (scalar(@downsrv) > 0) {
194 print "License servers NOT running:";
195 foreach my $downserver (@downsrv) {
196 print "$downserver,";
197 }
115} 198}
116 199
117exit $ERRORS{'OK'} if ( $servers == $lf1 + $lf2 + $lf3 ); 200# perfdata
118exit $ERRORS{'WARNING'} if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 ); 201print "\n|flexlm::up:".scalar(@upsrv).";down:".scalar(@downsrv)."\n";
202
203exit $ERRORS{'OK'} if ( scalar(@downsrv) == 0 );
204exit $ERRORS{'WARNING'} if ( (scalar(@upsrv) > 0) && (scalar(@downsrv) > 0));
205
206#exit $ERRORS{'OK'} if ( $servers == $lf1 + $lf2 + $lf3 );
207#exit $ERRORS{'WARNING'} if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 );
119exit $ERRORS{'CRITICAL'}; 208exit $ERRORS{'CRITICAL'};
120 209
121 210
122sub print_usage () { 211sub print_usage () {
123 print "Usage: 212 print "Usage:
124 $PROGNAME -F <filename> [--verbose] 213 $PROGNAME -F <filename> [-v] [-t] [-V] [-h]
125 $PROGNAME --help 214 $PROGNAME --help
126 $PROGNAME --version 215 $PROGNAME --version
127"; 216";
@@ -137,14 +226,20 @@ Check available flexlm license managers
137 print_usage(); 226 print_usage();
138 print " 227 print "
139-F, --filename=FILE 228-F, --filename=FILE
140 Name of license file 229 Name of license file (usually \"license.dat\")
141-v, --verbose 230-v, --verbose
142 Print some extra debugging information (not advised for normal operation) 231 Print some extra debugging information (not advised for normal operation)
232-t, --timeout
233 Plugin time out in seconds (default = $utils::TIMEOUT )
143-V, --version 234-V, --version
144 Show version and license information 235 Show version and license information
145-h, --help 236-h, --help
146 Show this help screen 237 Show this help screen
147 238
239Flexlm license managers usually run as a single server or three servers and a
240quorum is needed. The plugin return OK if 1 (single) or 3 (triple) servers
241are running, CRITICAL if 1(single) or 3 (triple) servers are down, and WARNING
242if 1 or 2 of 3 servers are running\n
148"; 243";
149 support(); 244 support();
150} 245}