From nobody@FreeBSD.org  Mon Jun 18 14:40:03 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 54E881065670
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2012 14:40:03 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 39AAB8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2012 14:40:03 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q5IEe3QI080675
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 18 Jun 2012 14:40:03 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q5IEe2un080674;
	Mon, 18 Jun 2012 14:40:02 GMT
	(envelope-from nobody)
Message-Id: <201206181440.q5IEe2un080674@red.freebsd.org>
Date: Mon, 18 Jun 2012 14:40:02 GMT
From: Rafael Ganascim <rganascim@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: bsnmpd host-resources - return hrFSTypes on hrStorageType oid
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         169201
>Category:       bin
>Synopsis:       bsnmpd(8) host-resources - return hrFSTypes on hrStorageType oid
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ae
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 18 14:50:11 UTC 2012
>Closed-Date:    
>Last-Modified:  Thu Jul 26 14:20:08 UTC 2012
>Originator:     Rafael Ganascim
>Release:        9.0-STABLE
>Organization:
>Environment:
FreeBSD ldalatimez006.dedic-br.dedic.corp 9.0-STABLE FreeBSD 9.0-STABLE #0: Fri Jun  1 15:19:04 BRT 2012     root@ldalatimez006.dedic.corp:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
According to the host-resources MIB, the HOST-RESOURCES-MIB::hrStorageType need
to be set to hrStorageTypes values (like hrStorageFixedDisk,
hrStorageRemovableDisk, etc), but the bsnmpd is setting the hrFSTypes
in this field (hrFSBerkeleyFFS, hrFSFat, etc).

rafael@ldalatimez006:~$ snmpwalk -c public -v 2c fw01 .1.3.6.1.2.1.25.2.3.1 | grep '\.4 '
HOST-RESOURCES-MIB::hrStorageIndex.4 = INTEGER: 4
HOST-RESOURCES-MIB::hrStorageType.4 = OID: HOST-RESOURCES-TYPES::hrFSBerkeleyFFS
HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: /, type: ufs, dev: /dev/mfid0s1a

On the source code, I found where is set the fstype  (file hostres_storage_tbl.c line 495):
..
entry->type = fs_get_type(&fs_buf[i]); /*XXX - This is wrong*/
..
>How-To-Repeat:
rafael@ldalatimez006:~$ snmpwalk -c public -v 2c fw01 .1.3.6.1.2.1.25.2.3.1 | grep '\.4 '
HOST-RESOURCES-MIB::hrStorageIndex.4 = INTEGER: 4
HOST-RESOURCES-MIB::hrStorageType.4 = OID: HOST-RESOURCES-TYPES::hrFSBerkeleyFFS
HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: /, type: ufs, dev: /dev/mfid0s1a


>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->ae 
Responsible-Changed-By: ae 
Responsible-Changed-When: Tue Jun 19 03:49:19 UTC 2012 
Responsible-Changed-Why:  
I have a WIP related to hostres module, so i take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169201 

From: Rafael Ganascim <rganascim@gmail.com>
To: bug-followup@FreeBSD.org, rganascim@gmail.com
Cc:  
Subject: Re: bin/169201: bsnmpd(8) host-resources - return hrFSTypes on
 hrStorageType oid
