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 | 1e68a88 | 2022-04-13 02:47:08 -0500 | [diff] [blame] | 7 | # shellcheck disable=SC1091 |
| 8 | . "$DREPORT_INCLUDE"/functions |
Marri Devender Rao | 1640a3d | 2022-03-24 03:28:59 -0500 | [diff] [blame] | 9 | |
| 10 | file_name="network.log" |
| 11 | |
Marri Devender Rao | 1e68a88 | 2022-04-13 02:47:08 -0500 | [diff] [blame] | 12 | #ip addr |
| 13 | add_cmd_output "echo $'[ip addr]'" "$file_name" "ip addr" |
| 14 | add_cmd_output "ip addr" "$file_name" "ip addr" |
| 15 | |
Marri Devender Rao | 1640a3d | 2022-03-24 03:28:59 -0500 | [diff] [blame] | 16 | #netstat |
Marri Devender Rao | 1e68a88 | 2022-04-13 02:47:08 -0500 | [diff] [blame] | 17 | add_cmd_output "echo $'\n[netstat]'" "$file_name" "netstat" |
Marri Devender Rao | 1640a3d | 2022-03-24 03:28:59 -0500 | [diff] [blame] | 18 | add_cmd_output "netstat -nr" "$file_name" "netstat" |
| 19 | |
| 20 | #eth0 |
| 21 | eth0_file="/etc/systemd/network/00-bmc-eth0.network" |
| 22 | if [ -f $eth0_file ]; then |
| 23 | add_cmd_output "echo $'\n[eth0]'" "$file_name" "eth0" |
| 24 | add_cmd_output "cat $eth0_file" "$file_name" "eth0" |
| 25 | fi |
| 26 | |
| 27 | #eth1 |
| 28 | eth1_file="/etc/systemd/network/00-bmc-eth1.network" |
| 29 | if [ -f $eth1_file ]; then |
| 30 | add_cmd_output "echo $'\n[eth1]'" "$file_name" "eth1" |
| 31 | add_cmd_output "cat $eth1_file" "$file_name" "eth1" |
| 32 | fi |
| 33 | |
| 34 | |
| 35 | #network interface statistics |
| 36 | procnetdev_file="/proc/net/dev" |
| 37 | if [ -f $procnetdev_file ]; then |
| 38 | add_cmd_output "echo $'\n[proc_net_dev]'" "$file_name" "proc_net_dev" |
| 39 | add_cmd_output "cat $procnetdev_file" "$file_name" "proc_net_dev" |
| 40 | fi |
| 41 | |
| 42 | #active tcp connections |
| 43 | activetcp="/proc/net/tcp" |
| 44 | if [ -f $activetcp ]; then |
Marri Devender Rao | 1e68a88 | 2022-04-13 02:47:08 -0500 | [diff] [blame] | 45 | add_cmd_output "echo $'\n[activetcp]'" "$file_name" "active tcp" |
| 46 | add_cmd_output "cat $activetcp" "$file_name" "active tcp" |
Marri Devender Rao | 1640a3d | 2022-03-24 03:28:59 -0500 | [diff] [blame] | 47 | fi |
| 48 | |
| 49 | #Load average |
Marri Devender Rao | 1e68a88 | 2022-04-13 02:47:08 -0500 | [diff] [blame] | 50 | loadavg="/proc/loadavg" |
| 51 | if [ -f $loadavg ]; then |
| 52 | add_cmd_output "echo $'\n[Load average]'" "$file_name" "load average" |
| 53 | add_cmd_output "cat $loadavg" "$file_name" "load average" |
Marri Devender Rao | 1640a3d | 2022-03-24 03:28:59 -0500 | [diff] [blame] | 54 | fi |