From: minima Date: Sun, 29 Sep 2002 22:46:00 +0000 (+0000) Subject: add in and out stats for data into the cluster X-Git-Tag: PRE-1-52~174 X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=e8fe72d833414c4bb7f017ed0b62167aa5ac593d;p=spider.git add in and out stats for data into the cluster --- diff --git a/cmd/mrtg.pl b/cmd/mrtg.pl index 05d426e2..dfc0fcb5 100644 --- a/cmd/mrtg.pl +++ b/cmd/mrtg.pl @@ -36,6 +36,20 @@ $want{nomrtg} = 1 if $want{cfgonly} || $want{test}; return (1, "MRTG not installed") unless $want{nomrtg} || -e '/usr/bin/mrtg' || -e '/usr/local/bin/mrtg'; my $mc = new Mrtg or return (1, "cannot initialise Mrtg $!"); + +# do Msg totals +$mc->cfgprint('msg', [], 64000, + "Data in and out of $main::mycall", + 'Bits / Sec', 'Bytes In', 'Bytes Out') unless $want{dataonly}; +$mc->data('msg', $Msg::total_in, $Msg::total_out, "Data in and out of $main::mycall") unless $want{cfgonly}; + +# do AGW stats if they apply +if ($want{agw}) { + $mc->cfgprint('agw', [], 64000, + "AGW Data in and out of $main::mycall", + 'Bits / Sec', 'Bytes In', 'Bytes Out') unless $want{dataonly}; + $mc->data('agw', $AGWMsg::total_in, $AGWMsg::total_out, "AGW Data in and out of $main::mycall") unless $want{cfgonly}; +} # do the users and nodes my $users = DXChannel::get_all_users(); diff --git a/perl/AGWMsg.pm b/perl/AGWMsg.pm index 693f3108..d6828812 100644 --- a/perl/AGWMsg.pm +++ b/perl/AGWMsg.pm @@ -30,7 +30,7 @@ use AGWConnect; use DXDebug; use vars qw(@ISA $sock @outqueue $send_offset $inmsg $rproc $noports $lastytime - $lasthtime $ypolltime $hpolltime %circuit); + $lasthtime $ypolltime $hpolltime %circuit $total_in $total_out); @ISA = qw(Msg ExtMsg); $sock = undef; @@ -43,6 +43,7 @@ $lastytime = $lasthtime = time; $ypolltime = 10 unless defined $ypolltime; $hpolltime = 300 unless defined $hpolltime; %circuit = (); +$total_in = $total_out = 0; use vars qw($VERSION $BRANCH); $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); @@ -171,6 +172,7 @@ sub _send if (isdbg('raw')) { dbgdump('raw', "AGW send $bytes_written: ", $msg); } + $total_out += $bytes_written; $offset += $bytes_written; $bytes_to_write -= $bytes_written; } @@ -196,6 +198,7 @@ sub _rcv { # Complement to _send $bytes_read = sysread ($sock, $msg, 1024, 0); if (defined ($bytes_read)) { if ($bytes_read > 0) { + $total_in += $bytes_read; $inmsg .= $msg; if (isdbg('raw')) { dbgdump('raw', "AGW read $bytes_read: ", $msg); diff --git a/perl/Msg.pm b/perl/Msg.pm index 45c0ab7c..c3637fb0 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -23,7 +23,7 @@ use IO::Socket; use DXDebug; use Timer; -use vars qw(%rd_callbacks %wt_callbacks %er_callbacks $rd_handles $wt_handles $er_handles $now %conns $noconns $blocking_supported $cnum); +use vars qw(%rd_callbacks %wt_callbacks %er_callbacks $rd_handles $wt_handles $er_handles $now %conns $noconns $blocking_supported $cnum $total_in $total_out); %rd_callbacks = (); %wt_callbacks = (); @@ -31,6 +31,7 @@ use vars qw(%rd_callbacks %wt_callbacks %er_callbacks $rd_handles $wt_handles $e $rd_handles = IO::Select->new(); $wt_handles = IO::Select->new(); $er_handles = IO::Select->new(); +$total_in = $total_out = 0; $now = time; @@ -378,6 +379,7 @@ sub _send { my $call = $conn->{call} || 'none'; dbgdump('raw', "$call send $bytes_written: ", $msg); } + $total_out += $bytes_written; $offset += $bytes_written; $bytes_to_write -= $bytes_written; } @@ -503,6 +505,7 @@ sub _rcv { # Complement to _send $bytes_read = sysread ($sock, $msg, 1024, 0); if (defined ($bytes_read)) { if ($bytes_read > 0) { + $total_in += $bytes_read; if (isdbg('raw')) { my $call = $conn->{call} || 'none'; dbgdump('raw', "$call read $bytes_read: ", $msg);