Reply To: IMPOSSIBLE PROCESSOR LOAD 2503%

Home Page Forums Network Management Signal a BUG IMPOSSIBLE PROCESSOR LOAD 2503% Reply To: IMPOSSIBLE PROCESSOR LOAD 2503%

#54263

iulyb
Member

Hi,
Can you replace /scripts/bitrate script with

#!/usr/bin/perl
use warnings;
use Scalar::Util qw(looks_like_number);
sub bits2Xbits {
my $bits=shift;
if($bits > 1000000000) {
$bits = ( sprintf( "%0.2f", $bits/1000000000 )). " Gbit";
} elsif ($bits > 1000000) {
$bits = ( sprintf( "%0.2f", $bits/1000000 )). " Mbit";
} elsif ($bits > 1000) {
$bits = ( sprintf( "%0.2f", $bits/1000 )). " Kbit";
} else {
$bits = sprintf( "%0.2f", $bits ). " bit";
}
return $bits;
}
sub bytes2Xbytes {
my $bytes=shift;
if($bytes > 1000000000) {
$bytes = ( sprintf( "%0.2f", $bytes/1000000000 )). " GB";
} elsif ($bytes > 1000000) {
$bytes = ( sprintf( "%0.2f", $bytes/1000000 )). " MB";
} elsif ($bytes > 1000) {
$bytes = ( sprintf( "%0.2f", $bytes/1000 )). " KB";
} else {
$bytes = sprintf( "%0.2f", $bytes ). " B";
}
return $bytes;
}



open PREV,"/tmp/bitrate-prev";
while ($entry=) {
($Proto,$sIP,$dIP,$sPort,$dPort,$RX,$TX) = split(':',$entry);
$PTraffic{"$Proto:$sIP:$dIP:$sPort:$dPort"}=$RX+$TX;
}
close PREV;
open PREV,">","/tmp/bitrate-prev";


open CONNTRACK,"conntrack -L 2>/dev/null|awk -F= ' /^(udp|tcp)/ {printf "%s:%s:%s:%s:%s:%s:%s\n",substr($1,0,index($1," ")-1),substr($2,0,index($2," ")-1),substr($3,0,index($3," ")-1),substr($4,0,index($4," ")-1),substr($5,0,index($5," ")-1),substr($7,0,index($7," ")-1),substr($13,0,index($13," ")-1)} /^icmp/ {printf "%s:%s:%s:type=%s:code=%s:%s:%s\n",substr($1,0,index($1," ")-1),substr($2,0,index($2," ")-1),substr($3,0,index($3," ")-1),substr($4,0,index($4," ")-1),substr($5,0,index($5," ")-1),substr($8,0,index($8," ")-1),substr($15,0,index($15," ")-1)} /^unknown/ {printf "%s:%s:%s:::%s:%s\n",substr($1,0,index($1," ")-1),substr($2,0,index($2," ")-1),substr($3,0,index($3," ")-1),substr($5,0,index($5," ")-1),substr($9,0,index($9," ")-1)}'|";



$Throughput=0;
while ($entry=) {
($Proto,$sIP,$dIP,$sPort,$dPort,$RX,$TX) = split(':',$entry);
if ($dIP ne "127.0.0.1") {
chomp($TX);
if (looks_like_number($TX) && looks_like_number($RX)) {
print PREV "$Proto:$sIP:$dIP:$sPort:$dPort:$RX:$TXn";
if (defined ($PBytes=$PTraffic{"$Proto:$sIP:$dIP:$sPort:$dPort"})) {
if ($RX+$TX-$PBytes > 0) {
$Throughput+=$RX+$TX-$PBytes;
}
} else {
$Throughput+=$RX+$TX;
}
}
}
}
close PREV;
close CONNTRACK;

open TS,"<","/tmp/bitrate-ts";
$PTS=;
close TS;
if (!looks_like_number($PTS)) {
$PTS=0;
}
$NOW=time();

$DELTA=$NOW-$PTS;
open TS,">","/tmp/bitrate-ts";
print TS "$NOW";
close TS;

my $CONN = `cat /proc/sys/net/netfilter/nf_conntrack_count`;
chop($CONN);

my @Load=split / /, `cat /proc/loadavg`;
my $CPUs=`/root/kerbynet.cgi/scripts/cpus`;
$CPUs=1 unless $CPUs;
my $Bitrate=$Throughput*8/$DELTA;
my $LOAD=int(100*$Load[1]/$CPUs);
printf "%s/s (Connections: %s Load: %s%%)n",bits2Xbits($Bitrate),$CONN,$LOAD;

I rewrote it from line 78, Let me know if it works for you. If copy paste doesn’t work then I can put it somewhere.

About your question .. well you can compare everything with anything as long as you have a common base. Now against cisco, they sell a product that has hardware + software. If we throw in some decent HW that have lunx drivers then ZS can compete especially on the small biz side. However some stuff is more easy on Cisco, but you pay for that.
On hi end Cisco is a different beast, mainly on th HW optimization side like drivers and so. Now keep in mind that underlying OS is a linux flavour but most of stuff is build tested and optimized in house so is hard to compete on this scale. Note, as a full disclosure I still work for one of Cisco’s former competitors.