int init_ipmi_handler(void) { const char *__function_name = "init_ipmi_handler"; int ret; zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name); if (NULL == (os_hnd = ipmi_posix_setup_os_handler())) { zabbix_log(LOG_LEVEL_WARNING, "unable to allocate IPMI handler"); return FAIL; } os_hnd->set_log_handler(os_hnd, my_vlog); if (0 != (ret = ipmi_init(os_hnd))) { zabbix_log(LOG_LEVEL_WARNING, "unable to initialize the OpenIPMI library." " ipmi_init() return error: 0x%x", ret); return FAIL; } zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name); return SUCCEED; }
int main(int argc, char *argv[]) { int rv; int curr_arg = 1; ipmi_args_t *args; ipmi_con_t *con; progname = argv[0]; /* OS handler allocated first. */ os_hnd = ipmi_posix_setup_os_handler(); if (!os_hnd) { printf("ipmi_smi_setup_con: Unable to allocate os handler\n"); exit(1); } /* Use the default log handler. */ /* Initialize the OpenIPMI library. */ ipmi_init(os_hnd); rv = ipmi_parse_args2(&curr_arg, argc, argv, &args); if (rv) { fprintf(stderr, "Error parsing command arguments, argument %d: %s\n", curr_arg, strerror(rv)); usage(); exit(1); } rv = ipmi_args_setup_con(args, os_hnd, NULL, &con); if (rv) { fprintf(stderr, "ipmi_ip_setup_con: %s", strerror(rv)); exit(1); } rv = ipmi_open_domain("", &con, 1, setup_done, NULL, NULL, NULL, NULL, 0, NULL); if (rv) { fprintf(stderr, "ipmi_init_domain: %s\n", strerror(rv)); exit(1); } /* This is the main loop of the event-driven program. Try <CTRL-C> to exit the program */ /* Let the selector code run the select loop. */ os_hnd->operation_loop(os_hnd); /* Technically, we can't get here, but this is an example. */ os_hnd->free_os_handler(os_hnd); return 0; }
int init_ipmi_handler() { zabbix_log(LOG_LEVEL_DEBUG, "In init_ipmi_handler()"); if (NULL == (os_hnd = ipmi_posix_setup_os_handler())) { zabbix_log(LOG_LEVEL_WARNING, "Unable to allocate IPMI handler"); return FAIL; } os_hnd->set_log_handler(os_hnd, my_vlog); ipmi_init(os_hnd); return SUCCEED; }
int main(int argc, char **argv) { reg_sigterm_handler(sigterm_handler); rmm_log_init(); enable_core_dump(); init_ipmi_subscribe(); ipmi_init(); register_ipmb_resp(); register_rmcp_resp(); IPMI_LOG_INFO("IPMI-Daemon is Running ...\n"); fd_events_main_loop(); return 0; }
int init_ipmi_handler() { const char *__function_name = "init_ipmi_handler"; zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name); if (NULL == (os_hnd = ipmi_posix_setup_os_handler())) { zabbix_log(LOG_LEVEL_WARNING, "unable to allocate IPMI handler"); return FAIL; } os_hnd->set_log_handler(os_hnd, my_vlog); ipmi_init(os_hnd); zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name); return SUCCEED; }
static int run_prd_daemon(struct opal_prd_ctx *ctx) { int rc; /* log to syslog */ pr_log_daemon_init(); ctx->fd = -1; ctx->socket = -1; i2c_init(); #ifdef DEBUG_I2C { uint8_t foo[128]; int i; rc = i2c_read(0, 1, 2, 0x50, 2, 0x10, 128, foo); pr_debug("I2C: read rc: %d", rc); for (i = 0; i < sizeof(foo); i += 8) { pr_debug("I2C: %02x %02x %02x %02x %02x %02x %02x %02x", foo[i + 0], foo[i + 1], foo[i + 2], foo[i + 3], foo[i + 4], foo[i + 5], foo[i + 6], foo[i + 7]); } } #endif rc = init_control_socket(ctx); if (rc) { pr_log(LOG_WARNING, "CTRL: Error initialising PRD control: %m"); goto out_close; } rc = prd_init(ctx); if (rc) { pr_log(LOG_ERR, "FW: Error initialising PRD channel"); goto out_close; } if (ctx->hbrt_file_name) { rc = map_hbrt_file(ctx, ctx->hbrt_file_name); if (rc) { pr_log(LOG_ERR, "IMAGE: Can't access hbrt file %s", ctx->hbrt_file_name); goto out_close; } } else { rc = map_hbrt_physmem(ctx, hbrt_code_region_name); if (rc) { pr_log(LOG_ERR, "IMAGE: Can't access hbrt " "physical memory"); goto out_close; } dump_hbrt_map(ctx); } pr_debug("IMAGE: hbrt map at %p, size 0x%zx", ctx->code_addr, ctx->code_size); fixup_hinterface_table(); pr_debug("HBRT: calling hservices_init"); hservices_init(ctx, ctx->code_addr); pr_debug("HBRT: hservices_init done"); if (ctx->pnor.path) { rc = pnor_init(&ctx->pnor); if (rc) { pr_log(LOG_ERR, "PNOR: Failed to open pnor: %m"); goto out_close; } } ipmi_init(ctx); /* Test a scom */ if (ctx->debug) { uint64_t val; pr_debug("SCOM: trying scom read"); fflush(stdout); hservice_scom_read(0x00, 0xf000f, &val); pr_debug("SCOM: f00f: %lx", be64toh(val)); } run_attn_loop(ctx); rc = 0; out_close: pnor_close(&ctx->pnor); if (ctx->fd != -1) close(ctx->fd); if (ctx->socket != -1) close(ctx->socket); return rc; }
int main(int argc, char *argv[]) { int fd = -1; pid_t pgid = -1; server_conf_t *conf; int log_priority = LOG_INFO; #ifndef NDEBUG log_priority = LOG_DEBUG; #endif /* NDEBUG */ log_set_file(stderr, log_priority, 0); conf = create_server_conf(); tp_global = conf->tp; process_cmdline(conf, argc, argv); if (!conf->enableForeground) { begin_daemonize(&fd, &pgid); } process_config(conf); setup_coredump(conf); setup_signals(conf); if (!(environ = get_sane_env())) { log_err(ENOMEM, "Unable to create sanitized environment"); } if (conf->enableVerbose) { display_configuration(conf); } if (list_is_empty(conf->objs)) { log_err(0, "Configuration \"%s\" has no consoles defined", conf->confFileName); } if (conf->tStampMinutes > 0) { schedule_timestamp(conf); } create_listen_socket(conf); if (!conf->enableForeground) { if (conf->syslogFacility > 0) { log_set_syslog(argv[0], conf->syslogFacility); } if (conf->logFileName) { open_daemon_logfile(conf); } else { log_set_file(NULL, 0, 0); } end_daemonize(fd); } log_msg(LOG_NOTICE, "Starting ConMan daemon %s (pid %d)", VERSION, (int) getpid()); #if WITH_FREEIPMI ipmi_init(conf->numIpmiObjs); #endif /* WITH_FREEIPMI */ open_objs(conf); mux_io(conf); #if WITH_FREEIPMI ipmi_fini(); #endif /* WITH_FREEIPMI */ destroy_server_conf(conf); if (pgid > 0) { if (kill(-pgid, SIGTERM) < 0) { log_msg(LOG_WARNING, "Unable to terminate process group ID %d: %s", pgid, strerror(errno)); } } log_msg(LOG_NOTICE, "Stopping ConMan daemon %s (pid %d)", VERSION, (int) getpid()); exit(0); }
int main(int argc, char *argv[]) { int rv; int curr_arg; ipmi_args_t *args; int i; progname = argv[0]; /* Have to initalize this first so the usage help will work, since it needs OpenIPMI initialized. */ /* OS handler allocated first. */ os_hnd = ipmi_posix_get_os_handler(); if (!os_hnd) { fprintf(stderr, "ipmi_smi_setup_con: Unable to allocate os handler\n"); exit(1); } /* Create selector with os handler. */ rv = sel_alloc_selector_nothread(&sel); if (rv) { fprintf(stderr, "Error allocating selector: 0x%x\n", rv); exit(1); } /* The OS handler has to know about the selector. */ ipmi_posix_os_handler_set_sel(os_hnd, sel); /* Initialize the OEM handlers. */ rv = ipmi_init(os_hnd); if (rv) { fprintf(stderr, "Error initializing connections: 0x%x\n", rv); exit(1); } for (i=1; i<argc; i++) { if (argv[i][0] != '-') break; if (strcmp(argv[i], "--") == 0) { i++; break; } else if ((strcmp(argv[i], "-k") == 0) || (strcmp(argv[i], "--command") == 0)) { i++; if (i >= argc) { usage(); exit(1); } cmdstr = argv[i]; interactive = 0; } else if ((strcmp(argv[i], "-v") == 0) || (strcmp(argv[i], "--version") == 0)) { printInfo(); exit(0); } else { usage(); exit(1); } } if (i >= argc) { fprintf(stderr, "Not enough arguments\n"); exit(1); } curr_arg = i; if (strcmp(argv[0], "ipmicmd") == 0) /* Backwards compatible interface */ rv = ipmi_parse_args(&curr_arg, argc, argv, &args); else rv = ipmi_parse_args2(&curr_arg, argc, argv, &args); if (rv) { fprintf(stderr, "Error parsing command arguments, argument %d: %s\n", curr_arg, strerror(rv)); exit(1); } rv = ipmi_args_setup_con(args, os_hnd, sel, &con); if (rv) { fprintf(stderr, "ipmi_ip_setup_con: %s\n", strerror(rv)); exit(1); } if (interactive) { rv = con->add_event_handler(con, event_handler, NULL); if (rv) { fprintf(stderr, "Could not set to get events: %x\n", rv); } sel_set_fd_handlers(sel, 0, NULL, user_input_ready, NULL, NULL, NULL); sel_set_fd_read_handler(sel, 0, SEL_FD_HANDLER_ENABLED); } con->add_con_change_handler(con, con_changed_handler, NULL); rv = con->start_con(con); if (rv) { fprintf(stderr, "Could not start connection: %x\n", rv); exit(1); } if (interactive) printf("=> "); fflush(stdout); while (continue_operation) { rv = os_hnd->perform_one_op(os_hnd, NULL); if (rv) break; } leave(rv); return rv; }
int main(int argc, const char *argv[]) { int rv; int curr_arg = 1; ipmi_args_t *args; ipmi_con_t *con; progname = argv[0]; /* OS handler allocated first. */ os_hnd = ipmi_posix_get_os_handler(); if (!os_hnd) { printf("ipmi_smi_setup_con: Unable to allocate os handler\n"); exit(1); } /* Create selector with os handler. */ sel_alloc_selector(os_hnd, &sel); /* The OS handler has to know about the selector. */ ipmi_posix_os_handler_set_sel(os_hnd, sel); /* Initialize the OpenIPMI library. */ ipmi_init(os_hnd); #if 1 if(argc > 1) { argc--; sname = argv[1]; argv++; }else { usage(); exit(-1); } #endif rv = ipmi_parse_args(&curr_arg, argc, argv, &args); if (rv) { fprintf(stderr, "Error parsing command arguments, argument %d: %s\n", curr_arg, strerror(rv)); usage(); exit(1); } rv = ipmi_args_setup_con(args, os_hnd, sel, &con); if (rv) { fprintf(stderr, "ipmi_ip_setup_con: %s", strerror(rv)); exit(1); } rv = ipmi_init_domain(&con, 1, setup_done, NULL, NULL, NULL); if (rv) { fprintf(stderr, "ipmi_init_domain: %s\n", strerror(rv)); exit(1); } /* We run the select loop here, this shows how you can use sel_select. You could add your own processing in this loop. */ while (1) { sel_select(sel, NULL, 0, NULL, NULL); if (done) { done = 0; printf("done\n"); } } }