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
- NTP:
set system ntp server; check withshow ntp associations;set date ntpsets the clock at once. - SNMP:
communitywithauthorization read-onlyorread-write,clientsto restrict,trap-group ... targetsfor 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.
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
| Command | Mode | Purpose |
|---|---|---|
set system ntp server <address> | Configuration | Adds an NTP server to synchronize with |
set system time-zone <zone> | Configuration | Sets the local time zone |
set date ntp <server> | Operational | Sets the clock from an NTP server at once |
show ntp associations | Operational | Lists NTP peers and their state |
show ntp status | Operational | Shows 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
| Statement | Purpose |
|---|---|
location and contact | Text the management station reads from the device |
community <name> | The community string for SNMPv1 and SNMPv2c |
authorization read-only or read-write | What the community may do |
clients | The 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
| Destination | Statement |
|---|---|
| A local file in /var/log | file <name> |
| A remote syslog server | host <address> |
| Logged-in users' terminals | user <name> or user * for all |
| The console | console |
| Facility | Events |
|---|---|
any | All facilities |
authorization | Logins and authentication |
interactive-commands | Commands typed in the CLI |
change-log | Configuration changes |
kernel | The operating system kernel |
daemon | System processes |
firewall | Firewall 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
| Command | Effect |
|---|---|
show log | Lists the log files |
show log messages | Shows the messages file |
monitor start messages | Shows new lines in real time as they are written |
monitor stop | Stops all real-time monitoring |
clear log messages | Empties 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
| Element | Purpose |
|---|---|
file <name> | The trace file, written to /var/log |
size and files | How 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.
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.
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 withshow ntp associations;set date ntpsets the clock at once. - SNMP:
communitywithauthorization read-onlyorread-write,clientsto restrict,trap-group ... targetsfor 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 messagesreads a log;monitor startfollows it live;monitor stopends it.traceoptionswithfileandflagtraces one protocol; the file is read withshow log.
Check yourself
Which messages does
set system syslog file messages any warningrecord?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 examplemonitor start ospf-trace, andmonitor stopto 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.