@@ -28,13 +28,6 @@ package trc::proc {
2828 use List::Util qw( sum max min) ;
2929 use Data::Dumper;
3030
31- my $NETSPEED =
32- ` curl -s "http://fritz.box:49000/igd2upnp/control/WANCommonIFC1" -H "Content-Type: text/xml; charset="utf-8"" -H "SoapAction:urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1#GetCommonLinkProperties" -d '<?xml version="1.0" encoding="utf-8"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:GetCommonLinkProperties xmlns:u="urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" /></s:Body></s:Envelope>'` ;
33- my $NETSPEED_DOWN = $NETSPEED =~ / .*(NewLayer1DownstreamMaxBitRate)>([0-9]+)/ ;
34- $NETSPEED_DOWN = $2 / 8;
35- my $NETSPEED_UP = $NETSPEED =~ / .*(NewLayer1UpstreamMaxBitRate)>([0-9]+)/ ;
36- $NETSPEED_UP = $2 / 8;
37-
3831 use constant {
3932 PARTITIONS => ' /proc/partitions' ,
4033 MOUNTS => ' /proc/mounts' ,
@@ -164,7 +157,6 @@ package trc::proc {
164157
165158 sub getNetworkUsage {
166159 my $direction = shift ;
167- my $wan = &getWanInterface;
168160
169161 my %results ;
170162 my $rx_bytes = 0;
@@ -190,10 +182,6 @@ package trc::proc {
190182 my $diff_usage = 100 * $diff_rx / &getInterfaceSpeed($nic );
191183 $results {$nic .($direction eq ' rx_bytes' ? ' _rx' : ' _tx' )} = $diff_usage ;
192184
193- if ($nic eq $wan ) {
194- $diff_usage = 100 * $diff_rx / ($direction eq ' rx_bytes' ? $NETSPEED_DOWN : $NETSPEED_UP );
195- $results {($direction eq ' rx_bytes' ? ' wan_rx' : ' wan_tx' )} = $diff_usage ;
196- }
197185 }
198186 }
199187 closedir $dh ;
@@ -202,7 +190,7 @@ package trc::proc {
202190 }
203191
204192 sub getWanInterface {
205- open my $fh , ' /proc/net/route' ;
193+ open ( my $fh , ' < ' , ' /proc/net/route' ) ;
206194
207195 my $if = <$fh >;
208196 $if = <$fh >;
@@ -213,7 +201,7 @@ package trc::proc {
213201
214202 sub getInterfaceSpeed {
215203 my $if = shift ;
216- open (my $fh , " /sys/class/net/$if /speed" );
204+ open (my $fh , ' < ' , " /sys/class/net/$if /speed" );
217205 my $speed = <$fh >;
218206 $speed *= 1000000 / 8;
219207 return $speed ;
@@ -862,7 +850,7 @@ sub on_init {
862850 $disks = [ split ( / [[:punct:],[:space:]]/ , $disks ) ];
863851 XR-> {gauges_disks } = trc::proc::getDisks;
864852
865- my $nics = $s -> x_resource(' %.gauges.nics' ) // ' eth0_rx,eth0_tx,eth1_rx,eth1_tx,wan_tx,wan_rx ' ; # Can be a list,
853+ my $nics = $s -> x_resource(' %.gauges.nics' ) // ' eth0_rx,eth0_tx,eth1_rx,eth1_tx' ; # Can be a list,
866854 # e.g. 'a,b,c'
867855 # or 'a
868856 # b c'
0 commit comments