Example #1
0
int main (int argc, char *argv[])
{
    flux_t *h;
    int ch = 0;
    int rc = 0;
    char *cmd = NULL;
    const char *j = NULL;
    const char *ofn = NULL;
    const char *attr = NULL;
    const char *jcbstr = NULL;

    log_init ("flux-jstat");
    while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) {
        switch (ch) {
        case 'h': /* --help */
            usage (0);
            break;
        case 'o': /* --testout */
            ofn = xasprintf ("%s", optarg);
            break;
        default:
            usage (1);
            break;
        }
    }
    if (optind == argc)
        usage (1);

    if (!(h = flux_open  (NULL, 0)))
        log_err_exit ("flux_open");

    flux_log_set_appname (h, "jstat");
    cmd = argv[optind++];

    if (!strcmp ("notify", cmd))
        rc = handle_notify_req (h, (const char *)ofn);
    else if (!strcmp ("query", cmd) && optind == argc - 2) {
        j = (const char *)(*(argv+optind));
        attr = (const char *)(*(argv+optind+1));
        rc = handle_query_req (h, strtol (j, NULL, 10), attr, ofn);
    }
    else if (!strcmp ("update", cmd) && optind == argc - 3) {
        j = (const char *)(*(argv+optind));
        attr = (const char *)(*(argv+optind+1));
        jcbstr = (const char *)(*(argv+optind+2));
        rc = handle_update_req (h, strtol (j, NULL, 10), attr, jcbstr, ofn);
    }
    else
        usage (1);

    flux_close (h);
    log_fini ();

    return (!rc)? 0: 42;
}
Example #2
0
int main (int argc, char *argv[])
{
    flux_t h;
    int ch = 0;
    int64_t jobid = -1;
    char *sfn = NULL;
    char *cfn = NULL;
    wjctx_t *ctx = NULL;

    log_init ("flux-waitjob");
    while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) {
        switch (ch) {
            case 'h': /* --help */
                usage ();
                break;
            case 's': /* --sync-start */
                sfn = xstrdup (optarg);
                break;
            case 'c': /* --sync-complete */
                cfn = xstrdup (optarg);
                break;
            default:
                usage ();
                break;
        }
    }
    if (optind == argc)
        usage ();

    jobid = strtol (argv[optind], NULL, 10);
    if (jobid <= 0)
        log_err_exit ("jobid must be a positive number");
    else if (!(h = flux_open  (NULL, 0)))
        log_err_exit ("flux_open");

    ctx = getctx (h);
    if (sfn)
        ctx->start = sfn;
    if (cfn)
        ctx->complete = cfn;
    ctx->jobid = jobid;

    flux_log_set_appname (h, "waitjob");
    wait_job_complete (h);

    flux_close (h);
    log_fini ();

    return 0;
}
Example #3
0
int main (int argc, char *argv[])
{
    flux_t h;
    int ch;
    char *message = NULL;
    size_t len = 0;
    int severity = LOG_NOTICE;
    char *appname = "logger";
    int e;

    log_init ("flux-logger");

    while ((ch = getopt_long (argc, argv, OPTIONS, longopts, NULL)) != -1) {
        switch (ch) {
            case 'h': /* --help */
                usage ();
                break;
            case 's': /* --severity LEVEL */
                if ((severity = stdlog_string_to_severity (optarg)) < 0)
                    log_msg_exit ("invalid severity: Use emerg|alert|crit|err|warning|notice|info|debug");
                break;
            case 'n': /* --appname NAME */
                appname = optarg;
                break;
            default:
                usage ();
                break;
        }
    }
    if (optind == argc)
        usage ();

    if ((e = argz_create (argv + optind, &message, &len)) != 0)
        log_errn_exit (e, "argz_create");
    argz_stringify (message, len, ' ');

    if (!(h = flux_open (NULL, 0)))
        log_err_exit ("flux_open");

    flux_log_set_appname (h, appname);
    flux_log (h, severity, "%s", message);

    flux_close (h);

    free (message);
    log_fini ();
    return 0;
}