This article explains how to collect log files for both Junos OS and Linux based host OS from MX150 device.
The following procedure describes the collecting of log files. Log files in the /var/log directory are required when analyzing an incident in a JTAC Service Request.
MX150 is based on a virtualized architecture. Junos OS runs as vMX virtual machine on Linux host OS KVM Hypervisor. The log directories are created individually on an OS basis and log files should be collected from both OS.
Note: You will need ftp, SSH, HTTP (JWEB) or USB access to copy the logs from MX150 box.
Compress all log files in the /var/log directories the same was as you would in Junos boxes. Please refer the documentation on Compressing Troubleshooting Logs from /var/logs to Send to Juniper Networks Technical Support
user@mx150> file archive compress source /var/log/* destination /var/tmp/junos_varlog.tgz
Move to Linux host prompt. "192.168.1.1" is the fixed address for Linux host via internal connection.
user@mx150> ssh routing-instance __juniper_private4__ [email protected] root@mx150-node:~# <-- "-node" indicates you're in Linux host shell
Note: From 17.4R1, you can use "hypervisor" as name resolution for Linux host instead of private IP address. Also from this revision, you need to input password every time.
user@mx150> ssh routing-instance __juniper_private4__ root@hypervisor root@hypervisor's password:
Archive and compress all log files and put them in /var/tmp.
root@mx150-node:~# tar czf /var/tmp/linuxhost_varlog.tar.gz /var/log/ tar: Removing leading `/' from member names root@mx150-node:~# ls -l /var/tmp | grep varlog -rw-r--r-- 1 root root 958867 Apr 20 06:35 linuxhost_varlog.tar.gz
NOTE: In later release, /var/log directory is symbolic linked. It is not followed target directory by default, needs additional "-h"(–dereference ) option if following output is seen.
root@mx150-node:~# ls -l /var/log lrwxrwxrwx 1 root root 17 Sep 21 06:01 /var/log -> /var/volatile/log
root@mx150-node:~# ls -l /var/tmp/linuxhost_varlog.tar.gz -rw------- 1 root root 119 Oct 5 02:51 linuxhost_varlog.tar.gz <-- shows quite small size.
root@mx150-node:~# tar tvf /var/tmp/linuxhost_varlog.tar.gz lrwxrwxrwx root/root 0 2020-09-21 06:01 var/log -> /var/volatile/log <-- only archived block information.
root@mx150-node:~# tar czfh /var/tmp/linuxhost_varlog.tar.gz /var/log/ <-- add h option. (Using wildcard works as well.) tar: Removing leading `/' from member names
root@mx150-node:~# ls -l /var/tmp/linuxhost_varlog.tar.gz -rw------- 1 root root 1712110 Oct 5 02:54 linuxhost_varlog.tar.gz
Copy the archived file from Linux host to Junos OS VM. "192.168.1.2" is fixed address for Junos VM via internal connection.
root@mx150-node:~# scp /var/tmp/linuxhost_varlog.tar.gz <username> @192.168.1.2:/var/tmp/
Password: linuxhost_varlog.tar.gz 100% 936KB 936.4KB/s 00:00
Note: Unless you enable configuration for SSH login from root user by "set system services ssh root-login allow", you cannot login to Junos as "root".
You can see both logs in /var/tmp on Junos OS. These files can be transferred via FTP, SCP, JWEB, or mounted USB.
user@mx150> file list /var/tmp | match varlog junos_varlog.tgz linuxhost_varlog.tar.gz
2020-10-05: Added note lines for recursive collection with symbolic link.