Bug 150723

Summary: bsnmpd(1): add knowledge of "ada" disks (ATA via SCSI CAM)
Product: Base System Reporter: Jeremy Chadwick <freebsd>
Component: binAssignee: Andrey V. Elsukov <ae>
Status: Closed FIXED    
Severity: Affects Only Me CC: eugen, harti
Priority: Normal    
Version: 8.1-STABLE   
Hardware: Any   
OS: Any   

Description Jeremy Chadwick 2010-09-19 16:20:00 UTC
	bsnmpd(1) does not properly handle disks attached to the ada(4)
	subsystem.  The daemon outputs the following syslog errors when
	starting:

snmpd[2964]: disk_OS_get_disks: device 'ada3' not in device list
snmpd[2964]: disk_OS_get_disks: device 'ada2' not in device list
snmpd[2964]: disk_OS_get_disks: device 'ada1' not in device list
snmpd[2964]: disk_OS_get_disks: device 'ada0' not in device list

	This is for a system with the following in sysctl kern.disks:

kern.disks: ada3 ada2 ada1 ada0

	These disks are:

ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
ada0: <WDC WD3000HLFS-01G6U0 04.04V01> ATA-8 SATA 2.x device
ada0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada0: Command Queueing enabled
ada0: 286168MB (586072368 512 byte sectors: 16H 63S/T 16383C)
ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
ada1: <WDC WD1001FALS-00U9B0 05.00K05> ATA-8 SATA 2.x device
ada1: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada1: Command Queueing enabled
ada1: 953869MB (1953525168 512 byte sectors: 16H 63S/T 16383C)
ada2 at ahcich2 bus 0 scbus2 target 0 lun 0
ada2: <WDC WD1001FALS-00U9B0 05.00K05> ATA-8 SATA 2.x device
ada2: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada2: Command Queueing enabled
ada2: 953869MB (1953525168 512 byte sectors: 16H 63S/T 16383C)
ada3 at ahcich3 bus 0 scbus3 target 0 lun 0
ada3: <WDC WD1001FALS-00U9B0 05.00K05> ATA-8 SATA 2.x device
ada3: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada3: Command Queueing enabled
ada3: 953869MB (1953525168 512 byte sectors: 16H 63S/T 16383C)

	Walking the appropriate OID branches is interesting:

	- hrDeviceType is correct
	- hrDeviceDescr doesn't show the hard disk model/firmware version
	- hrDeviceStatus is incorrect
	- hrDiskStorageMedia is incorrect
	- hrDiskStorageCapacity is correct
	- (Unrelated) hrDiskStorageRemoveble appears to have a typo in its
	  MIB name (should be hrDiskStorageRemovable -- "a", not "e"!)

hrDeviceTable =
HOST-RESOURCES-MIB::hrDeviceIndex.158 = INTEGER: 158
HOST-RESOURCES-MIB::hrDeviceIndex.159 = INTEGER: 159
HOST-RESOURCES-MIB::hrDeviceIndex.160 = INTEGER: 160
HOST-RESOURCES-MIB::hrDeviceIndex.161 = INTEGER: 161
HOST-RESOURCES-MIB::hrDeviceType.158 = OID: HOST-RESOURCES-TYPES::hrDeviceDiskStorage
HOST-RESOURCES-MIB::hrDeviceType.159 = OID: HOST-RESOURCES-TYPES::hrDeviceDiskStorage
HOST-RESOURCES-MIB::hrDeviceType.160 = OID: HOST-RESOURCES-TYPES::hrDeviceDiskStorage
HOST-RESOURCES-MIB::hrDeviceType.161 = OID: HOST-RESOURCES-TYPES::hrDeviceDiskStorage
HOST-RESOURCES-MIB::hrDeviceDescr.158 = STRING: ada3:
HOST-RESOURCES-MIB::hrDeviceDescr.159 = STRING: ada2:
HOST-RESOURCES-MIB::hrDeviceDescr.160 = STRING: ada1:
HOST-RESOURCES-MIB::hrDeviceDescr.161 = STRING: ada0:
HOST-RESOURCES-MIB::hrDeviceID.158 = OID: SNMPv2-SMI::zeroDotZero
HOST-RESOURCES-MIB::hrDeviceID.159 = OID: SNMPv2-SMI::zeroDotZero
HOST-RESOURCES-MIB::hrDeviceID.160 = OID: SNMPv2-SMI::zeroDotZero
HOST-RESOURCES-MIB::hrDeviceID.161 = OID: SNMPv2-SMI::zeroDotZero
HOST-RESOURCES-MIB::hrDeviceStatus.158 = INTEGER: unknown(1)
HOST-RESOURCES-MIB::hrDeviceStatus.159 = INTEGER: unknown(1)
HOST-RESOURCES-MIB::hrDeviceStatus.160 = INTEGER: unknown(1)
HOST-RESOURCES-MIB::hrDeviceStatus.161 = INTEGER: unknown(1)
HOST-RESOURCES-MIB::hrDeviceErrors.158 = Counter32: 0
HOST-RESOURCES-MIB::hrDeviceErrors.159 = Counter32: 0
HOST-RESOURCES-MIB::hrDeviceErrors.160 = Counter32: 0
HOST-RESOURCES-MIB::hrDeviceErrors.161 = Counter32: 0

