I'm trying to do some kind of network monitoring on embedded Linux.
Embedded Linux, likely with busybox.
Several hardware targets : so the aim is to get a solution as portable as possible (may be an illusion
) : the only common base may be the linux kernel itself.
The devices will have Ethernet and ppp/GPRS interfaces, at least.
Get stats about network interfaces, especially RX/TX bytes: so I planned to use ipconfig or /proc/net/dev to get those.
I use pppd to mount a GPRS connection through serial port.
(example of use: pppd /dev/ttyS0 115200 modem debug novj usepeerdns lock refuse-chap updetach connect chat'chat options ...' )
I need to get RX/TX stats for this connection.
In my case, when ppp link goes down, the interface totally disappears from "interface tools" like ifconfig -a, /proc/net/dev
However, I need to have RX/TX values for ppp link when interface goes down.
Second need (optional):
I would be happy to have events on network interface status (IP and/or link status)
Ex: knowing that the Ethernet cable is disconnected might be nice for me.
What I have already tried / look for:
- ip-down script for ppp: when the script is called, the interface is already down, RX/TX stats are not accessible from ifconfig or /proc/net/dev
Is there this kind of script registration for interface events other than ppp ?
- netlink socket, using RTMGRP_IPV4_IFADDR | RTMGRP_LINK messages.
For now, I don't see bearers stats (RX/TX) in RTMGRP_IPV4_IFADDR msgs (it makes sense for me), and when ppp interface goes down I've got some confusing msg sequence : NEWADDR ->DELADDR->NEWADDR
I get bearers stats (RX/TX) in some RTMGRP_LINK msgs, but it seems that RTMGRP_LINK messages are really dependant on interface driver.
In deed, ppp interface seems to behave strangely about information given in netlink msg: IFLA_OPERSTATE for instance don't follow http://www.mjmwired.net/kernel/Docum...operstates.txt
description, whereas msg related to eth on several devices are way more intelligible.
So, for know, I don't feel confident about my use of netlink sockets.
I hope all of this makes sense.
Thank you by advance for reading this