1#!/usr/bin/env bash 2# 3# config: 123 30 4# @brief: Collect network information 5# 6 7. $DREPORT_INCLUDE/functions 8 9file_name="network.log" 10 11#netstat 12add_cmd_output "echo $'[netstat]'" "$file_name" "netstat" 13add_cmd_output "netstat -nr" "$file_name" "netstat" 14 15#eth0 16eth0_file="/etc/systemd/network/00-bmc-eth0.network" 17if [ -f $eth0_file ]; then 18 add_cmd_output "echo $'\n[eth0]'" "$file_name" "eth0" 19 add_cmd_output "cat $eth0_file" "$file_name" "eth0" 20fi 21 22#eth1 23eth1_file="/etc/systemd/network/00-bmc-eth1.network" 24if [ -f $eth1_file ]; then 25 add_cmd_output "echo $'\n[eth1]'" "$file_name" "eth1" 26 add_cmd_output "cat $eth1_file" "$file_name" "eth1" 27fi 28 29 30#network interface statistics 31procnetdev_file="/proc/net/dev" 32if [ -f $procnetdev_file ]; then 33 add_cmd_output "echo $'\n[proc_net_dev]'" "$file_name" "proc_net_dev" 34 add_cmd_output "cat $procnetdev_file" "$file_name" "proc_net_dev" 35fi 36 37#active tcp connections 38activetcp="/proc/net/tcp" 39if [ -f $activetcp ]; then 40 add_cmd_output "echo $'\n[activetcp]'" "$file_name" "activetcp" 41 add_cmd_output "cat $activetcp" "$file_name" "activetcp" 42fi 43 44#Load average 45loadavg="cat /proc/loadavg" 46if [ -f $activetcp ]; then 47 add_cmd_output "echo $'\n[Load average]'" "$file_name" "loadaverage" 48 add_cmd_output "cat $loadavg" "$file_name" "loadaverage" 49fi 50