Reply
Highlighted

template trigger matching

JBrown_1
Techie
Posts: 26
5940     0

I created a new script and it does not seem to be matching the template trigger properly.

Below is a portion of the script, the process log, and the session log.

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

Action-Commands: show vlan id $vlanNumber

SET: $license = $device_devicelicensed

Action-Timeout: 10

Output-Triggers: vlancheck

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

Trigger: vlancheck

Trigger-Template:

VLAN 3 not found

Trigger-Filter: $name like /PUB/ or $name like /ACCESS/ or $name like /5548/

Trigger-Commands: SET: $vlanExists = "false"

Output-Triggers: createVlan

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

 

I dont think NetMRI is

Adviser
Posts: 373
5941     0

I dont think NetMRI is treating the output as a true output, more like an error.  I would open a case on this to make sure.

I would just do a show vlan id

Loop though each output looking for a line starting with 3 with somename and active.  If I dont find it then add it.

 

Router# show vlan id 

 
VLAN Name                             Status    Ports
---- -------------------------------- --------- ------------------------------
1    default                          active    Fa5/7, Fa5/12
2    VLAN0002                         active
3    VLAN0003                         act/lshut
4    VLAN0004                         act/lshut
5    VLAN0005                         active
6    VLAN0006                         active
10   VLAN0010                         active
20   VLAN0020                         active
Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

I'm not sure why this isn't

Adviser
Posts: 53
5941     0

I'm not sure why this isn't working, it should be. Perhaps try adding a .* to the beginning and end of the Trigger-Template to see if that helps (e.g. .*VLAN 3 not found.*). Also, could you hover over the ? in the title to the right of "Output: 'Check for VLAN'" and post the text shown in the hover?

Thanks,

- Chris

 

I cannot get my snipping tool

JBrown_1
Techie
Posts: 26
5941     0

I cannot get my snipping tool to capture while I hover the mouse, but in the box when I hover is one double qoute and that is all.

"

 

I have hundreds of VLANs so I

JBrown_1
Techie
Posts: 26
5941     0

I have hundreds of VLANs so I would rather not do a show VLAN and have it look for one line.

I tried the .* before and after with the same result.

I hovered over the ? again

JBrown_1
Techie
Posts: 26
5941     0

I hovered over the ? again and saw one double quote again "

Sorry about that. I thought

Adviser
Posts: 53
5941     0

Sorry about that. I thought the hover text showed the CLI buffer being processed by the given trigger (that would be a handy feature Smiley Happy), but, instead, it shows the text of the Trigger-Description, if defined. I'm still puzzled as to why this isn't working. How about trying this:

 

Trigger-Variables:
    $data_buffer    string

Trigger-Template:
    [[$data_buffer]]

Trigger-Filter: true

Trigger-Commands:
    DEBUG: $data_buffer
 

This should show what data is in the buffer being processed.

Thanks,

- Chris

 

Interesting, it appears to

JBrown_1
Techie
Posts: 26
5941     0

Interesting, it appears to skip the part I actually care about in the line.  Here are the outputs.

1102F9R4-7009-2-PUB# terminal terminal-type vt100

1102F9R4-7009-2-PUB# terminal no monitor

1102F9R4-7009-2-PUB# terminal length 0

1102F9R4-7009-2-PUB# terminal width 511

1102F9R4-7009-2-PUB# show vlan id 3

VLAN 3 not found in current VLAN database

1102F9R4-7009-2-PUB# config terminal

Enter configuration commands, one per line. End with CNTL/Z.

1102F9R4-7009-2-PUB(config)# end

Script snipit -

JBrown_1
Techie
Posts: 26
5941     0

Script snipit -

Action:
    Check for VLAN


Action-Description:
    This action is executed once for every device that matches the
    Script-Filter defined above.  It will look for vlan id.  

Action-Commands:
    show vlan id $vlanNumber
    SET: $license = $device_devicelicensed

Action-Timeout: 10

Output-Triggers:
    vlancheck


#########################################################################
Trigger:
    vlancheck

