Git commit notifications via post-receive hook
[monitoring-plugins.git] / contrib / check_flexlm.pl
blob8fa0e33454fc58e9e513be37722eb697bcf51e2e
1 #!/usr/local/bin/perl
3 # usage:
4 # check_flexlm.pl license_file
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.
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
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$
22 # Notes:
23 # - you need the lmstat utility which comes with flexlm.
24 # - set the correct path in the variable $lmstat.
26 # initial version: 9-10-99 Ernst-Dieter Martin edmt@infineon.com
27 # current status: looks like working
29 # Copyright Notice: Do as you please, credit me, but don't blame me
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;
37 alarm(20);
39 $lmstat = "/opt/lic/sw/cadadm/default/bin/lmstat";
41 $licfile = shift;
43 #print "$licfile \n";
45 open CMD,"$lmstat -c $licfile |";
47 $serverup = 0;
49 while ( <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;
75 if ( $serverup == 0 ) {
76 print " license server not running\n";
77 exit 2;
80 exit 0 if ( $servers == $lf1 + $lf2 + $lf3 );
81 exit 1 if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 );
82 exit 2;