2023-11-02T02:28:58.png

[root@localhost input.exec]# cat ip_counter_from_snmp.sh

!/bin/bash

content=$(cat /proc/net/snmp | grep "Ip:" | tail -n 1)

value=$(echo $content | awk '{print $2}')
echo "ip_counter_from_snmp_Forwarding{} $value"

value=$(echo $content | awk '{print $3}')
echo "ip_counter_from_snmp_DefaultTTL{} $value"

value=$(echo $content | awk '{print $4}')
echo "ip_counter_from_snmp_InReceives{} $value"

value=$(echo $content | awk '{print $5}')
echo "ip_counter_from_snmp_InHdrErrors{} $value"

value=$(echo $content | awk '{print $6}')
echo "ip_counter_from_snmp_InAddrErrors{} $value"

value=$(echo $content | awk '{print $7}')
echo "ip_counter_from_snmp_ForwDatagrams{} $value"

value=$(echo $content | awk '{print $8}')
echo "ip_counter_from_snmp_InUnknownProtos{} $value"

value=$(echo $content | awk '{print $9}')
echo "ip_counter_from_snmp_InDiscards{} $value"

value=$(echo $content | awk '{print $10}')
echo "ip_counter_from_snmp_InDelivers{} $value"

value=$(echo $content | awk '{print $11}')
echo "ip_counter_from_snmp_OutRequests{} $value"

value=$(echo $content | awk '{print $12}')
echo "ip_counter_from_snmp_OutDiscards{} $value"

value=$(echo $content | awk '{print $13}')
echo "ip_counter_from_snmp_OutNoRoutes{} $value"

value=$(echo $content | awk '{print $14}')
echo "ip_counter_from_snmp_ReasmTimeout{} $value"

value=$(echo $content | awk '{print $15}')
echo "ip_counter_from_snmp_ReasmReqds{} $value"

value=$(echo $content | awk '{print $16}')
echo "ip_counter_from_snmp_ReasmOKs{} $value"

value=$(echo $content | awk '{print $17}')
echo "ip_counter_from_snmp_ReasmFails{} $value"

value=$(echo $content | awk '{print $18}')
echo "ip_counter_from_snmp_FragOKs{} $value"

value=$(echo $content | awk '{print $19}')
echo "ip_counter_from_snmp_FragFails{} $value"

value=$(echo $content | awk '{print $20}')
echo "ip_counter_from_snmp_FragCreates{} $value"

2023-11-02T02:29:26.png

最后修改:2023 年 11 月 02 日
如果觉得我的文章对你有用,请随意赞赏