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>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/fm/fmd/common/fmd_protocol.c
          +++ new/usr/src/cmd/fm/fmd/common/fmd_protocol.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
       27 +/*
       28 + * Copyright 2018 Nexenta Systems, Inc.
       29 + */
       30 +
  27   31  #include <sys/fm/protocol.h>
       32 +
  28   33  #include <fm/fmd_msg.h>
  29      -#include <strings.h>
       34 +
  30   35  #include <alloca.h>
  31   36  #include <stdio.h>
       37 +#include <strings.h>
  32   38  
  33   39  #include <fmd_protocol.h>
  34   40  #include <fmd_module.h>
  35   41  #include <fmd_conf.h>
  36   42  #include <fmd_subr.h>
  37   43  #include <fmd_error.h>
  38   44  #include <fmd_time.h>
  39   45  #include <fmd.h>
  40   46  
  41   47  /*
↓ open down ↓ 99 lines elided ↑ open up ↑
 141  147  
 142  148  nvlist_t *
 143  149  fmd_protocol_list(const char *class, nvlist_t *de_fmri, const char *uuid,
 144  150      const char *code, uint_t argc, nvlist_t **argv, uint8_t *flagv, int domsg,
 145  151      struct timeval *tvp, int injected)
 146  152  {
 147  153          int64_t tod[2];
 148  154          nvlist_t *nvl;
 149  155          int err = 0;
 150  156          fmd_msg_hdl_t *msghdl;
 151      -        char *severity;
      157 +        char *item;
 152  158  
 153  159          tod[0] = tvp->tv_sec;
 154  160          tod[1] = tvp->tv_usec;
 155  161  
 156  162          if (nvlist_xalloc(&nvl, NV_UNIQUE_NAME, &fmd.d_nva) != 0)
 157  163                  fmd_panic("failed to xalloc suspect list nvlist");
 158  164  
 159  165          err |= nvlist_add_uint8(nvl, FM_VERSION, FM_SUSPECT_VERSION);
 160  166          err |= nvlist_add_string(nvl, FM_CLASS, class);
 161  167          err |= nvlist_add_string(nvl, FM_SUSPECT_UUID, uuid);
↓ open down ↓ 12 lines elided ↑ open up ↑
 174  180          }
 175  181  
 176  182          if (argc != 0) {
 177  183                  err |= nvlist_add_nvlist_array(nvl,
 178  184                      FM_SUSPECT_FAULT_LIST, argv, argc);
 179  185                  err |= nvlist_add_uint8_array(nvl,
 180  186                      FM_SUSPECT_FAULT_STATUS, flagv, argc);
 181  187          }
 182  188  
 183  189          /*
 184      -         * Attempt to lookup the severity associated with this diagnosis from
 185      -         * the portable object file using the diag code.  Failure to init
 186      -         * libfmd_msg or add to the nvlist will be treated as fatal.  However,
 187      -         * we won't treat a fmd_msg_getitem_id failure as fatal since during
 188      -         * development it's not uncommon to be working with po/dict files that
 189      -         * haven't yet been updated with newly added diagnoses.
      190 +         * Attempt to lookup the type, severity, and description associated with
      191 +         * this diagnosis from the portable object file using the diag code.
      192 +         * Failure to init libfmd_msg or add to the nvlist will be treated as
      193 +         * fatal.  However, we won't treat a fmd_msg_getitem_id failure as fatal
      194 +         * since during development it's not uncommon to be working with po/dict
      195 +         * files that haven't yet been updated with newly added diagnoses.
 190  196           */
 191  197          msghdl = fmd_msg_init(fmd.d_rootdir, FMD_MSG_VERSION);
 192  198          if (msghdl == NULL)
 193  199                  fmd_panic("failed to initialize libfmd_msg\n");
 194  200  
 195      -        if ((severity = fmd_msg_getitem_id(msghdl, NULL, code,
      201 +        if ((item = fmd_msg_getitem_id(msghdl, NULL, code,
      202 +            FMD_MSG_ITEM_TYPE)) != NULL) {
      203 +                err |= nvlist_add_string(nvl, FM_SUSPECT_TYPE, item);
      204 +                free(item);
      205 +        }
      206 +        if ((item = fmd_msg_getitem_id(msghdl, NULL, code,
 196  207              FMD_MSG_ITEM_SEVERITY)) != NULL) {
 197      -                err |= nvlist_add_string(nvl, FM_SUSPECT_SEVERITY, severity);
 198      -                free(severity);
      208 +                err |= nvlist_add_string(nvl, FM_SUSPECT_SEVERITY, item);
      209 +                free(item);
 199  210          }
      211 +        if ((item = fmd_msg_getitem_id(msghdl, NULL, code,
      212 +            FMD_MSG_ITEM_DESC)) != NULL) {
      213 +                err |= nvlist_add_string(nvl, FM_SUSPECT_DESC, item);
      214 +                free(item);
      215 +        }
 200  216          fmd_msg_fini(msghdl);
 201  217  
 202  218          if (err != 0)
 203  219                  fmd_panic("failed to populate nvlist: %s\n", fmd_strerror(err));
 204  220  
 205  221          return (nvl);
 206  222  }
 207  223  
 208  224  nvlist_t *
 209  225  fmd_protocol_rsrc_asru(const char *class,
↓ open down ↓ 195 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX