diff --git a/Changes b/Changes index c7b029f..b16e9bd 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ 3.N.N - NN.XXX-2013 ==================== +- Changed the source from where the memory usage is collected in the 'squid' + graph. Now the values shown are more real and accurate. - Fixed a bug that prevented seeing the Core temperatures in the 'lmsens' graph. (thanks to Bryan Guidroz, bryanguidroz AT hotmail.com for pointing this out) diff --git a/lib/squid.pm b/lib/squid.pm index 1a889fb..307acc0 100644 --- a/lib/squid.pm +++ b/lib/squid.pm @@ -303,13 +303,25 @@ sub squid_update { close(IN); $rrdata .= ":$rq_client_http_req:$rq_client_http_hit:$rq_server_http_req:$rq_server_ftp_req:$rq_server_other_req:$rq_aborted_req:$rq_swap_files_cleaned:$rq_unlink_requests:0"; - open(IN, "$squid->{cmd} mgr:mem |"); + open(IN, "$squid->{cmd} mgr:info |"); + my $memory_section = 0; while() { - if(/^Total /) { - (undef, undef, $m_alloc, undef, undef, undef, undef, $m_inuse) = split(' ', $_); - chomp($m_alloc); - chomp($m_inuse); - last; + if(/^Memory usage for squid via mallinfo/) { + $memory_section = 1; + next; + } + if($memory_section) { + if(/^\tTotal in use:\s+(\d+) KB/) { + $m_inuse = $1; + chomp($m_inuse); + next; + } + if(/^\tTotal size:\s+(\d+) KB/) { + $m_alloc = $1; + chomp($m_alloc); + $memory_section = 0; + last; + } } } close(IN);