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 informational
Keeps messages up to level 6 in the device's buffer.
logging host 10.0.99.30
Sends messages to a syslog server, such as the NMS.
logging trap warnings
Only levels 0 to 4 go to the server.
logging source-interface Loopback0
The address the messages come from.
logging console critical
Only levels 0 to 2 on the console.
clock timezone EST -5 0
The router's time zone (hours and minutes from UTC).
service timestamps log datetime msec localtime show-timezone year
Stamps 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 uptime
Stamps debug output with the time since boot instead.
logging monitor informational
The level vty sessions get, once they ask with terminal monitor.
no logging console
Nothing on the console.
service timestamps log datetime msec
Dates the messages, to the millisecond.
service sequence-numbers
Numbers them.
In privileged EXEC
show logging
The logging settings and the buffer.
clear logging
Empties the buffer (asks to confirm).
terminal monitor
Shows 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 10
A read-only community, allowed from the hosts ACL 10 permits.
snmp-server location Lab rack 1
The location the NMS reads.
snmp-server contact noc@ntpath.lab
The contact.
snmp-server enable traps
Sends traps (link up and down).
snmp-server host 10.0.99.30 version 2c NTpathRO
Where the traps go.
In privileged EXEC
show snmp community
The communities and their ACLs.
show snmp host
The 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 included
A view: the system group (interfaces, iso and any subtree name or OID work too).
snmp-server view NMS-VIEW sysContact excluded
Takes a subtree out of the view; the longest match wins.
snmp-server group NMS-GROUP v3 priv read NMS-VIEW
A group that requires authentication and encryption, and reads NMS-VIEW (access ACL limits its sources).
A 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 NMSADMIN
SNMPv3 traps to a receiver, as that user.
In privileged EXEC
show snmp user
Each user: engine ID, authentication and privacy protocols, group.
show snmp group
Each group (and each community as v1 and v2c): security model and level, read and write views.
show snmp view
The configured views.
show snmp engineID
The 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 icmp
Logs each ICMP message the router sends or receives.
debug ip packet
Each IP packet the router itself sends or receives (CEF-switched transit traffic doesn't show).
debug ip packet 101
Only the packets access list 101 permits.
debug condition ip 10.1.1.20
Limits every debug to packets to or from one address.
debug condition interface Gi0/1
Limits every debug to one interface. With several conditions, a packet that matches any of them is shown.
show debug condition
The conditions, numbered.
no debug condition 1
Removes one condition (no debug condition all asks to confirm).
show debugging
What is being debugged.
undebug all
Stops 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 ingress
Adds 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 9
The export format: 1 (the default), 5 or 9.
ip flow-export destination 10.0.99.30 2055
The collector and its UDP port (up to two).
ip flow-export source Gi0/1
The address the export comes from.
ip flow-cache timeout active 1
How long a busy flow stays before it is exported (minutes).
In privileged EXEC
show ip cache flow
The packet size distribution, the cache counters and each flow.
show ip flow export
Version, source, destinations and how many flows went out.
show ip flow interface
Where NetFlow collects.
Flexible NetFlow
Router
Under flow record REC
match ipv4 source address
A key field: flows differ by source address.
match ipv4 destination address
And by destination.
collect counter bytes
A non-key field: what is counted per flow.
Under flow exporter EXP
destination 10.0.99.30
The collector (the NMS).
transport udp 2055
Its port.
Under flow monitor MON
record REC
The monitor uses the record.
exporter EXP
And sends to the exporter.
Under interface Gi0/1
ip flow monitor MON input
Watches what arrives on Gi0/1.
In privileged EXEC
show flow monitor MON cache
The flows seen so far.
show flow exporter statistics
What 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 none
An 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 SAVE
Runs it.
show event manager policy registered
The applets.
show event manager history events
When each one ran.
RESTCONF and NETCONF
Router
In global configuration
ip http secure-server
The HTTPS server RESTCONF runs on.
ip http authentication local
Logins use the local users (privilege 15).
restconf
Turns RESTCONF on.
netconf-yang
Turns 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.