6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 #include <sys/fm/protocol.h>
  27 #include <sys/strlog.h>
  28 #include <sys/log.h>
  29 #include <libscf.h>
  30 
  31 #include <fm/fmd_api.h>
  32 #include <fm/fmd_msg.h>
  33 
  34 #include <stropts.h>
  35 #include <strings.h>
  36 #include <syslog.h>
  37 #include <alloca.h>
  38 #include <unistd.h>
  39 #include <stdlib.h>
  40 #include <errno.h>
  41 #include <fcntl.h>
  42 
  43 static struct stats {
  44         fmd_stat_t bad_vers;
  45         fmd_stat_t bad_code;
 
 296         if ((msg = fmd_msg_gettext_nv(syslog_msghdl, NULL, nvl)) == NULL) {
 297                 fmd_hdl_debug(hdl, "failed to format message");
 298                 syslog_stats.bad_code.fmds_value.ui64++;
 299                 return; /* libfmd_msg error */
 300         }
 301 
 302         syslog_ctl.pri &= LOG_FACMASK;
 303         if (strcmp(class, FM_LIST_ISOLATED_CLASS) == 0 ||
 304             strcmp(class, FM_LIST_RESOLVED_CLASS) == 0 ||
 305             strcmp(class, FM_LIST_REPAIRED_CLASS) == 0 ||
 306             strcmp(class, FM_LIST_UPDATED_CLASS) == 0)
 307                 syslog_ctl.pri |= LOG_NOTICE;
 308         else
 309                 syslog_ctl.pri |= LOG_ERR;
 310 
 311         syslog_emit(hdl, msg);
 312         free(msg);
 313 }
 314 
 315 static const fmd_prop_t fmd_props[] = {
 316         { "console", FMD_TYPE_BOOL, "true" },
 317         { "facility", FMD_TYPE_STRING, "LOG_DAEMON" },
 318         { "gmt", FMD_TYPE_BOOL, "false" },
 319         { "syslogd", FMD_TYPE_BOOL, "true" },
 320         { "url", FMD_TYPE_STRING, "http://illumos.org/msg/" },
 321         { "message_all", FMD_TYPE_BOOL, "false" },
 322         { NULL, 0, NULL }
 323 };
 324 
 325 static const fmd_hdl_ops_t fmd_ops = {
 326         syslog_recv,    /* fmdo_recv */
 327         NULL,           /* fmdo_timeout */
 328         NULL,           /* fmdo_close */
 329         NULL,           /* fmdo_stats */
 330         NULL,           /* fmdo_gc */
 331 };
 332 
 333 static const fmd_hdl_info_t fmd_info = {
 334         "Syslog Messaging Agent", "1.1", &fmd_ops, fmd_props
 335 };
 336 
 
 | 
 
 
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 /*
  27  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  28  */
  29 
  30 #include <sys/fm/protocol.h>
  31 #include <sys/strlog.h>
  32 #include <sys/log.h>
  33 #include <libscf.h>
  34 
  35 #include <fm/fmd_api.h>
  36 #include <fm/fmd_msg.h>
  37 
  38 #include <stropts.h>
  39 #include <strings.h>
  40 #include <syslog.h>
  41 #include <alloca.h>
  42 #include <unistd.h>
  43 #include <stdlib.h>
  44 #include <errno.h>
  45 #include <fcntl.h>
  46 
  47 static struct stats {
  48         fmd_stat_t bad_vers;
  49         fmd_stat_t bad_code;
 
 300         if ((msg = fmd_msg_gettext_nv(syslog_msghdl, NULL, nvl)) == NULL) {
 301                 fmd_hdl_debug(hdl, "failed to format message");
 302                 syslog_stats.bad_code.fmds_value.ui64++;
 303                 return; /* libfmd_msg error */
 304         }
 305 
 306         syslog_ctl.pri &= LOG_FACMASK;
 307         if (strcmp(class, FM_LIST_ISOLATED_CLASS) == 0 ||
 308             strcmp(class, FM_LIST_RESOLVED_CLASS) == 0 ||
 309             strcmp(class, FM_LIST_REPAIRED_CLASS) == 0 ||
 310             strcmp(class, FM_LIST_UPDATED_CLASS) == 0)
 311                 syslog_ctl.pri |= LOG_NOTICE;
 312         else
 313                 syslog_ctl.pri |= LOG_ERR;
 314 
 315         syslog_emit(hdl, msg);
 316         free(msg);
 317 }
 318 
 319 static const fmd_prop_t fmd_props[] = {
 320 #ifdef DEBUG
 321         { "console", FMD_TYPE_BOOL, "true" },
 322 #else
 323         { "console", FMD_TYPE_BOOL, "false" },
 324 #endif
 325         { "facility", FMD_TYPE_STRING, "LOG_DAEMON" },
 326         { "gmt", FMD_TYPE_BOOL, "false" },
 327         { "syslogd", FMD_TYPE_BOOL, "true" },
 328         { "url", FMD_TYPE_STRING, "http://illumos.org/msg/" },
 329         { "message_all", FMD_TYPE_BOOL, "false" },
 330         { NULL, 0, NULL }
 331 };
 332 
 333 static const fmd_hdl_ops_t fmd_ops = {
 334         syslog_recv,    /* fmdo_recv */
 335         NULL,           /* fmdo_timeout */
 336         NULL,           /* fmdo_close */
 337         NULL,           /* fmdo_stats */
 338         NULL,           /* fmdo_gc */
 339 };
 340 
 341 static const fmd_hdl_info_t fmd_info = {
 342         "Syslog Messaging Agent", "1.1", &fmd_ops, fmd_props
 343 };
 344 
 
 |