Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

help need with flexlm

by vkknava (Initiate)
on May 04, 2013 at 09:47 UTC ( #1032014=perlquestion: print w/ replies, xml ) Need Help??
vkknava has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am a perl beginner. I have an output like below. I need to get an email if first field (USER1 or USER2) uses 30% of Total licenses issued.
Users of PRODUCT1: (Total of 10 licenses issued; Total of 9 licenses + in use) "PRODUCT1" v2013.03, vendor: snpslmd floating license USER1 host1 /dev/tty (v2011.03) (flexlmhost/1011 130759), start Fr +i 5/3 18:55 USER1 host1 /dev/tty (v2011.03) (flexlmhost/1011 96878), start Fri + 5/3 18:55 USER1 host2 /dev/tty (v2011.03) (flexlmhost/1011 42805), start Fri + 5/3 19:03 USER1 host3 /dev/tty (v2011.03) (flexlmhost/1011 38101), start Tue + 4/30 22:01 USER1 host3 /dev/tty (v2011.03) (flexlmhost/1011 56246), start Fri + 5/3 15:34 USER1 host3 /dev/tty (v2011.03) (flexlmhost/1011 134276), start Th +u 5/2 19:10 USER2 host4 /dev/tty (v2010.06) (flexlmhost/1011 29632), start Fri + 5/3 18:38 USER2 host4 /dev/tty (v2010.06) (flexlmhost/1011 29632), start Fri + 5/3 18:38 USER2 host4 /dev/tty (v2010.06) (flexlmhost/1011 29632), start Fri + 5/3 18:38 Users of PRODUCT2: (Total of 10 licenses issued; Total of 9 licenses + in use) "PRODUCT2" v2013.03, vendor: snpslmd floating license USER2 host5 /dev/tty (v2010.06) (flexlmhost/1011 18701), start Tue + 4/30 22:01 USER2 host6 /dev/tty (v2010.06) (flexlmhost/1011 40601), start Tue + 4/30 22:01 USER2 host7 /dev/tty (v2010.06) (flexlmhost/1011 15041), start Wed + 5/1 14:17 USER2 host8 /dev/tty (v2010.06) (flexlmhost/1011 9801), start Tue +4/30 22:01 USER2 host7 /dev/tty (v2010.06) (flexlmhost/1011 57099), start Fri + 5/3 18:23 USER2 host3 /dev/tty (v2010.06) (flexlmhost/1011 119742), start Fr +i 5/3 18:27 USER2 host2 /dev/tty (v2010.06) (flexlmhost/1011 126337), start Fr +i 5/3 18:27 USER2 host1 /dev/tty (v2010.06) (flexlmhost/1011 126190), start Fr +i 5/3 18:27 USER2 host4 /dev/tty (v2010.06) (flexlmhost/1011 29632), start Fri + 5/3 18:38

Comment on help need with flexlm
Download Code
Re: help need with flexlm
by blue_cowdawg (Monsignor) on May 04, 2013 at 10:00 UTC

    so... what have you tried? Are you concerned about total number of licenses of all products or each product? Either way it is a fairly straight forward detection of what lines you are on

    if ( $line =~ m@Users of Product@ ) { $line =~ m@Product(\d+):@; # match and capture product number $product = $1l
    and tallying the user's product usage
    $line = s/\s+//; #get rid of the leading spaces my @f=split(/[\s\t]+/,$line); my $user=$f[0]; # if our hash does not contain an entry for our user $counter{$user} = [] if ( ! defined($counter{$user}) ) ; $counter{$user}->{$product}++;
    Once you have your counts I'm sure you can work out how to calculate percentages. As far as making your script send email there are plenty of articles on that on PM (try a super search) and my own blog has examples of how to do that (offsite link) here.


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
      I need for each product. If a user uses 30% of the total number of a product, I need an email. I will try with what you have suggested and let you know with the result.

        I tried with the first half of the code. But it is not printing the number.

        Another thing is I have many products in the output file. I am calculating the usage of each product.

        #!/usr/bin/perl local $/; open(DAT, "output1.txt") || die("Could not open file!"); my $line = <DAT>; my $product; if ( $line =~ m/Users of/ ) { $line =~ m@Product(\d+):@; $product = $1; print $product; }
Re: help need with flexlm
by hdb (Prior) on May 04, 2013 at 10:46 UTC

    Have a look at this node: Splitting a file into records. Solutions proposed there can be easily adapted for your problem. Proposals how to send emails are all over PerlMonks...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1032014]
Approved by baxy77bax
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (15)
As of 2014-12-18 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (58 votes), past polls