From: Olivier A. <oli...@co...> - 2011-06-14 12:12:55
|
hello someone in my compagnie need to get the volume of traffic on interfaces. As far as I know the only oid I have it the IfInOctets and IfOutOctets. That's good but reading a volume in octets is not really human readable. Some solution exist with devmon ? May I implement a need transform method like HUMAN for exemple to do this ? Following : sub octets_to_human 2 { 4 5 my $size = shift; 6 7 if ($size > 1099511627776) # TiB: 1024 GiB 8 { 9 return sprintf("%.2f TiB", $size / 1099511627776); 10 } 11 elsif ($size > 1073741824) # GiB: 1024 MiB 12 { 13 return sprintf("%.2f GiB", $size / 1073741824); 14 } 15 elsif ($size > 1048576) # MiB: 1024 KiB 16 { 17 return sprintf("%.2f MiB", $size / 1048576); 18 } 19 elsif ($size > 1024) # KiB: 1024 B 20 { 21 return sprintf("%.2f KiB", $size / 1024); 22 } 23 else # bytes 24 { 25 return sprintf("%.2f bytes", $size); 26 } 27 } what do you think ? oau |
From: Richard F. <gol...@gm...> - 2011-06-15 01:33:32
|
On Tue, Jun 14, 2011 at 04:52, Olivier AUDRY <oli...@co...> wrote: > sub octets_to_human > 2 { > 5 my $size = shift; > 7 if ($size > 1099511627776) # TiB: 1024 GiB > 8 { > 9 return sprintf("%.2f TiB", $size / 1099511627776); > 10 } > 11 elsif ($size > 1073741824) # GiB: 1024 MiB > 12 { > 13 return sprintf("%.2f GiB", $size / 1073741824); > 14 } [snip] There's a SPEED transform already implemented, with an automatic ending of "bps". If this ending and SI prefixes (instead of binary prefixes) are acceptable, all is well, no modifications required. If you want to remove this ending, you should be able to do it with a negative SUBSTR transform; I submitted http://sourceforge.net/tracker/?func=detail&aid=2963118&group_id=160720&atid=816979 but I'm not sure if it was accepted (due to lack of persuasive use case). A very low impact patch. If you insist on binary prefixes, duplicating the speeds array/trans_speed function in dm_tests.pm is fairly straightforward, but that's a much bigger patch. |
From: Olivier A. <oli...@co...> - 2011-06-15 11:44:47
|
hello > If you insist on binary prefixes, duplicating the speeds > array/trans_speed function in dm_tests.pm is fairly straightforward, > but that's a much bigger patch. it's exactly what I'm doing. But any chance to add this into the official devmon ? oau On Tue, Jun 14, 2011 at 06:33:05PM -0700, Richard Finegold wrote: > On Tue, Jun 14, 2011 at 04:52, Olivier AUDRY <oli...@co...> wrote: > > sub octets_to_human > > 2 { > > 5 my $size = shift; > > 7 if ($size > 1099511627776) # TiB: 1024 GiB > > 8 { > > 9 return sprintf("%.2f TiB", $size / 1099511627776); > > 10 } > > 11 elsif ($size > 1073741824) # GiB: 1024 MiB > > 12 { > > 13 return sprintf("%.2f GiB", $size / 1073741824); > > 14 } > [snip] > > There's a SPEED transform already implemented, with an automatic > ending of "bps". If this ending and SI prefixes (instead of binary > prefixes) are acceptable, all is well, no modifications required. > > If you want to remove this ending, you should be able to do it with a > negative SUBSTR transform; I submitted > http://sourceforge.net/tracker/?func=detail&aid=2963118&group_id=160720&atid=816979 > but I'm not sure if it was accepted (due to lack of persuasive use > case). A very low impact patch. > > If you insist on binary prefixes, duplicating the speeds > array/trans_speed function in dm_tests.pm is fairly straightforward, > but that's a much bigger patch. > > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically advanced content > authoring tool. Experience the power of Track Changes, Inline Image > Editing and ensure content is compliant with Accessibility Checking. > http://p.sf.net/sfu/ephox-dev2dev > _______________________________________________ > Devmon-support mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/devmon-support |
From: Olivier A. <oli...@co...> - 2011-06-16 12:02:23
|
hello here is my patch. What is the process to add them ? it's in production on one of my hobbit plateform. oau On Tue, Jun 14, 2011 at 06:33:05PM -0700, Richard Finegold wrote: > On Tue, Jun 14, 2011 at 04:52, Olivier AUDRY <oli...@co...> wrote: > > sub octets_to_human > > 2 { > > 5 my $size = shift; > > 7 if ($size > 1099511627776) # TiB: 1024 GiB > > 8 { > > 9 return sprintf("%.2f TiB", $size / 1099511627776); > > 10 } > > 11 elsif ($size > 1073741824) # GiB: 1024 MiB > > 12 { > > 13 return sprintf("%.2f GiB", $size / 1073741824); > > 14 } > [snip] > > There's a SPEED transform already implemented, with an automatic > ending of "bps". If this ending and SI prefixes (instead of binary > prefixes) are acceptable, all is well, no modifications required. > > If you want to remove this ending, you should be able to do it with a > negative SUBSTR transform; I submitted > http://sourceforge.net/tracker/?func=detail&aid=2963118&group_id=160720&atid=816979 > but I'm not sure if it was accepted (due to lack of persuasive use > case). A very low impact patch. > > If you insist on binary prefixes, duplicating the speeds > array/trans_speed function in dm_tests.pm is fairly straightforward, > but that's a much bigger patch. > > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically advanced content > authoring tool. Experience the power of Track Changes, Inline Image > Editing and ensure content is compliant with Accessibility Checking. > http://p.sf.net/sfu/ephox-dev2dev > _______________________________________________ > Devmon-support mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/devmon-support |
From: Buchan M. <bg...@st...> - 2011-06-20 12:35:35
|
On Thursday, 16 June 2011 14:01:57 Olivier AUDRY wrote: > hello > > here is my patch. No patch was attached to the mail. > What is the process to add them ? Submit a patch on the patches tracker (works best if you have an sf username, otherwise patches I don't want to accept or can't test sit with my feedback waiting for the original poster to respond). Links to everything you need are available here: http://sourceforge.net/projects/devmon/develop Regards, Buchan |
From: Buchan M. <bg...@st...> - 2011-06-20 12:24:57
|
On Tuesday, 14 June 2011 13:52:06 Olivier AUDRY wrote: > hello > > someone in my compagnie need to get the volume of traffic on interfaces. As > far as I know the only oid I have it the IfInOctets and IfOutOctets. > That's good but reading a volume in octets is not really human readable. > Some solution exist with devmon ? May I implement a need transform method > like HUMAN for exemple to do this ? Following : I don't know if the name of the transform is the best choice. I was also wondering if it would be better to have this transform take an argument, such as the precision. > > sub octets_to_human > 2 { > 4 > 5 my $size = shift; > 6 > 7 if ($size > 1099511627776) # TiB: 1024 GiB > 8 { > 9 return sprintf("%.2f TiB", $size / 1099511627776); > 10 } > 11 elsif ($size > 1073741824) # GiB: 1024 MiB > 12 { > 13 return sprintf("%.2f GiB", $size / 1073741824); > 14 } > 15 elsif ($size > 1048576) # MiB: 1024 KiB > 16 { > 17 return sprintf("%.2f MiB", $size / 1048576); > 18 } > 19 elsif ($size > 1024) # KiB: 1024 B > 20 { > 21 return sprintf("%.2f KiB", $size / 1024); > 22 } > 23 else # bytes > 24 { > 25 return sprintf("%.2f bytes", $size); > 26 } > 27 } > > what do you think ? How about: sub trans_best_binary_prefix { my $size = shift; my $precision = shift; my @units = qw/B KiB MiB GiB TiB/; my $i; for ( $i = 0; $i < @units -1; $i++) { last if (2**(10*($i+1)) > $size) } return sprintf("%.${precision}f ${units[$i]}",$size/(2**(10*$i)) ); } Regards, Buchan |