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