hrDiskStorageTable =
HOST-RESOURCES-MIB::hrDiskStorageAccess.158 = INTEGER: readWrite(1)
HOST-RESOURCES-MIB::hrDiskStorageAccess.159 = INTEGER: readWrite(1)
HOST-RESOURCES-MIB::hrDiskStorageAccess.160 = INTEGER: readWrite(1)
HOST-RESOURCES-MIB::hrDiskStorageAccess.161 = INTEGER: readWrite(1)
HOST-RESOURCES-MIB::hrDiskStorageMedia.158 = INTEGER: unknown(2)
HOST-RESOURCES-MIB::hrDiskStorageMedia.159 = INTEGER: unknown(2)
HOST-RESOURCES-MIB::hrDiskStorageMedia.160 = INTEGER: unknown(2)
HOST-RESOURCES-MIB::hrDiskStorageMedia.161 = INTEGER: unknown(2)
HOST-RESOURCES-MIB::hrDiskStorageRemoveble.158 = INTEGER: false(2)
HOST-RESOURCES-MIB::hrDiskStorageRemoveble.159 = INTEGER: false(2)
HOST-RESOURCES-MIB::hrDiskStorageRemoveble.160 = INTEGER: false(2)
HOST-RESOURCES-MIB::hrDiskStorageRemoveble.161 = INTEGER: false(2)
HOST-RESOURCES-MIB::hrDiskStorageCapacity.158 = INTEGER: 976762584 KBytes
HOST-RESOURCES-MIB::hrDiskStorageCapacity.159 = INTEGER: 976762584 KBytes
HOST-RESOURCES-MIB::hrDiskStorageCapacity.160 = INTEGER: 976762584 KBytes
HOST-RESOURCES-MIB::hrDiskStorageCapacity.161 = INTEGER: 293036184 KBytes

Fix: 

Things I've tried:

	- Modifying modules/snmp_hostres/hostres_diskstorage_tbl.c, around
	  line 476, to include a strncmp() for "ada".  This does improve
	  things slightly, but not enough to get disk_OS_get_disks() to
	  stop complaining
	- Modifying modules/snmp_hostres/hostres_diskstorage_tbl.c, around
	  line 260, adding "ada" to the lookup[] structure.  This may have
	  had an effect, but again, not enough to get disk_OS_get_disks()
	  to stop complaining

	I'm marking this as high priority because lots of server admins
	at this point are using ada(4) instead of ad(4).

	I can provide patches for the hrDiskStorageRemoveble typo if need
	be, but the other stuff will need some who's a bit more familiar
	with the device_find_by_name() framework and why it's returning
	NULL for ada(4) devices.
How-To-Repeat: 	Run bsnmpd on a machine with ada(4) disks.
Comment 1 Shteryana Shopova freebsd_committer freebsd_triage 2010-09-22 12:38:30 UTC
Responsible Changed
From-To: freebsd-bugs->syrinx

Take over.
Comment 2 Andrey V. Elsukov freebsd_committer freebsd_triage 2011-10-26 07:46:57 UTC
Responsible Changed
From-To: syrinx->ae

Since there was no activity for a year, i'll take it.
Comment 3 Eugene Grosbein freebsd_committer freebsd_triage 2017-06-11 13:59:13 UTC
Fixed long time ago.