#! /usr/bin/perl use strict ; use warnings ; package Probe::Lmstat ; use base 'Probe' ; # lm_flex spin lmstat lm # lm_pgroupd spin lmstat pgroupd # lm_maplelmg spin lmstat maplelmg # lm_idl_lmgrd spin lmstat idl_lmgrd sub ITEMS { [ { name => 'lm_flex' , kind => 'spin' , args => [ 'license server' ] } , { name => 'lm_pgroupd' , kind => 'spin' , args => [ qw(pgroupd) ] } , { name => 'lm_maplelmg' , kind => 'spin' , args => [ qw(maplelmg) ] } , { name => 'lm_idl_lmgrd' , kind => 'spin' , args => [ qw(idl_lmgrd) ] } ] } ; sub main { my $self = shift ; my $itms = shift ; # items to probe : [ item, ... ] my $clnt = shift ; # main::CLIENT my $prog = '/local/bin/lmstat' ; my ( $err, $xit, $sig, @lines ) = Probe::Util::run_prog ( $prog ) ; if ( $err ) { $_ -> perr ( $err ) for @$itms ; } else { chomp @lines ; for my $item ( @$itms ) { my $name = $item -> name ; my $clas = $item -> args -> [ 0 ] ; my $cnt = scalar grep /$clas:?\sUP/, @lines ; my $val = $cnt ? Dmon::SPIN_UP : Dmon::SPIN_DO ; OBB::TT ( ' item %s val %s', $name, $val ) ; $item -> set_val ( $val ) ; } } } 1 ;