int main(int argc, char *argv[]) { log_options_t opts = LOG_OPTS_STDERR_ONLY; int rc = 0; slurm_conf_init(NULL); log_init(xbasename(argv[0]), opts, SYSLOG_FACILITY_USER, NULL); parse_command_line(argc, argv); if (params.verbose) { opts.stderr_level += params.verbose; log_alter(opts, SYSLOG_FACILITY_USER, NULL); } while (1) { if ((!params.no_header) && (params.iterate || params.verbose || params.long_output)) print_date(); if (!params.clusters) { if (_get_info(false)) rc = 1; } else if (_multi_cluster(params.clusters) != 0) rc = 1; if (params.iterate) { printf("\n"); sleep(params.iterate); } else break; } exit(rc); }
int main (int argc, char *argv[]) { log_options_t opts = LOG_OPTS_STDERR_ONLY ; int error_code = SLURM_SUCCESS; log_init(xbasename(argv[0]), opts, SYSLOG_FACILITY_USER, NULL); parse_command_line( argc, argv ); if (params.verbose) { opts.stderr_level += params.verbose; log_alter(opts, SYSLOG_FACILITY_USER, NULL); } max_line_size = _get_window_width( ); if (params.clusters) working_cluster_rec = list_peek(params.clusters); while (1) { if ((!params.no_header) && (params.iterate || params.verbose || params.long_list)) _print_date (); if (!params.clusters) { if (_get_info(false)) error_code = 1; } else if (_multi_cluster(params.clusters) != 0) error_code = 1; if ( params.iterate ) { printf( "\n"); sleep( params.iterate ); } else break; } if ( error_code != SLURM_SUCCESS ) exit (error_code); else exit (0); }
int main (int argc, char *argv[]) { log_options_t log_opts = LOG_OPTS_STDERR_ONLY ; int rc = 0; slurm_conf_init(NULL); log_init (xbasename(argv[0]), log_opts, SYSLOG_FACILITY_DAEMON, NULL); initialize_and_process_args(argc, argv); if (opt.verbose) { log_opts.stderr_level += opt.verbose; log_alter (log_opts, SYSLOG_FACILITY_DAEMON, NULL); } if (opt.clusters) rc = _multi_cluster(opt.clusters); else rc = _proc_cluster(); exit(rc); }
int main (int argc, char **argv) { int opt_char; log_options_t opts = LOG_OPTS_STDERR_ONLY; shares_request_msg_t req_msg; char *temp = NULL; int option_index; bool all_users = 0; static struct option long_options[] = { {"accounts", 1, 0, 'A'}, {"all", 0, 0, 'a'}, {"helpformat",0,0, 'e'}, {"long", 0, 0, 'l'}, {"partition",0, 0, 'm'}, {"cluster", 1, 0, 'M'}, {"clusters", 1, 0, 'M'}, {"noheader", 0, 0, 'n'}, {"format", 1, 0, 'o'}, {"parsable", 0, 0, 'p'}, {"parsable2",0, 0, 'P'}, {"users", 1, 0, 'u'}, {"Users", 0, 0, 'U'}, {"verbose", 0, 0, 'v'}, {"version", 0, 0, 'V'}, {"help", 0, 0, OPT_LONG_HELP}, {"usage", 0, 0, OPT_LONG_USAGE}, {NULL, 0, 0, 0} }; exit_code = 0; long_flag = 0; quiet_flag = 0; verbosity = 0; memset(&req_msg, 0, sizeof(shares_request_msg_t)); slurm_conf_init(NULL); log_init("sshare", opts, SYSLOG_FACILITY_DAEMON, NULL); while ((opt_char = getopt_long(argc, argv, "aA:ehlM:no:pPqUu:t:vVm", long_options, &option_index)) != -1) { switch (opt_char) { case (int)'?': fprintf(stderr, "Try \"sshare --help\" " "for more information\n"); exit(1); break; case 'a': all_users = 1; break; case 'A': if (!req_msg.acct_list) req_msg.acct_list = list_create(slurm_destroy_char); slurm_addto_char_list(req_msg.acct_list, optarg); break; case 'e': _help_format_msg(); exit(0); break; case 'h': print_fields_have_header = 0; break; case 'l': long_flag = 1; break; case 'M': FREE_NULL_LIST(clusters); if (!(clusters = slurmdb_get_info_cluster(optarg))) { print_db_notok(optarg, 0); exit(1); } working_cluster_rec = list_peek(clusters); break; case 'm': options |= PRINT_PARTITIONS; break; case 'n': print_fields_have_header = 0; break; case 'o': xstrfmtcat(opt_field_list, "%s,", optarg); break; case 'p': print_fields_parsable_print = PRINT_FIELDS_PARSABLE_ENDING; break; case 'P': print_fields_parsable_print = PRINT_FIELDS_PARSABLE_NO_ENDING; break; case 'u': if (!xstrcmp(optarg, "-1")) { all_users = 1; break; } all_users = 0; if (!req_msg.user_list) req_msg.user_list = list_create(slurm_destroy_char); _addto_name_char_list(req_msg.user_list, optarg, 0); break; case 'U': options |= PRINT_USERS_ONLY; break; case 'v': quiet_flag = -1; verbosity++; break; case 'V': _print_version(); exit(exit_code); break; case OPT_LONG_HELP: case OPT_LONG_USAGE: _usage(); exit(0); default: exit_code = 1; fprintf(stderr, "getopt error, returned %c\n", opt_char); exit(exit_code); } } if (verbosity) { opts.stderr_level += verbosity; opts.prefix_level = 1; log_alter(opts, 0, NULL); } if (all_users) { if (req_msg.user_list && list_count(req_msg.user_list)) { FREE_NULL_LIST(req_msg.user_list); } if (verbosity) fprintf(stderr, "Users requested:\n\t: all\n"); } else if (verbosity && req_msg.user_list && list_count(req_msg.user_list)) { fprintf(stderr, "Users requested:\n"); ListIterator itr = list_iterator_create(req_msg.user_list); while ((temp = list_next(itr))) fprintf(stderr, "\t: %s\n", temp); list_iterator_destroy(itr); } else if (!req_msg.user_list || !list_count(req_msg.user_list)) { struct passwd *pwd; if ((pwd = getpwuid(getuid()))) { if (!req_msg.user_list) { req_msg.user_list = list_create(slurm_destroy_char); } temp = xstrdup(pwd->pw_name); list_append(req_msg.user_list, temp); if (verbosity) { fprintf(stderr, "Users requested:\n"); fprintf(stderr, "\t: %s\n", temp); } } } if (req_msg.acct_list && list_count(req_msg.acct_list)) { if (verbosity) { fprintf(stderr, "Accounts requested:\n"); ListIterator itr = list_iterator_create(req_msg.acct_list); while ((temp = list_next(itr))) fprintf(stderr, "\t: %s\n", temp); list_iterator_destroy(itr); } } else { if (req_msg.acct_list && list_count(req_msg.acct_list)) { FREE_NULL_LIST(req_msg.acct_list); } if (verbosity) fprintf(stderr, "Accounts requested:\n\t: all\n"); } if (clusters) exit_code = _multi_cluster(&req_msg); else exit_code = _single_cluster(&req_msg); exit(exit_code); }