Reply
Accepted Solution

Is there a dept limit on a trigger?

Authority
Posts: 20
1258     0

I am working on a fairly simeple script to collect the licensing information on Cisco routers and generate an issue if I have any with Eval licening enabled that are also active. I run the show license command as an action and I get an indexed list of the licenses and the status. I have 10 licenses return from the show command but the trigger only processes 4 of them then exits out, not error anything.   Here is the script:

 

###########################################################################
## Export of Script: Detect IOS Licensing in EVAL State
## Script-Level: 2
## Script-Category: Uncategorized
###########################################################################

Script:
    Detect IOS Licensing in EVAL State
    
Script-Description:
    This script will run the show license command and parse out any inuse license in eval mode

Script-Filter:
    $Vendor eq "Cisco"
    
############################################################################
    
Action:
    show license

Action-Description:
    This gets the show license output

Action-Commands:
    show license
        
Output-Triggers:
    Trigger detect license status by feature

############################################################################
Trigger:
    Trigger detect license status by feature

Trigger-Variables:
    $LicenseFeature string
    $PeriodLeft string
    $LicenseType string
    $LicenseState string

Trigger-Template:
    Feature: [[$LicenseFeature]]
    Period left: [[$PeriodLeft]]
    License Type: [[$LicenseType]]
    License State: [[$LicenseState]]

Trigger-Commands: { $PeriodLeft eq "Life time" and $LicenseType eq "Permanent" and $LicenseState eq "Active, In Use" }
    SET: $LicenseInEval = no

Trigger-Commands: { $LicenseType eq "EvalRightToUse" and $LicenseState eq "Active, In Use" }
    SET: $LicenseInEval = yes

Output-Triggers:
 Issue Eval License in Use

#########################################################################

Issue:
    Issue Eval License in Use
    
Issue-ID:
    EvalLicenseInUse

Issue-Severity:
    Error

Issue-Description:
    The current device has a Eval License active

Issue-Filter:
    $LicenseInEval eq "yes"

Issue-Details:
    Host        $IPAddress
    Name        $Name
    Model        $Model
    Feature     $LicenseFeature
   

##################################################################################

 

Output of a show license command:

 

show license
Index 1 Feature: appxk9
        Period left: Life time
        License Type: Permanent
        License State: Active, In Use
        License Count: Non-Counted
        License Priority: Medium
Index 2 Feature: uck9
        Period left: Not Activated
        Period Used: 0  minute  0  second
        License Type: EvalRightToUse
        License State: Active, Not in Use, EULA not accepted
        License Count: Non-Counted
        License Priority: None
Index 3 Feature: securityk9
        Period left: Life time
        License Type: Permanent
        License State: Active, In Use
        License Count: Non-Counted
        License Priority: Medium
Index 4 Feature: ipbasek9
        Period left: Life time
        License Type: Permanent
        License State: Active, In Use
        License Count: Non-Counted
        License Priority: Medium
Index 5 Feature: FoundationSuiteK9
        Period left: Life time
        License Type: Permanent
        License State: Active, Not in Use
        License Count: Non-Counted
        License Priority: Medium
Index 6 Feature: AdvUCSuiteK9
        Period left: Not Activated
        Period Used: 0  minute  0  second
        License Type: EvalRightToUse
        License State: Active, Not in Use, EULA not accepted
        License Count: Non-Counted
        License Priority: None
Index 7 Feature: cme-srst
        Period left: Not Activated
        Period Used: 0  minute  0  second
        License Type: EvalRightToUse
        License State: Active, Not in Use, EULA not accepted
        License Count: 0/0  (In-use/Violation)
        License Priority: None
Index 8 Feature: hseck9
Index 9 Feature: throughput
        Period left: 6  days 20 hours
        Period Used: 7  weeks 4  days
        License Type: EvalRightToUse
        License State: Active, In Use
        License Count: Non-Counted
        License Priority: Low
Index 10 Feature: internal_service

 

 

 

 

 

Highlighted

Re: Is there a dept limit on a trigger?

Expert
Posts: 259
1258     0

Based on the output of "show license", only four of the indexes have exactly the four consecutive line matches in your trigger-template.  The others have "Period Used:" in between.

 

You could modify your template to use the (undocumented?) "| ..." modifier which allows zero or N intervening lines of output.  But it's probably easier to just filter the output of "show license" to match on what you're searching for, and leave out Period Left in your template.

 

  show license | inc Feature|EvalRight|Active

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You