/** The main NEB module deinitialization routine. * * This function gets called when the module is unloaded by the event broker. * * @param[in] flags - nagios NEB module flags - not used. * @param[in] reason - nagios reason code - not used. * * @return Always returns zero. */ int nebmodule_deinit(int flags, int reason) { dnxLog("-------- DNX Server Module Shutdown Initiated --------"); dnxServerDeInit(); releaseConfig(); xheapchk(); dnxLog("-------- DNX Server Module Shutdown Completed --------"); return 0; }
/** The main program entry point for the dnx management client. * * @param[in] argc - the number of elements in the @p argv array. * @param[in] argv - a null-terminated array of command-line arguments. * * @return Zero on success, or a non-zero error code that is returned to the * shell. Any non-zero codes should be values between 1 and 127. */ int main(int argc, char ** argv) { extern char * optarg; extern int optind, opterr, optopt; gTopDCS = dnxComStatCreateDCS("127.0.0.1"); int ch, ret; char * cp, * prog, * cmdstr; char * hoststr, * portstr; // get program base name prog = (char *)((cp = strrchr(argv[0], '/')) != 0 ? (cp + 1) : argv[0]); // parse arguments hoststr = "localhost"; portstr = "12482"; opterr = 0; cmdstr = 0; while ((ch = getopt(argc, argv, "hvc:s:p:")) != -1) { switch (ch) { case 's': hoststr = optarg; break; case 'p': portstr = optarg; break; case 'c': cmdstr = optarg; break; case 'v': printf("\n %s version %s\n Bug reports: %s.\n\n", prog, VERSION, PACKAGE_BUGREPORT); exit(0); case 'h': default : usage(prog); } } // ensure we've been given a command if (!cmdstr) { fprintf(stderr, "%s: No command string specified.\n", prog); usage(prog); } // init comm sub-system; send command; wait for response if ((ret = dnxChanMapInit(0)) != 0) fprintf(stderr, "%s: Error initializing channel map: %s.\n", prog, dnxErrorString(ret)); else { char url[1024]; snprintf(url, sizeof url, "udp://%s:%s", hoststr, portstr); if ((ret = dnxChanMapAdd("MgmtClient", url)) != 0) fprintf(stderr, "%s: Error adding channel (%s): %s.\n", prog, url, dnxErrorString(ret)); else { DnxChannel * channel; if ((ret = dnxConnect("MgmtClient", 1, &channel)) != 0) fprintf(stderr, "%s: Error connecting to server (%s): %s.\n", prog, url, dnxErrorString(ret)); else { DnxMgmtRequest req; memset(&req, 0, sizeof req); dnxMakeXID(&req.xid, DNX_OBJ_MANAGER, 0, 0); req.action = cmdstr; if ((ret = dnxSendMgmtRequest(channel, &req, 0)) != 0) fprintf(stderr, "%s: Error sending request: %s.\n", prog, dnxErrorString(ret)); else { DnxMgmtReply rsp; if ((ret = dnxWaitForMgmtReply(channel, &rsp, 0, 10)) != 0) fprintf(stderr, "%s: Error receiving response: %s.\n", prog, dnxErrorString(ret)); else { if (rsp.status == DNX_REQ_ACK) printf("%s\n", rsp.reply); else fprintf(stderr, "%s: Request failed on server.\nResponse was (%s)\n", prog,rsp.reply); } } dnxDisconnect(channel); } dnxChanMapDelete("MgmtClient"); } dnxChanMapRelease(); } xheapchk(); return ret? -1: 0; }