Index: includes/polling/functions.inc.php
===================================================================
--- includes/polling/functions.inc.php	(revision 9542)
+++ includes/polling/functions.inc.php	(working copy)
@@ -25,15 +25,38 @@
     # BB +1.1V IOH     | 1.089      | Volts      | ok    | na        | 1.027     | 1.054     | 1.146     | 1.177     | na
     list($desc,$current,$unit,$state,$low_nonrecoverable,$limit_low,$limit_low_warn,$limit_high_warn,$limit_high,$high_nonrecoverable) = explode('|',$row);
 
-    if (trim($current) != "na" && trim($state) != "nr" && $config['ipmi_unit'][trim($unit)])
+    if (trim($current) != "na" && trim($state) != "nr")
     {
-      $limits = array('limit_high'      => trim($limit_high),
-                      'limit_low'       => trim($limit_low),
-                      'limit_high_warn' => trim($limit_high_warn),
-                      'limit_low_warn'  => trim($limit_low_warn));
-      discover_sensor($config['ipmi_unit'][trim($unit)], $device, '', $index, $source, trim($desc), 1, trim($current), $limits, $source);
 
-      $ipmi_sensors[$config['ipmi_unit'][trim($unit)]][$source][$index] = array('description' => $desc, 'current' => $current, 'index' => $index, 'unit' => $unit);
+      if ($config['ipmi_unit'][trim($unit)])
+      {
+        $limits = array('limit_high'      => trim($limit_high),
+                        'limit_low'       => trim($limit_low),
+                        'limit_high_warn' => trim($limit_high_warn),
+                        'limit_low_warn'  => trim($limit_low_warn));
+        discover_sensor($config['ipmi_unit'][trim($unit)], $device, '', $index, $source, trim($desc), 1, trim($current), $limits, $source);
+
+        $ipmi_sensors[$config['ipmi_unit'][trim($unit)]][$source][$index] = array('description' => $desc, 'current' => $current, 'index' => $index, 'unit' => $unit);
+      } elseif (trim($unit) === 'discrete') {
+        $options = null;
+        // Initialize as number
+        $state_sanitized = hexdec(trim($state)) + 0;
+
+        // This is a bit hackish...
+        if (strtolower(substr($desc, 0, 7)) === 'chassis' || strtolower(substr($desc, 0, 9)) === 'intrusion')
+        {
+          $options = array('entPhysicalClass' => 'chassis');
+          $state_sanitized = ($state_sanitized === 0x0000) ? 1 : 0;
+        } elseif (strtolower(substr($desc, 0, 2)) === 'ps') {
+          $options = array('entPhysicalClass' => 'powersupply');
+          $state_sanitized = in_array($state_sanitized, [0x0100, 0x01ff]) ? 1 : 0;
+        }
+
+        if ($options) {
+          discover_status($device, '', $index, 'unix-agent-state', trim($desc), $state_sanitized, $options, $source);
+          $ipmi_sensors['state']['unix-agent-state'][$index] = array('description' => trim($desc), 'current' => $state_sanitized, 'index' => $index);
+        }
+      }
     }
   }
 
