locked
How to check flexlm license availability before executing a job? RRS feed

  • Question

  • Dear all,

    In Windows HPC Server 2008 scheduler, is it possible to check for flexlm license availability before each job in the queue is executed?
    If it's possible, could someone tell me how??

    The program I am running is using flexlm network license and right now the job will run even when the license is not available, so the job will stop right away since license is not available.

    I guess there are paid programs out there, but I am looking for free resources.

    Thank you.
    Friday, September 25, 2009 2:59 AM

Answers

  • Hi,

     This is an error, the sample will be soon online !

    Best regards, Tom

    • Marked as answer by hiasa Monday, September 27, 2010 1:08 AM
    Sunday, September 26, 2010 6:30 AM

All replies

  • Hi Hiasa
    I guess the 'free' route is to write an activation filter which checks for availability of licences before running the job. The good news is that there is some example filter code which deals with license availability available from Microsoft here http://technet.microsoft.com/en-us/library/dd277833(WS.10).aspx but the not so good news is that license management has got the potential to be a complicated beast!
    Cheers
    Dan


    Friday, September 25, 2009 8:53 AM
  • Hi DanAdams,

    I have tried to search for the solution for a while, but looks like the url you posted is the only free ones that I could find so far.
    It mike take some time to understand the code, but I will try it anyway.

    Thanks for the info.

    Hiasa


    Tuesday, September 29, 2009 6:19 AM
  • Hi,

    My fluent users had the same problem. To prevent jobs from starting when no licenses are available, i made a vbs script that they add as a task and run before compute task. The problem of this method is that the cores are reserved once the job start. In my particular case it s not a problem as fluent users are separated from other user by job template.

    If needed, i can post the vbs.

    Bye
    Tuesday, September 29, 2009 11:31 AM
  • Hi TuX_fr,

    That would be great if you can post the vbs :)

    I have a question about the vbs file.
    When you add the vbs as a task, does the job fail when there is not enough license or the job remain in the queue?

    Thank you
    Wednesday, September 30, 2009 7:44 AM
  • Hi hiasa,

    I wrote this script because of a problem with Fluent licenses. When a fluent job/task is canceled with the job manager, the fluent process is simply killed and the licenses are not available until a timeout is reach (1 hour by default on our flexlm serv). I set this timeout to 10 minutes, but even so, when an fluent job were killed, the queued ones started and failed because of the lack of licenses available.
    How to use this script :
    In your job, create a task that will execute prior to your compute task: cscript //nologo \\yourserv\your_path\fluent_license_check_and_wait.vbs
    In this task set the same number of procs that you compute task will need.
    The script will run until there are enought licenses available. I set a timeout in the script to prevent it from blocking the cluster (by default 1 hour but can easely be modified).
    As is, this script only works for fluent but it can be modified to support other applications. If you need some tips to modify the script just ask and i'll try to help.

    The other way to check licenses is
    activation filter but it's seems quite harder to implement.

    I hope it will help you.

    Bye
    '==========================================================================
    'Script VBS créé avec Astase VBScript Factory - www.astase.com
    'NOM : fluent_licenses_check&wait
    'DATE : 06/07/2009, 12:25
    'AUTEUR : Sébastien CHEVALDONNET _TECHNIP FRANCE_
    'COMMENTAIRES :
    'Check if there are enough FLUENT licenses before exiting. If not enough
    'licenses available, will wait the time you define till enough licenses are
    'free for computing. This script was designed to be used with lmstat v9.2 and
    'Microsoft HPC 2008 scheduler. Just create a task with this command line:
    'cscript //nologo fluent_license_check_and_wait.vbs then add your FLUENT task
    'in the same job. If you manage to run multiple FLUENT tasks in the same job
    'run this script before each FLUENT task (You have to create a
    'fluent_licenses_check&wait task for each FLUENT task). When you create the
    'fluent_licenses_check&wait task you _MUST_ set the same ressources as the
    'FLUENT job will need. If you need logs of this script, use these command :
    'cscript //nologo fluent_license_check_and_wait.vbs >> \\myserv\myfolder\licenses.log
    '==========================================================================
    'Variables to modify :
    'lmstat_fluent_all & lmstat_fluent_par = you have to specify the location
    'where lmstat is located.
    'time_max = number of cycle the script will wait until exiting with error 2.
    'A cycle is 60 seconds + one script execution ( 65 to 75 seconds depending
    'on the speed of you flexlm server/ Network)
    '==========================================================================
    'EXIT CODES :
    ' 0 = OK
    ' 1 = The %CCP_NUMCPUS% variable is not correct.
    ' 2 = The script waited more than time_max variable.
    ' 3 = The %CCP_NUMCPUS% = 0 (no core required)
    '==========================================================================
    lmstat = "\\myserv\data\Administration\Licenses\lmstat.exe"
    time_max = 60
    Set objShell = CreateObject("WScript.Shell")
    Set WshProcessEnv = ObjShell.Environment("Process" )
    fluent_all_licenses_free = 0
    fluent_par_licenses_free = 0
    I=0
    err=0
    If WshProcessEnv("CCP_NUMCPUS") = "" Then
    Wscript.echo  ("CCP_NUMCPUS not correct")
    Wscript.Quit 1
    End If
    If WshProcessEnv("CCP_NUMCPUS") = 0 Then
    Wscript.echo  ("CCP_NUMCPUS = 0")
    Wscript.Quit 3
    End If
    Do While (fluent_all_licenses_free < 1) or ((WshProcessEnv("CCP_NUMCPUS") - 1) > fluent_par_licenses_free)
    If I > time_max Then
    err = 2
    Wscript.echo  ("Time_max reached")
    Exit do
    End If
    If I > 0 Then
    WScript.Sleep 60000
    End if
    ' Gives the numbers of free FLUENT ALL licenses.
    Set ObjWshScriptExec = ObjShell.Exec(lmstat & " -f fluentall")
    Set ObjStdOut = ObjWshScriptExec.StdOut
            While Not ObjStdOut.AtEndOfStream
            StrLine = ObjStdOut.ReadLine
                    If InStr(strLine,"Users of fluentall:") Then
                    fluent_all_licenses_free = ( mid(StrLine,31,2) - mid(StrLine,60,2) )
                    wscript.echo ( now & VbCrLf & "FLUENT ALL free/needed : " & fluent_all_licenses_free&"/1" )
                    End If
            Wend
    ' Gives the numbers of free FLUENT PAR licenses.
    Set ObjWshScriptExec = ObjShell.Exec(lmstat & " -f fluent-par")
    Set ObjStdOut = ObjWshScriptExec.StdOut
            While Not ObjStdOut.AtEndOfStream
            StrLine = ObjStdOut.ReadLine
                    If InStr(strLine,"Users of fluent-par:") Then
                    fluent_par_licenses_free = ( Mid(StrLine,33,2) - mid(StrLine,63,2) )
                    wscript.echo ( "FLUENT PAR free/needed : " & fluent_par_licenses_free&"/"& ((WshProcessEnv("CCP_NUMCPUS") - 1) ) )
                    End If
            Wend
    I = I+1
    Loop
    Wscript.Quit err

    • Marked as answer by Josh BarnardModerator Thursday, October 1, 2009 10:35 PM
    • Unmarked as answer by hiasa Tuesday, September 14, 2010 5:28 AM
    Wednesday, September 30, 2009 2:18 PM
  • Hi TuX_fr,

    Thank you for posting the code.

    I will try to understand it and see if I can adapt it to the application that I am using now :)

    Laters
    Thursday, October 1, 2009 9:33 AM
  • Hello,

     

    The activation filter work quite well, like DanAdams   says is in the MS net pages, I copied the code and compiled it (using visual studio c# 2008, it's free!) and it works well, the only bad thing is it will block the queue until the licenses are avialable for the current job, which means it will block the whole queue for all jobs until the current one can run...

     

    I managed to work around this on my code, passing the job to configure state, and then having a second background program that will resubmit the job in a range of time...

    The good news is the next release of HPC will support "hold/re-submit" jobsUsers Medals Users Medals Users Medals so no more "blocking" queue!


    Regards

    Thursday, May 6, 2010 12:49 PM
  • HI all,

      The next release will offer nice way to manage that :

        See : "Activation Filter - New Options in Beta 2" on http://blogs.technet.com/b/windowshpc/archive/2010/03/26/activation-filter-new-options-in-beta-2.aspx

    Best regards, Tom

    Monday, June 7, 2010 7:28 AM
  • Hi all,

     

     We also provide a sample :

    Check for license availability before a job is started on http://technet.microsoft.com/en-us/library/ee783563%28WS.10%29.aspx#BKMK_Activation  


    Best regards, Tom

    Sunday, July 11, 2010 7:37 AM
  • Hi Tom,

    Thank you for the url.

    But, I was not able to find the license availability checking topic on the url you have provided.

    Did the page change after your post?

     

    I also found a page saying that license checking sample is included in the SDK, but inside SDK sample code, there was only code for activation filter, but nothing related to flexlm license checking.

    "The HPC 2008 R2 SDK includes sample code for an activation filter that checks for license availability against a FlexLM license file.

    For detailed information about the new exit codes for Activation Filters and more information about building the code sample, see the “Check for license availability before a job is started” section in the New Feature Evaluation Guide for Windows HPC Server R2."

    http://technet.microsoft.com/en-us/library/ee815854(WS.10).aspx

     

    Best regards, Hiasa

    Monday, September 13, 2010 2:53 AM
  • Hi,

     This is an error, the sample will be soon online !

    Best regards, Tom

    • Marked as answer by hiasa Monday, September 27, 2010 1:08 AM
    Sunday, September 26, 2010 6:30 AM
  • Hi Tom,

    Seems like the site had been updated on 9/24 and I am able to find the sample of FlexLM in it now.

    Thank you for the information.

    Best regards, Hiasa

    Monday, September 27, 2010 1:08 AM
  • Hi All,

           I have a similair problem like Hiasa but I am not VB guy.  Any alternative for me to overcome this problem?

     

    Rgds,

    Airfoil

    Thursday, November 18, 2010 8:23 AM
  • Any new development on a solution for this? 90% of our HPC usage is dependent on FlexLM.
    Friday, July 29, 2011 3:17 PM
  • Hi,

     See http://www.microsoft.com/download/en/details.aspx?id=26645 

     Into HPC2008R2.SampleCode.zip you have a very interesting  sample for that ! Look into Scheduler\Filters you will find :   

     
    Samples for each type of HPC Scheduler filter technology are provided:

     dll:
      Activation FlexLM
       A sample activation filter that integrates with FlexLM.

      Activation HoldUntil
       A sample actvation filter that performs HoldUntil.

      ComboDiagLogging
       A sample filter that serves as both an activation and submission
       filter and includes sample logging.   This filter is useful for
       diagnostic purposes as well as demonstrating shared state between
       a submission filter and an activation filter.

      Submission JobSize
       A sample submission filter that changes the job based on its size.


     exe:
      Activation FlexLM
       A sample activation filter that integrates with FlexLM.

      Activation HoldUntil
       A sample actvation filter that performs HoldUntil.

      Submission JobSize
       A sample submission filter that changes the job based on its size.

    Best regards, Tom

    Friday, August 5, 2011 7:14 AM