Monitoring and automation

Devices log what happens to them as IOS does, and the lab's NMS receives it: syslog in /var/log/syslog, traps in /var/log/snmptrapd.log, flows in nfdump.

Syslog

Router
In global configuration
logging buffered 16384 informationalKeeps messages up to level 6 in the device's buffer.
logging host 10.0.99.30Sends messages to a syslog server, such as the NMS.
logging trap warningsOnly levels 0 to 4 go to the server.
logging source-interface Loopback0The address the messages come from.
logging console criticalOnly levels 0 to 2 on the console.
clock timezone EST -5 0The router's time zone (hours and minutes from UTC).
service timestamps log datetime msec localtime show-timezone yearStamps log messages in local time, with milliseconds, the zone and the year. Without localtime they stay in UTC; an asterisk means the clock is not synchronised by NTP.
service timestamps debug uptimeStamps debug output with the time since boot instead.
logging monitor informationalThe level vty sessions get, once they ask with terminal monitor.
no logging consoleNothing on the console.
service timestamps log datetime msecDates the messages, to the millisecond.
service sequence-numbersNumbers them.
In privileged EXEC
show loggingThe logging settings and the buffer.
clear loggingEmpties the buffer (asks to confirm).
terminal monitorShows log messages and debugs in this vty (SSH) session; the console always shows them up to its level.

SNMP

Router
In global configuration
snmp-server community NTpathRO ro 10A read-only community, allowed from the hosts ACL 10 permits.
snmp-server location Lab rack 1The location the NMS reads.
snmp-server contact noc@ntpath.labThe contact.
snmp-server enable trapsSends traps (link up and down).
snmp-server host 10.0.99.30 version 2c NTpathROWhere the traps go.
In privileged EXEC
show snmp communityThe communities and their ACLs.
show snmp hostThe trap receivers.

From a Linux NMS: snmpget -v2c -c NTpathRO 10.0.99.1 sysName.0 and snmpwalk -v2c -c NTpathRO 10.0.99.1 ifDescr.

SNMPv3 replaces the community with a user. The user belongs to a group, the group sets the lowest security level (noauth, auth or priv) and the view it may read, and the view lists the subtrees it includes or excludes. IOS never shows users in the running configuration.

Router
In global configuration
snmp-server view NMS-VIEW system includedA view: the system group (interfaces, iso and any subtree name or OID work too).
snmp-server view NMS-VIEW sysContact excludedTakes a subtree out of the view; the longest match wins.
snmp-server group NMS-GROUP v3 priv read NMS-VIEWA group that requires authentication and encryption, and reads NMS-VIEW (access ACL limits its sources).
snmp-server user NMSADMIN NMS-GROUP v3 auth sha AuthPass1 priv aes 128 PrivPass1A user: SHA or MD5 for authentication, AES (128, 192, 256), 3DES or DES for privacy.
snmp-server host 10.0.99.30 version 3 priv NMSADMINSNMPv3 traps to a receiver, as that user.
In privileged EXEC
show snmp userEach user: engine ID, authentication and privacy protocols, group.
show snmp groupEach group (and each community as v1 and v2c): security model and level, read and write views.
show snmp viewThe configured views.
show snmp engineIDThe local engine ID, made from the base MAC address.

From the NMS: snmpget -v3 -l authPriv -u NMSADMIN -a SHA -A AuthPass1 -x AES -X PrivPass1 10.0.99.1 sysName.0. net-snmp's errors say where it fails: Unknown user name, Authentication failure (wrong password or hash), Decryption error (privacy), Unsupported security level (the user lacks it), authorizationError (the group requires a higher level), No Such Object (outside the view).

Debug

