I have a situation where I need to write an application to monitor that a 3g router is up and running, as sometimes the 3g connection isn't stable. I have to ensure the bandwidth usage doesn't go over the limit.

I am not sure what is the best way to monitor the 3g connection status with the minimum usage of the bandwidth of the 3g connection. Any good suggestion?

有帮助吗?

解决方案

If ping is not blocked, you can simply do ping -c 10 8.8.8.8 | grep -oE "[0-9]* received" | sed "s/ received//g". If the connection is up, you should get nonzero (>7 for any reasonably good connection) value.

其他提示

Any reasonable quality router should have an SNMP service which can be polled to check the status of each interface, and the amount of traffic over each interface.

If your router has this, it's pretty trivial to write what you need in a variety of scripting languages. I've used the Perl Net::SNMP library for this sort of stuff in the past.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top