Configuration Basics · Topic 4 of 5

NTP, SNMP, System Logging and Tracing

Learn Junos NTP, SNMP communities and traps, syslog facilities and severities, show log, monitor start and traceoptions for the JNCIA-Junos JN0-106.

  • 5 min
In a nutshell
  • NTP: set system ntp server; check with show ntp associations; set date ntp sets the clock at once.
  • SNMP: community with authorization read-only or read-write, clients to restrict, trap-group ... targets for traps.
  • Syslog statements: destination, facility, severity; files are in /var/log.

What it is

After the first setup, a device needs a few services that make it observable. NTP keeps the clock right, SNMP lets a management station poll the device and receive traps, and system logging (syslog) records events to files, the console, users or a remote server.

Tracing goes deeper than syslog. With traceoptions you tell a single protocol, such as OSPF, to write detailed debug messages to its own trace file.

Eventon the devicesyslogLog fileor remote hostProtocolOSPF or BGPtraceoptionsTrace filein /var/log

How it works

NTP

Accurate time makes log messages from different devices line up and keeps certificates and scheduled commits correct.

[edit system]
user@R1# set ntp server 192.0.2.123
user@R1# set time-zone America/New_York
CommandModePurpose
set system ntp server <address>ConfigurationAdds an NTP server to synchronize with
set system time-zone <zone>ConfigurationSets the local time zone
set date ntp <server>OperationalSets the clock from an NTP server at once
show ntp associationsOperationalLists NTP peers and their state
show ntp statusOperationalShows the local NTP state

If the clock is far off, NTP may not correct it gradually. Running set date ntp once brings the clock close so that normal synchronization can take over.

SNMP

[edit snmp]
user@R1# set location "London DC1"
user@R1# set contact "[email protected]"
user@R1# set community public authorization read-only
user@R1# set community public clients 192.0.2.0/24
user@R1# set trap-group NMS targets 192.0.2.50
StatementPurpose
location and contactText the management station reads from the device
community <name>The community string for SNMPv1 and SNMPv2c
authorization read-only or read-writeWhat the community may do
clientsThe source addresses allowed to use the community
trap-group <name> targets <address>Where the device sends traps

show snmp statistics shows how many SNMP requests and traps the device has handled.

System logging

Each syslog statement chooses a destination, a facility (the type of event) and a minimum severity.

[edit system syslog]
user@R1# set file messages any notice
user@R1# set file messages authorization info
user@R1# set file interactive-commands interactive-commands any
user@R1# set host 192.0.2.60 any warning
user@R1# set user * any emergency
user@R1# set console any critical
DestinationStatement
A local file in /var/logfile <name>
A remote syslog serverhost <address>
Logged-in users' terminalsuser <name> or user * for all
The consoleconsole
FacilityEvents
anyAll facilities
authorizationLogins and authentication
interactive-commandsCommands typed in the CLI
change-logConfiguration changes
kernelThe operating system kernel
daemonSystem processes
firewallFirewall filter log and syslog actions
Severity, most to least severe
emergency, alert, critical, error, warning, notice, info

A severity selects that level and everything more severe. any selects every level, and none turns a facility off for that destination.

Reading the logs

CommandEffect
show logLists the log files
show log messagesShows the messages file
monitor start messagesShows new lines in real time as they are written
monitor stopStops all real-time monitoring
clear log messagesEmpties the file

Add a pipe to narrow the output, for example show log messages | last 20 for the 20 newest lines.

Tracing with traceoptions

[edit protocols ospf traceoptions]
user@R1# set file ospf-trace size 1m files 3
user@R1# set flag hello
user@R1# set flag error
ElementPurpose
file <name>The trace file, written to /var/log
size and filesHow large each file grows and how many old copies are kept
flag <event>What to trace, for example hello or error for OSPF

You read a trace file the same way as a log: show log ospf-trace or monitor start ospf-trace. Many protocols and processes have their own traceoptions, including routing protocols and interfaces.

traceoptionsflag helloospf trace filemonitor startLive outputdelete traceoptionsTracing off
Watch out

Tracing uses CPU and disk space. Trace only what you need, avoid flag all on a busy device, and remove or deactivate traceoptions when you finish.

Common mistakes

Thinking a severity selects only that level. warning also includes error, critical, alert and emergency.

Confusing syslog with traceoptions. Syslog records events across the system. Traceoptions records detailed debug data for one protocol or process.

Expecting monitor start to stop itself. Real-time output keeps appearing until you run monitor stop.

Allowing every SNMP manager. Without clients, the community is not limited to specific source addresses.

Exam tip

show log messages | match <text> combined with | last is the fastest way to find recent events in an exhibit-style question.

What to remember for the exam

  • NTP: set system ntp server; check with show ntp associations; set date ntp sets the clock at once.
  • SNMP: community with authorization read-only or read-write, clients to restrict, trap-group ... targets for traps.
  • Syslog statements: destination, facility, severity; files are in /var/log.
  • Severity order: emergency, alert, critical, error, warning, notice, info; a level includes all more severe levels.
  • show log messages reads a log; monitor start follows it live; monitor stop ends it.
  • traceoptions with file and flag traces one protocol; the file is read with show log.

Check yourself

  • Which messages does set system syslog file messages any warning record?

    Messages of warning severity and above, from every facility, written to /var/log/messages.

  • How do you watch a trace file in real time?

    Use monitor start <file>, for example monitor start ospf-trace, and monitor stop to end it.

  • Which SNMP statement limits which management stations can use a community?

    clients, which lists the allowed source addresses for that community.

Topic 4 of 5 in Configuration Basics

Test yourself on Configuration Basics

The full Juniper JNCIA-Junos JN0-106 question bank has 1,155 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.