Reply

Show module script

Authority
Posts: 13
5338     2

Hello,

 

I'm trying to write script to check 7k and 6k modules, by using "show module" command. The status could be more than one (other, unknown, faulty, errdisable, power-deny and power-bad). on the trigger-variables can I use OR to check the status?

 

Trigger-Variables:

                    $number int

                    $status  /\w+other/ OR /\w+unknown/ OR /\w+faulty/ OR /\w+errdisable/ OR /\w+power-deny/ OR /\w+power-bad/ string 

 

Thank you,

Re: Show module script

Adviser
Posts: 12
5338     2

I haven't tested OR on Trigger Variables. However, I doubt if it will work. 

 

Since you already have the output of 'show module' handy, you can use the Regular expression Test tool within NetMRI to check if the template matches the output.

 

To access the test too, Login to Web UI and on a new Tab, navigate to this link

 

Your-NetMRI-URL/netmri/ccs/tx/regex_test/index.tdf

 

This should directly open the test tool on the Tab

Re: Show module script

Expert
Posts: 70
5338     2

I'm uncertain how you expect to actually match on this but you can accomplish the logical OR like this:

  $status  /(\w+other|\w+unknown|\w+faulty|\w+errdisable|\w+power-deny|\w+power-bad)/ string

 

Just realize that $status will end up including whatever "\w+" matches before the actual status.  If you want to end up with $status containing just the status string, then you'll probably be better off including the "\w+", or whatever uniquely preceeds the status, in the Template.

Re: Show module script

Authority
Posts: 13
5338     2

Thanks all for replying. I found the solution.

 

 

Script-Filter:

$Vendor eq "Cisco" and
$Model in ["N7Kc7010", "WS-C6509-E", "N77c7710"]


#########################################################################
Action:
show module | begin Online | end Module-Type

 

Action-Description:
Execute the "show module"show module | begin Online | end Module-Type" command and process the output

 

Action-Commands:
SET: $matchFound = "no"
terminal length 0
show module | begin Online | end Module-Type

 

Output-Triggers:
Process Output

########################################################################
Trigger:
Process Output

Trigger-Variables:
$modNum int
$state /\w+/

 

Trigger-Template:
[[$modNum]] [[$state]]

Trigger-Commands: { $state ne "Pass" }
SET: $matchFound = "yes"

Trigger-Commands: { $state eq "Pass" }
SET: $matchFound = "no"

Output-Triggers:
Bad Module

 

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


Issue:
Bad Module

Issue-ID:
BadModule

Issue-Severity:
error

Issue-Description:
If the above matched the criteria, display an error with affected switch info

Issue-Filter:
$matchFound eq "yes"

Issue-Details:

Host $IPAddress
Name $name
Module_Num $modNum
State $state


## End of Script ##################################################################

Note: Create the Custom Issues first. 

 

## Custom Issues #########################################

 

Issue ID: BadModule

 

Name: Bad Module

 

Component: Devices

 

Penalty: Stability

 

Detail Columns:

                         Host,string
                         Name,string
                         Module_Num,string
                         State,string

Showing results for 
Search instead for 
Did you mean: 

Recommended for You