我正在尝试全天候监控流。
为此,我监视我的树莓的网络速度。
网络速度(KB):
(old="$(</sys/class/net/eth0/statistics/rx_bytes)"; while $(sleep 1); do now=$(</sys/class/net/eth0/statistics/rx_bytes); echo $((($now-$old)/1024)); old=$now; done)
输出单位为Kbit/s:
216
384
288
360
336
360
电报代码:
TELEGRAM=$(curl -s -X POST 'https://api.telegram.org/<BOT ID>:<API KEY>/sendMessage?chat_id=<ID>&text="Stream has problems"')
为此,我需要一个whiledo循环和if条件。
编辑////
$(old="$(</sys/class/net/eth0/statistics/rx_bytes)"; while $(sleep 1); do now=$(</sys/class/net/eth0/statistics/rx_bytes); if (( (now-old)/1024 < 1000 )); then $TELEGRAM ; fi echo $((($now-$old)/1024)); old=$now; done)