***SPAM(-2.9)*** Disk space being incorrectly reported.
David <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
Sorry think that should have looked more like this.
--- agent/mibgroup/ucd-snmp/disk_hw.c.orig 2011-08-31
11:22:10.000000000 +0
+++ agent/mibgroup/ucd-snmp/disk_hw.c 2011-08-31 11:28:27.000000000 +0100
@@ -245,7 +245,7 @@
static int _percent( int value, int total ) {
- return (int)( value * 100 ) / total;
+ return (int)( value / (total / 100));
}
static netsnmp_fsys_info **
David
On 31/08/2011 09:16, Dave Shield wrote:
> On 30 August 2011 14:20, David<[email protected]> wrote:
>> As of net-snmp 5.7 disk space is incorrectly reported.
> Actually, I think the disk space values are correct.
> It's the calculation of percentage used that's failing
>
>
>> UCD-SNMP-MIB::dskTotal.4 = INTEGER: 219227030
>> UCD-SNMP-MIB::dskAvail.4 = INTEGER: 153871682
>> UCD-SNMP-MIB::dskUsed.4 = INTEGER: 47817186
> 219227030 / (1024*1024) = 209.07
> 153871682 / (1024*1024) = 146.74
> 47817186 / (1024*1024) = 45.60
>
> which match the results from df
>
>> Filesystem Size Used Avail Capacity Mounted on
>> /dev/mfid0s1f 209G 46G 147G 24% /usr
>
>> Any ideas what is going wrong here.
> The calculation of the percentage usage is as follows:
>
> static int _percent( value, total ) {
> return (int) (value * 100 / total );
> }
>
> (ucd-snmp/disk_hw.c:250-ish)
>
> Your problem is almost certainly an arithmetic
> overflow when multiplying the main value by 100.
> What happens if you tweak this line to read
>
> return (int) ( value / (total / 100));
>
> ?
> The result should be the same, but without the
> possibility of overflow.
>
> Dave
>
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users