int main(int argc, const char *argv[]) { int c, ret; if((ret = omlc_init("click_mon", &argc, argv, NULL)) < 0) { logerror("Could not initialise OML\n"); return -1; } /* Parse command line arguments */ poptContext optCon = poptGetContext(NULL, argc, argv, options, 0); /* options is defined in click_mon_popt.h */ while ((c = poptGetNextOpt(optCon)) > 0) {} /* Initialise measurement points, only if OML is not disabled */ oml_register_mps(); /* Defined in click_mon_oml.h */ if(ret == 0 && omlc_start()) { logerror("Could not start OML\n"); return -1; } run(g_opts, g_oml_mps_click_mon); /* Do some work and injections, see above */ omlc_close(); return 0; }
int main(int argc, const char *argv[]) { int c, i, ret; /* Reconstruct command line */ size_t cmdline_len = 0; for(i = 0; i < argc; i++) { cmdline_len += strlen(argv[i]) + 1; } char *cmdline = oml_malloc(cmdline_len); cmdline[0] = '\0'; for(i = 0; i < argc; i++) { strncat(cmdline, argv[i], cmdline_len); cmdline_len -= strlen(argv[i]); strncat(cmdline, " ", cmdline_len); cmdline_len--; } /* Initialize OML */ if((ret = omlc_init("generator", &argc, argv, NULL)) < 0) { logerror("Could not initialise OML\n"); return -1; } /* Parse command line arguments */ poptContext optCon = poptGetContext(NULL, argc, argv, options, 0); /* options is defined in generator_popt.h */ while ((c = poptGetNextOpt(optCon)) > 0) {} /* Initialise measurement points and start OML */ oml_register_mps(); /* Defined in generator_oml.h */ if(omlc_start()) { logerror("Could not start OML\n"); return -1; } /* Inject some metadata about this application */ OmlValueU v; omlc_zero(v); omlc_set_string(v, PACKAGE_NAME); omlc_inject_metadata(NULL, "appname", &v, OML_STRING_VALUE, NULL); omlc_set_string(v, PACKAGE_VERSION); omlc_inject_metadata(NULL, "version", &v, OML_STRING_VALUE, NULL); omlc_set_string(v, cmdline); omlc_inject_metadata(NULL, "cmdline", &v, OML_STRING_VALUE, NULL); omlc_reset_string(v); oml_free(cmdline); /* Inject measurements */ run(g_opts, g_oml_mps_generator); /* Do some work and injections, see above */ omlc_close(); return 0; }
int main( int argc, const char *argv[] ) { int c; omlc_init("generator", &argc, argv, NULL); // parsing command line arguments poptContext optCon = poptGetContext(NULL, argc, argv, options, 0); while ((c = poptGetNextOpt(optCon)) > 0) {} // Initialize measurment points oml_register_mps(); // defined in xxx_oml.h omlc_start(); // Do some work run(g_opts, g_oml_mps_generator); return(0); }
/** Set up connection to a monitoring OML server. * * \param argc non-NULL pointer to the argument count * \param argv argument vector */ void oml_setup(int *argc, const char **argv) { int result; /* connect to the monitoring server */ result = omlc_init("server", argc, argv, NULL); if(0 == result) { logdebug("Initialised OML client library\n"); oml_register_mps(); if(omlc_start() == 0) { logdebug("Started OML reporting of server's internal metrics\n"); oml_enabled = 1; } else { logwarn("Could not start OML client library; this does not impact the server's collection capabilities\n"); } } else if (result == 1) { logdebug ("OML was disabled by the user\n"); } else { logwarn("Could not initialise OML client library; this does not impact the server's collection capabilities\n"); } }