Net::Int::Stats - Reports specific ifconfig values for a network interface
use Net::Int::Stats; my $get = Net::Int::Stats->new(); # get a value for a specific interface my $int = 'eth0'; my $stat = 'rx_packets'; my $packets = $get->value($int, $stat); # get a list of all interfaces my @interface_list = $get->interfaces();
This module provides a list of all interfaces and various statistics generated from the ifconfig command for specific interfaces. RX values consist of packets, errors, dropped, overruns, frame, and bytes. TX values consist of packets, errors, dropped, overruns, carrier, and bytes. In addition IPv4 address, collisions, and txqueuelen are reported. Values are in the format of type:n - ex 'packets:123456'. The interfaces() method returns a space delimited list of all interfaces. Ex: lo eth0 eth1.
Use this method to get specific values which requires two arguments: value(). Ex: $packets = $get->value($int, 'rx_packets');
The first argument is the interface and the second is the type value to extract.
RX values - rx_packets, rx_errors, rx_dropped, rx_overruns, rx_frame, rx_bytes
TX values - tx_packets, tx_errors, tx_dropped, tx_overruns, tx_carrier, tx_bytes
Miscellaneous values - collisions, txqueuelen, inet_addr
Use this method to get a list of all interfaces: interfaces(). Ex: @interface_list = $get->interfaces();
This module is platform dependent. It uses the linux version of /sbin/ifconfig. Other platforms such as the windows equivalent of ipconfig, mac osx, and other versions of unix are not supported. This is due to the fact that each platform generates and displays different information in different formats of ifconfig results. The linux version is used over the other platforms because of the amount of data the default command outputs.
linux command /sbin/ifconfig
ifconfig output contains more information than the values that are extracted in this module. More values and/or support for other operating systems can be added if there are any requests to do so.
Bruce Burch <bcb12001@yahoo.com>
Copyright (C) 2009 by Bruce Burch
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Net::Int::Stats, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Int::Stats
CPAN shell
perl -MCPAN -e shell install Net::Int::Stats
For more information on module installation, please visit the detailed CPAN module installation guide.