вторник, март 29, 2022

Generate test syslog message on Junos

 
The logger utility is a shell command, and so the user must first start a system shell by invoking the start shell command:

    user@Junos> start shell %

The logger utility has the following command syntax: logger -e EVENT_ID -p SYSLOG_PRIORITY -d DAEMON -a ATTRIBUTE=VALUE MESSAGE. Only the EVENT_ID is required, and it must be entered entirely in uppercase:

    % logger -e UI_COMMIT
    % logger -e UI_COMMIT -d mgd "This is a fake commit."

 Some syslog tips

I’m ONLY sending messages to external host 192.168.56.11 if the facility is ‘external’ AND the severity is ‘info’ or greater (ie. not debug) AND the regex of the message matches LICENSE. Otherwise, we’ll likely have a local catch-all configured with any-any to locally log messages we may not be explicitly interested in looking at on the remote server.

root@vSRX-NAT-GW> show configuration
system {
  syslog {
    host 192.168.56.11 {
      external info;
      match LICENSE;
    }
   file messages {
     any any;
     authorization info;
   }
   file interactive-commands {
     interactive-commands any;
   }
}


The following configuration command will transfer output from all activated traces to your syslog server: 

set system tracing destination-override syslog host 10.0.0.13 

To exclude some of traces to be send to remote syslog (for example dhcp): 

 set forwarding-options dhcp traceoptions no-remote-trace


To send information from syslog to every (currently) logged in user console:  (except matching regex "Login attempt")

set system syslog user * any critical
set system syslog user * authorization info
set system syslog user * interactive-commands notice
set system syslog user * match "!(.*Login attempt.*)"