summaryrefslogtreecommitdiffstats
path: root/contrib/check_flexlm.pl
diff options
context:
space:
mode:
authorEthan Galstad <egalstad@users.sourceforge.net>2002-03-01 02:42:56 +0000
committerEthan Galstad <egalstad@users.sourceforge.net>2002-03-01 02:42:56 +0000
commitecc185f1a43d2b01acb14c9cdcc98e80d3b67122 (patch)
tree29839707d5910c08ce881a3bcddb2822f67afb2f /contrib/check_flexlm.pl
parent44a321cb8a42d6c0ea2d96a1086a17f2134c89cc (diff)
downloadmonitoring-plugins-ecc185f1a43d2b01acb14c9cdcc98e80d3b67122.tar.gz
Contrib plugin cleanup
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@6 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/check_flexlm.pl')
-rw-r--r--contrib/check_flexlm.pl82
1 files changed, 82 insertions, 0 deletions
diff --git a/contrib/check_flexlm.pl b/contrib/check_flexlm.pl
new file mode 100644
index 00000000..8fa0e334
--- /dev/null
+++ b/contrib/check_flexlm.pl
@@ -0,0 +1,82 @@
1#!/usr/local/bin/perl
2#
3# usage:
4# check_flexlm.pl license_file
5#
6# Check available flexlm license managers.
7# Use lmstat to check the status of the license server
8# described by the license file given as argument.
9# Check and interpret the output of lmstat
10# and create returncodes and output.
11#
12# Contrary to the nagios concept, this script takes
13# a file, not a hostname as an argument and returns
14# the status of hosts and services described in that
15# file. Use these hosts.cfg entries as an example
16#
17#host[anchor]=any host will do;some.address.com;;check-host-alive;3;120;24x7;1;1;1;
18#service[anchor]=yodel;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yodel_lic
19#service[anchor]=yeehaw;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yeehaw_lic
20#command[check_flexlm]=/some/path/libexec/check_flexlm.pl $ARG1$
21#
22# Notes:
23# - you need the lmstat utility which comes with flexlm.
24# - set the correct path in the variable $lmstat.
25#
26# initial version: 9-10-99 Ernst-Dieter Martin edmt@infineon.com
27# current status: looks like working
28#
29# Copyright Notice: Do as you please, credit me, but don't blame me
30#
31
32# Just in case of problems, let's not hang Nagios
33$SIG{'ALRM'} = sub {
34 print "No Answer from Client\n";
35 exit 2;
36};
37alarm(20);
38
39$lmstat = "/opt/lic/sw/cadadm/default/bin/lmstat";
40
41$licfile = shift;
42
43#print "$licfile \n";
44
45open CMD,"$lmstat -c $licfile |";
46
47$serverup = 0;
48
49while ( <CMD> ) {
50 if ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*)/ ) {
51 $ls1 = $1;
52 $ls2 = $2;
53 $ls3 = $3;
54 $lf1 = $lf2 = $lf3 = 0;
55 $servers = 3;
56 } elsif ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*)/ ) {
57 $ls1 = $1;
58 $ls2 = $ls3 = "";
59 $lf1 = $lf2 = $lf3 = 0;
60 $servers = 1;
61 } elsif ( / *$ls1: license server UP/ ) {
62 print "$ls1 UP, ";
63 $lf1 = 1
64 } elsif ( / *$ls2: license server UP/ ) {
65 print "$ls2 UP, ";
66 $lf2 = 1
67 } elsif ( / *$ls3: license server UP/ ) {
68 print "$ls3 UP, ";
69 $lf3 = 1
70 } elsif ( / *([^:]*: UP .*)/ ) {
71 print " license server for $1\n";
72 $serverup = 1;
73 }
74}
75if ( $serverup == 0 ) {
76 print " license server not running\n";
77 exit 2;
78}
79
80exit 0 if ( $servers == $lf1 + $lf2 + $lf3 );
81exit 1 if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 );
82exit 2;