Router
In privileged EXEC
debug ip icmpLogs each ICMP message the router sends or receives.
debug ip packetEach IP packet the router itself sends or receives (CEF-switched transit traffic doesn't show).
debug ip packet 101Only the packets access list 101 permits.
debug condition ip 10.1.1.20Limits every debug to packets to or from one address.
debug condition interface Gi0/1Limits every debug to one interface. With several conditions, a packet that matches any of them is shown.
show debug conditionThe conditions, numbered.
no debug condition 1Removes one condition (no debug condition all asks to confirm).
show debuggingWhat is being debugged.
undebug allStops every debug.

Traditional NetFlow

One cache per router, keyed by the seven classic fields (addresses, ports, protocol, ToS, input interface). The collector in the labs is nfcapd on UDP 2055.

Router
Under interface Gi0/1
ip flow ingressAdds the packets that come in on the interface to the main cache (ip flow egress: those that leave).
In global configuration
ip flow-export version 9The export format: 1 (the default), 5 or 9.
ip flow-export destination 10.0.99.30 2055The collector and its UDP port (up to two).
ip flow-export source Gi0/1The address the export comes from.
ip flow-cache timeout active 1How long a busy flow stays before it is exported (minutes).
In privileged EXEC
show ip cache flowThe packet size distribution, the cache counters and each flow.
show ip flow exportVersion, source, destinations and how many flows went out.
show ip flow interfaceWhere NetFlow collects.

Flexible NetFlow

Router
Under flow record REC
match ipv4 source addressA key field: flows differ by source address.
match ipv4 destination addressAnd by destination.
collect counter bytesA non-key field: what is counted per flow.
Under flow exporter EXP
destination 10.0.99.30The collector (the NMS).
transport udp 2055Its port.
Under flow monitor MON
record RECThe monitor uses the record.
exporter EXPAnd sends to the exporter.
Under interface Gi0/1
ip flow monitor MON inputWatches what arrives on Gi0/1.
In privileged EXEC
show flow monitor MON cacheThe flows seen so far.
show flow exporter statisticsWhat was exported.

EEM applets

Router
Under event manager applet WAN-DOWN
event syslog pattern "Interface GigabitEthernet0/0, changed state to down"Runs when a log message matches.
action 1.0 syslog msg "WAN link is down"Logs a message.
action 2.0 cli command "enable"CLI actions start in user EXEC, as in IOS.
Under event manager applet SAVE
event noneAn applet you run by hand.
action 1.0 cli command "enable"First action.
action 2.0 cli command "write memory"Second action: labels run in text order.
In privileged EXEC
event manager run SAVERuns it.
show event manager policy registeredThe applets.
show event manager history eventsWhen each one ran.

RESTCONF and NETCONF

Router
In global configuration
ip http secure-serverThe HTTPS server RESTCONF runs on.
ip http authentication localLogins use the local users (privilege 15).
restconfTurns RESTCONF on.
netconf-yangTurns NETCONF on, on TCP 830.

From a Linux laptop: curl -k -u admin:Cisco123 -H "Accept: application/yang-data+json" https://10.0.99.1/restconf/data/Cisco-IOS-XE-native:native/hostname returns JSON (ask for application/yang-data+xml to get XML), with the real status codes for a wrong path, user or media type. python3 -m json.tool formats a saved answer, and ssh admin@10.0.99.1 -p 830 -s netconf opens a NETCONF session.

Model-driven telemetry

A configured (dial-out) subscription, as IOS XE runs it: the router streams one YANG path to a collector over gRPC. It is valid with netconf-yang running, the yang-push stream, a known XPath, an encoding and an update policy the path supports (the CPU paths are periodic only). Its receiver connects when the collector listens on that TCP port.

Router
In global configuration
netconf-yangThe YANG infrastructure telemetry needs.
telemetry ietf subscription 101A subscription.
Under telemetry ietf subscription 101
encoding encode-kvgpbKey-value Google Protocol Buffers, for gRPC.
filter xpath /process-cpu-ios-xe-oper:cpu-usage/cpu-utilization/five-secondsWhat to stream.
stream yang-pushThe stream.
update-policy periodic 1000Every 10 seconds (centiseconds); update-policy on-change where the path supports it.
receiver ip address 10.0.99.30 57500 protocol grpc-tcpThe collector.
In privileged EXEC
show telemetry ietf subscription allEach subscription: Valid or Invalid.
show telemetry ietf subscription 101 detailStream, filter, policy, encoding and receivers.
show telemetry ietf subscription 101 receiverEach receiver's state: Connected, Connecting or Disconnected.