Print this page
NEX-17772 libfmd_snmp should learn about new FmProblem fields
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
        
*** 22,36 ****
  /*
   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
   * Use is subject to license terms.
   */
  
  #include <sys/fm/protocol.h>
  #include <fm/fmd_msg.h>
! #include <strings.h>
  #include <alloca.h>
  #include <stdio.h>
  
  #include <fmd_protocol.h>
  #include <fmd_module.h>
  #include <fmd_conf.h>
  #include <fmd_subr.h>
--- 22,42 ----
  /*
   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
   * Use is subject to license terms.
   */
  
+ /*
+  * Copyright 2018 Nexenta Systems, Inc.
+  */
+ 
  #include <sys/fm/protocol.h>
+ 
  #include <fm/fmd_msg.h>
! 
  #include <alloca.h>
  #include <stdio.h>
+ #include <strings.h>
  
  #include <fmd_protocol.h>
  #include <fmd_module.h>
  #include <fmd_conf.h>
  #include <fmd_subr.h>
*** 146,156 ****
  {
          int64_t tod[2];
          nvlist_t *nvl;
          int err = 0;
          fmd_msg_hdl_t *msghdl;
!         char *severity;
  
          tod[0] = tvp->tv_sec;
          tod[1] = tvp->tv_usec;
  
          if (nvlist_xalloc(&nvl, NV_UNIQUE_NAME, &fmd.d_nva) != 0)
--- 152,162 ----
  {
          int64_t tod[2];
          nvlist_t *nvl;
          int err = 0;
          fmd_msg_hdl_t *msghdl;
!         char *item;
  
          tod[0] = tvp->tv_sec;
          tod[1] = tvp->tv_usec;
  
          if (nvlist_xalloc(&nvl, NV_UNIQUE_NAME, &fmd.d_nva) != 0)
*** 179,204 ****
                  err |= nvlist_add_uint8_array(nvl,
                      FM_SUSPECT_FAULT_STATUS, flagv, argc);
          }
  
          /*
!          * Attempt to lookup the severity associated with this diagnosis from
!          * the portable object file using the diag code.  Failure to init
!          * libfmd_msg or add to the nvlist will be treated as fatal.  However,
!          * we won't treat a fmd_msg_getitem_id failure as fatal since during
!          * development it's not uncommon to be working with po/dict files that
!          * haven't yet been updated with newly added diagnoses.
           */
          msghdl = fmd_msg_init(fmd.d_rootdir, FMD_MSG_VERSION);
          if (msghdl == NULL)
                  fmd_panic("failed to initialize libfmd_msg\n");
  
!         if ((severity = fmd_msg_getitem_id(msghdl, NULL, code,
              FMD_MSG_ITEM_SEVERITY)) != NULL) {
!                 err |= nvlist_add_string(nvl, FM_SUSPECT_SEVERITY, severity);
!                 free(severity);
          }
          fmd_msg_fini(msghdl);
  
          if (err != 0)
                  fmd_panic("failed to populate nvlist: %s\n", fmd_strerror(err));
  
--- 185,220 ----
                  err |= nvlist_add_uint8_array(nvl,
                      FM_SUSPECT_FAULT_STATUS, flagv, argc);
          }
  
          /*
!          * Attempt to lookup the type, severity, and description associated with
!          * this diagnosis from the portable object file using the diag code.
!          * Failure to init libfmd_msg or add to the nvlist will be treated as
!          * fatal.  However, we won't treat a fmd_msg_getitem_id failure as fatal
!          * since during development it's not uncommon to be working with po/dict
!          * files that haven't yet been updated with newly added diagnoses.
           */
          msghdl = fmd_msg_init(fmd.d_rootdir, FMD_MSG_VERSION);
          if (msghdl == NULL)
                  fmd_panic("failed to initialize libfmd_msg\n");
  
!         if ((item = fmd_msg_getitem_id(msghdl, NULL, code,
!             FMD_MSG_ITEM_TYPE)) != NULL) {
!                 err |= nvlist_add_string(nvl, FM_SUSPECT_TYPE, item);
!                 free(item);
!         }
!         if ((item = fmd_msg_getitem_id(msghdl, NULL, code,
              FMD_MSG_ITEM_SEVERITY)) != NULL) {
!                 err |= nvlist_add_string(nvl, FM_SUSPECT_SEVERITY, item);
!                 free(item);
          }
+         if ((item = fmd_msg_getitem_id(msghdl, NULL, code,
+             FMD_MSG_ITEM_DESC)) != NULL) {
+                 err |= nvlist_add_string(nvl, FM_SUSPECT_DESC, item);
+                 free(item);
+         }
          fmd_msg_fini(msghdl);
  
          if (err != 0)
                  fmd_panic("failed to populate nvlist: %s\n", fmd_strerror(err));