Trigger-Variables:
    $data_buffer    string

Trigger-Template:
    [[$data_buffer]]

Trigger-Filter: true

Trigger-Commands:
    DEBUG: $data_buffer

 

Dealing with Error Output

MGriffin
Techie
Posts: 37
5941     0

I have found that dealing with errors works better when the script is in this format, instead of the trigger catching the error calling additional triggers:

(this is a working CCS)

 


Script:
 Add SNMP community String

Script-Description:
 This script adds an SNMP community string to a cisco switch or router,
 if SNMP is enabled.
 
Script-Filter:
 $Vendor eq "Cisco"
 and $Type in ["Switch", "Switch-Router", "Router"]
 and $sysDescr like /IOS/

Script-Variables:
 $NewCommunityString string
 $RW   boolean
 
########################################################################
Action:
 Confirm SNMP

Action-Description:
 Make sure SNMP is enabled on the device

Action-Commands:
 SET: $snmpEnabled = "true"
 show snmp
 
Output-Triggers:
 Determine SNMP Status
 SNMP Disabled
 Determine RW String
 Add Community String
 
########################################################################
Trigger:
 Determine SNMP Status

Trigger-Description:
 Determine whether SNMP is enabled or disabled
 
Trigger-Template:
 // cisco devices return this string if snmp is disabled
 %SNMP agent not enabled
 
Trigger-Commands:
 SET: $snmpEnabled = "false"
 
########################################################################
Trigger:
 Determine RW String

Trigger-Description:
 Determine whether the string should be Read-Write or Read-Only
 
Trigger-Filter:
 true
 
Trigger-Commands:{$RW eq "off"} 
 SET: $RW = "RO"
 
Trigger-Commands:{$RW eq "on"} 
 SET: $RW = "RW"
 
########################################################################
Trigger:
 Add Community String

Trigger-Description:
 Adds the given community string to the device(s)
 
Trigger-Filter:
 $snmpEnabled eq "true"

Trigger-Commands:
 //cisco commands to add string here
 snmp-server community $NewCommunityString $RW
 

Output-Triggers:
 Community String Added

########################################################################
Issue:
 Community String Added

Issue-ID:
 newCommunityString
 
Issue-Severity:
 Info
 
Issue-Description:
 Show which devices the community string was added to, and the string added

Issue-Filter:
 $snmpEnabled eq "true"
 
Issue-Details:
      Host          $IPAddress
       Name          $Name
 Community String $NewCommunityString
 RW or RO  $RW

########################################################################
Issue:
 SNMP Disabled

Issue-ID:
 snmpDisabled
 
Issue-Severity:
 Error
 
Issue-Description:
 SNMP is not enabled on this device

Issue-Filter:
 $snmpEnable eq "false"
 
Issue-Details:
      Host          $IPAddress
       Name          $Name

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

Hi Joe,

Adviser
Posts: 53
5941     0

Hi Joe,

Is the device against which you are running the script one of the following:

1. Cisco Nexus or running NX-OS

2. Cisco ACE

3. Cisco Switch, model N7Kc70

If any of the above, I can see where the problem lies in the job engine. If this is the case, unfortunately, I don't see a way to work around this at the moment short of rewriting the logic so that the output "not found" is avoided (or isn't required). It seems that any output up to and including the "not found" is being weeded out for the above devices.

Thanks,

- Chris

 

Yes, it is a Nexus 7K switch.

JBrown_1
Techie
Posts: 26
5941     0

Yes, it is a Nexus 7K switch.  

I will try changing the logic of my code to look for the reverse and call appropriate trigger based on opposite expectation.

 

Thank you Chris.

I am having a hard time

JBrown_1
Techie
Posts: 26
5941     0

I am having a hard time coming up with a work around.  Is this something that will be addressed in a patch or future release?

Hi Joe,

Adviser
Posts: 53
5941     0

Hi Joe,

I'd recommend opening a support case for this so that it can be tracked and addressed properly. A code change will likely be needed.

Thanks,

- Chris

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You