Wiki Markup |
---|
\\
!worddavf0fa7487cbf6a8024a1736c81e74bdf1.png|height=331,width=247!
\\ |
As
...
previously
...
noted,
...
Trigger-Commands
...
are
...
the
...
looping
...
mechanism
...
for
...
CCS
...
scripts,
...
though
...
simple
...
IF-THEN
...
logical
...
constructs
...
can
...
be
...
defined
...
in
...
other
...
attributes.
...
The
...
sample
...
script
...
in
...
this
...
section
...
uses
...
two
...
simple
...
iterations
...
of
...
automated
...
Cisco
...
command
...
line
...
operations
...
to
...
illustrate
...
nested
...
loops
...
in
...
CCS.
...
You
...
choose
...
the
...
device,
...
devices
...
or
...
device
...
group
...
against
...
which
...
the
...
script
...
runs.
...
Once
...
that's
...
done,
...
the
...
script
...
executes
...
beginning
...
with
...
the
...
script-filter,
...
which
...
filters
...
out
...
all
...
devices
...
in
...
the
...
chosen
...
device
...
group
...
except
...
for
...
specific
...
router
...
model
...
types.
...
Script-Filter:
...
$Vendor
...
eq
...
"Cisco"
...
&&
...
$Model
...
in
...
\["2811",
...
"2821",
...
"2621XM"\]
...
The
...
single
...
Action
...
section
...
executes
...
a
...
simple
...
loop
...
of
...
Cisco
...
CLI
...
commands
...
against
...
every
...
device
...
that
...
matches
...
the
...
Script-Filter.
...
The
...
output
...
is
...
contained
...
in
...
a
...
memory
...
buffer,
...
log
...
messages
...
written
...
and
...
the
...
output
...
is
...
also
...
written
...
to
...
a
...
file
...
using
...
the
...
ARCHIVE
...
command.
...
Note
...
that
...
the
...
Log
...
and
...
ARCHIVE
...
directives
...
do
...
not
...
appear
...
in
...
the
...
Process
...
Log.
...
Action-Commands:
...
\{
...
$type
...
eq
...
"Router"
...
\}
...
ARCHIVE
...
($ipaddress.txt):
...
show
...
int
...
summ
...
LOG-INFO:
...
Router's
...
interface
...
list
...
has
...
been
...
written
...
to
...
file
...
sh
...
int
...
LOG-INFO:
...
issued
...
another
...
sh
...
int
...
command
...
for
...
full
...
interface
...
config
...
Output-Triggers:
...
Show
...
Ethernet
...
Interfaces
...
Then,
...
the
...
Output-Trigger
...
is
...
called
...
for
...
each
...
matching
...
device.
...
This
...
represents
...
the
...
nested
...
loop,
...
which
...
starts
...
by
...
establishing
...
a
...
Trigger-Template
...
and
...
a
...
Trigger-Variable,
...
which
...
uses
...
a
...
regular
...
expression.
...
The
...
trigger
...
matches
...
the
...
template
...
against
...
the
...
output
...
from
...
the
...
*sh*
...
*int*
...
command.
...
For
...
matching
...
devices,
...
at
...
least
...
one
...
interface
...
will
...
match
...
the
...
template.
...
In
...
the
...
first
...
trigger
...
execution,
...
a
...
single
...
template
...
match
...
appears,
...
showing
...
FastEthernet0/0
...
in
...
red.
...
Then,
...
using
...
a
...
Trigger-Command
...
attribute,
...
the
...
script
...
issues
...
a
...
sh
...
int
...
$ifName
...
command
...
(note
...
the
...
use
...
of
...
the
...
variable)
...
and
...
appends
...
the
...
response
...
output
...
into
...
the
...
associated
...
text
...
file.
...
Trigger:
...
Show
...
Ethernet
...
Interfaces
...
Trigger-Variables:
...
\\
...
$ifName
...
"/FastEthernet\[^
...
\]*/"
...
Trigger-Template:
...
\[\[$ifName\]\]
...
is
...
.+,
...
line
...
protocol
...
is
...
.+
...
Trigger-Filter:
...
$ifName
...
eq
...
"FastEthernet0/0"
...
|
...
$ifName
...
eq
...
"FastEthernet0/1"
...
Trigger-Commands:
...
ARCHIVE
...
($ipaddress.txt):
...
sh
...
int
...
$ifName
...
LOG-INFO:
...
Router's
...
Ethernet
...
port
...
configs
...
have
...
been
...
written
...
to
...
file
...
<span
...
style="color:
...
#231f20"><strong>Script</strong></span>
...
<span
...
style="color:
...
#231f20"><strong>Section</strong></span><span
...
style="color:
...
#231f20"><strong>Action</strong></span>
...
<span
...
style="color:
...
#231f20"><strong>Section</strong></span><span
...
style="color:
...
#231f20"><strong>Trigger</strong></span><span
...
style="color:
...
#231f20">Simple</span>
...
<span
...
style="color:
...
#231f20">Trigger</span><span
...
style="color:
...
#231f20">Login</span><span
...
style="color:
...
#231f20"><strong>sh</strong></span>
...
<span
...
style="color:
...
#231f20"><strong>int</strong></span>
...
<span
...
style="color:
...
#231f20"><strong>summ</strong></span>
...
\\
...
<span
...
style="color:
...
#231f20">Output</span><span
...
style="color:
...
#231f20">Output</span><span
...
style="color:
...
#231f20"><strong>sh</strong></span>
...
<span
...
style="color:
...
#231f20"><strong>int</strong></span>
...
<span
...
style="color:
...
#231f20"><strong>$ifname</strong></span><span
...
style="color:
...
#231f20"><strong>Devices/</strong></span>
...
<span
...
style="color:
...
#231f20"><strong>Device-Group</strong></span>As
...
shown
...
in
...
the
...
Job
...
Details
...
Viewer
...
example,
...
a
...
second
...
iteration
...
of
...
the
...
loop
...
executes
...
for
...
the
...
sh
...
int
...
$ifName
...
command
...
on
...
the
...
router
...
(because
...
the
...
router
...
has
...
two
...
Ethernet
...
ports)
...
and
...
the
...
text
...
output
...
is
...
appended
...
to
...
the
...
same
...
text
...
file.
...
The
...
output
...
from
...
the
...
original
...
*sh*
...
*int*
...
*summ*
...
command
...
and
...
from
...
the
...
*two*
...
*sh*
...
*int*
...
*FastEthernet*
...
commands
...
is
...
concatenated
...
to
...
the
...
same
...
file.
...
The
...
trigger
...
executes
...
at
...
least
...
once
...
for
...
any
...
router
...
device
...
whose
...
Ethernet
...
interface
...
CLI
...
name
...
resembles
...
FastEthernet\[^
...
\]*
...
and
...
in
...
this
...
case
...
executes
...
twice.
...
It's
...
a
...
simple
...
matter,
...
on
...
a
...
Catalyst
...
switch
...
with
...
24
...
or
...
48
...
ports,
...
and
...
a
...
slightly
...
modified
...
script,
...
to
...
automatically
...
execute
...
the
...
loop
...
24
...
or
...
48
...
times.
...
First,
...
change
...
the
...
Script-Filter
...
specifications:
...
Script-Filter:
...
$Vendor
...
eq
...
"Cisco"
...
&&
...
$Model
...
in
...
\["catalyst295024"\]
...
Note
...
that
...
all
...
arguments
...
are
...
case-sensitive.
...
In
...
this
...
case,
...
if
...
you
...
wrote
...
"Catalyst295024"
...
the
...
script
...
would
...
skip
...
all
...
switch
...
devices
...
this
...
it
...
was
...
intended
...
to
...
run
...
against,
...
because
...
$Model
...
wouldn't
...
find
...
a
...
match.
...
Action-Commands:
...
\{
...
$type
...
eq
...
"Switch"
...
\}
...
Then,
...
to
...
enforce
...
the
...
loop
...
automatically,
...
simply
...
remove
...
the
...
Trigger-Filter,
...
because
...
you
...
don't
...
need
...
it
...
given
...
that
...
all
...
ports
...
on
...
the
...
device
...
type
...
are
...
FastEthernet0/*
...
(also,
...
you
...
may
...
have
...
either
...
a
...
Trigger-Filter
...
or
...
a
...
Trigger-Template
...
or
...
both,
...
depending
...
on
...
the
...
script;
...
you
...
must
...
have
...
at
...
least
...
one
...
of
...
the
...
two):
...
# Trigger-Filter:
...
# $ifName eq "FastEthernet0/0" | $ifName eq "FastEthernet0/1"
The same shint commands execute for every port on the chosen devices; the Status Logs and Process Logs, and the written text file, are substantially longer. For a 24-port Catalyst, each device writes out a file nearly 700 lines in length.