Date: Thu, 26 Jul 2012 11:11:36 -0300

 To workaround this issue, and to put our network monitoring system
 back to work, I made the following patch.
 
 It's very questionable, for example, an FAT partition can be an
 removable usb stick. But for our servers being monitored it works
 fine.
 
 
 
 --- hostres_fs_tbl.c.old	2012-07-26 10:38:27.000000000 -0300
 +++ hostres_fs_tbl.c	2012-07-26 10:34:41.000000000 -0300
 @@ -125,23 +125,37 @@
  static const struct asn_oid OIDX_hrFSHPFS_c = OIDX_hrFSHPFS;
  static const struct asn_oid OIDX_hrFSUnknown_c = OIDX_hrFSUnknown;
 
 +/* constants from HOSTRESOURCES-TYPES hrStorageTypes */
 +static const struct asn_oid OIDX_hrStorageOther_c = OIDX_hrStorageOther;
 +static const struct asn_oid OIDX_hrStorageRam_c = OIDX_hrStorageRam;
 +static const struct asn_oid OIDX_hrStorageVirtualMemory_c =
 OIDX_hrStorageVirtualMemory;
 +static const struct asn_oid OIDX_hrStorageFixedDisk_c =
 OIDX_hrStorageFixedDisk;
 +static const struct asn_oid OIDX_hrStorageRemovableDisk_c =
 OIDX_hrStorageRemovableDisk;
 +static const struct asn_oid OIDX_hrStorageFloppyDisk_c =
 OIDX_hrStorageFloppyDisk;
 +static const struct asn_oid OIDX_hrStorageCompactDisc_c =
 OIDX_hrStorageCompactDisc;
 +static const struct asn_oid OIDX_hrStorageRamDisk_c = OIDX_hrStorageRamDisk;
 +static const struct asn_oid OIDX_hrStorageFlashMemory_c =
 OIDX_hrStorageFlashMemory;
 +static const struct asn_oid OIDX_hrStorageNetworkDisk_c =
 OIDX_hrStorageNetworkDisk;
 +
 +
  /* file system type map */
  static const struct {
  	const char		*str;	/* the type string */
  	const struct asn_oid	*oid;	/* the OID to return */
 +	const struct asn_oid	*oidst;	/* the OID of the StorageType to return */
  } fs_type_map[] = {
 -	{ "ufs",	&OIDX_hrFSBerkeleyFFS_c },
 -	{ "zfs",        &OIDX_hrFSOther_c },
 -	{ "cd9660",	&OIDX_hrFSiso9660_c },
 -	{ "nfs",	&OIDX_hrFSNFS_c },
 -	{ "ext2fs",	&OIDX_hrFSLinuxExt2_c },
 -	{ "procfs",	&OIDX_hrFSOther_c },
 -	{ "devfs",	&OIDX_hrFSOther_c },
 -	{ "msdosfs",	&OIDX_hrFSFAT32_c },
 -	{ "ntfs",	&OIDX_hrFSNTFS_c },
 -	{ "nwfs",	&OIDX_hrFSNetware_c },
 -	{ "hpfs",	&OIDX_hrFSHPFS_c },
 -	{ "smbfs",	&OIDX_hrFSOther_c },
 +	{ "ufs",	&OIDX_hrFSBerkeleyFFS_c , &OIDX_hrStorageFixedDisk_c},
 +	{ "zfs",        &OIDX_hrFSOther_c , &OIDX_hrStorageFixedDisk_c},
 +	{ "cd9660",	&OIDX_hrFSiso9660_c , &OIDX_hrStorageCompactDisc_c},
 +	{ "nfs",	&OIDX_hrFSNFS_c , &OIDX_hrStorageNetworkDisk_c },
 +	{ "ext2fs",	&OIDX_hrFSLinuxExt2_c , &OIDX_hrStorageFixedDisk_c},
 +	{ "procfs",	&OIDX_hrFSOther_c , &OIDX_hrStorageOther_c },
 +	{ "devfs",	&OIDX_hrFSOther_c , &OIDX_hrStorageOther_c },
 +	{ "msdosfs",	&OIDX_hrFSFAT32_c , &OIDX_hrStorageFixedDisk_c},
 +	{ "ntfs",	&OIDX_hrFSNTFS_c , &OIDX_hrStorageFixedDisk_c},
 +	{ "nwfs",	&OIDX_hrFSNetware_c , &OIDX_hrStorageNetworkDisk_c },
 +	{ "hpfs",	&OIDX_hrFSHPFS_c , &OIDX_hrStorageFixedDisk_c},
 +	{ "smbfs",	&OIDX_hrFSOther_c , &OIDX_hrStorageNetworkDisk_c},
  };
  #define	N_FS_TYPE_MAP	(sizeof(fs_type_map) / sizeof(fs_type_map[0]))
 
 @@ -329,9 +343,9 @@
 
  	for (t = 0; t < N_FS_TYPE_MAP; t++)
  		if (strcmp(fs_type_map[t].str, fs_p->f_fstypename) == 0)
 -			return (fs_type_map[t].oid);
 +			return (fs_type_map[t].oidst);
 
 -	return (&OIDX_hrFSUnknown_c);
 +	return (&OIDX_hrStorageOther_c);
  }
 
  /*
>Unformatted:
