コード例 #1
0
void workers_completion (int rc,
                         const struct String_vector *strings,
                         const void *data) {
    switch (rc) {
        case ZCONNECTIONLOSS:
        case ZOPERATIONTIMEOUT:
            get_workers();
            
            break;
        case ZOK:
            if(strings->count == 1) {
                LOG_DEBUG(("Got %d worker", strings->count));
            } else {
                LOG_DEBUG(("Got %d workers", strings->count));
            }

            struct String_vector *tmp_workers = removed_and_set(strings, &workers);
            free_vector(tmp_workers);
            get_tasks();

            break;
        default:
            LOG_ERROR(("Something went wrong when checking workers: %s", rc2string(rc)));
            
            break;
    }
}
コード例 #2
0
ファイル: mesos_state.cpp プロジェクト: bmandrade/sysdig
marathon_group::ptr_t mesos_state_t::add_group(const Json::Value& group, marathon_group::ptr_t to_group, const std::string& framework_id)
{
	Json::Value group_id = group["id"];
	if(!group_id.isNull())
	{
		std::string id = group_id.asString();
		std::ostringstream os;
		os << "Adding Marathon group [" + id + ']';
		if(to_group)
		{
			os << " to group [" + to_group->get_id() << ']';
		}
		g_logger.log(os.str(), sinsp_logger::SEV_INFO);
		marathon_group::ptr_t pg(new marathon_group(id));
		marathon_group::ptr_t p_group = add_or_replace_group(pg, to_group);
		if(!framework_id.empty())
		{
			Json::Value apps = group["apps"];
			if(!apps.isNull())
			{
				for(const auto& app : apps)
				{
					Json::Value app_id = app["id"];
					if(!app_id.isNull())
					{
						marathon_app::ptr_t p_app = get_app(app_id.asString());
						if(!p_app)
						{
							p_app = add_app(app, framework_id);
						}
						if(p_app)
						{
							p_group->add_or_replace_app(p_app);
							for(const auto& task : get_tasks(framework_id))
							{
								if(task.second->get_marathon_app_id() == app_id.asString())
								{
									add_task_to_app(p_app, task.first);
								}
							}
						}
						else
						{
							g_logger.log("An error occured adding app [" + app_id.asString() +
										"] to group [" + id + ']', sinsp_logger::SEV_ERROR);
						}
					}
				}
			}
		}
		return p_group;
	}
	return 0;
}
コード例 #3
0
ファイル: default_profile.cpp プロジェクト: m000/panda
/**
 * @brief Retrieves the address of the following task_struct in the process list.
 *
 * XXX: Can now be implemented with IMPLEMENT_OFFSET_GETTER_2LN
 */
target_ptr_t default_get_task_struct_next(CPUState *env, target_ptr_t task_struct)
{
    target_ptr_t tasks = get_tasks(env, task_struct);

    if (!tasks) {
        return (target_ptr_t)NULL;
    }
    else {
        return tasks-ki.task.tasks_offset;
    }
}
コード例 #4
0
/**
 *
 * Watcher function called when the list of tasks
 * changes.
 *
 */
void tasks_watcher (zhandle_t *zh,
                    int type,
                    int state,
                    const char *path,
                    void *watcherCtx) {
    LOG_DEBUG(("Tasks watcher triggered %s %d", path, state));
    if( type == ZOO_CHILD_EVENT) {
        assert( !strcmp(path, "/tasks") );
        get_tasks();
    } else {
        LOG_INFO(("Watched event: %s", type2string(type)));
    }
    LOG_DEBUG(("Tasks watcher done"));
}
コード例 #5
0
ファイル: test.c プロジェクト: skn/tasknc
void test_search() /* {{{ */
{
	/* test search functionality */
	char *addcmdstr, *testcmdstr, *tmp;
	const char *proj = "test123";
	const char pri = 'H';
	const char *unique = "simple";
	FILE *cmdout;
	task *this;
	bool pass;

	asprintf(&addcmdstr, "task add pro:%s pri:%c %s", proj, pri, unique);
	cmdout = popen(addcmdstr, "r");
	pclose(cmdout);
	free_tasks(head);
	head = get_tasks(NULL);

	stdout = devnull;
	searchstring = strdup(unique);
	find_next_search_result(head, head);
	stdout = out;
	this = get_task_by_position(selline);
	pass = strcmp(this->project, proj)==0 && this->priority==pri;
	test_result("search", pass);
	if (!pass)
	{
		puts(addcmdstr);
		tmp = var_value_message(find_var("search_string"), 1);
		puts(tmp);
		free(tmp);
		puts("selected:");
		printf("uuid: %s\n", this->uuid);
		printf("description: %s\n", this->description);
		printf("project: %s\n", this->project);
		printf("tags: %s\n", this->tags);
		fflush(stdout);
		asprintf(&testcmdstr, "task list %s", unique);
		system(testcmdstr);
		free(testcmdstr);
	}

	cmdout = popen("task undo", "r");
	pclose(cmdout);
	free(addcmdstr);
} /* }}} */
コード例 #6
0
ファイル: kernel.c プロジェクト: aianus/trains
void dump_timing_info(unsigned int kernel_cpu_time) {
    unsigned int num_tasks, i, total_cpu_time;
    Task *tasks = get_tasks(&num_tasks);
    total_cpu_time = 0;
    for (i = 0; i < num_tasks; ++i) {
        total_cpu_time += tasks[i].cpu_time;
    }
    total_cpu_time += kernel_cpu_time;

    log("\nTask runtime info:\n");
    for (i = 0; i < num_tasks; ++i) {
        unsigned int microseconds;
        microseconds = fine_time_to_usec(tasks[i].cpu_time);
        float percent = 100.0f * tasks[i].cpu_time / total_cpu_time;
        log("Task %u ran for %uus or %u percent of the time\n", tasks[i].tid, microseconds, (int) percent);
    }

    // Print Kernel Info.
    unsigned int microseconds;
    microseconds = fine_time_to_usec(kernel_cpu_time);
    float percent = 100.0f * kernel_cpu_time / total_cpu_time;
    log("Kernel ran for %uus or %u percent of the time\n", microseconds, (int) percent);
}
コード例 #7
0
/**
 *
 * Completion function invoked when the call to get
 * the list of tasks returns.
 *
 */
void tasks_completion (int rc,
                       const struct String_vector *strings,
                       const void *data) {
    switch (rc) {
        case ZCONNECTIONLOSS:
        case ZOPERATIONTIMEOUT:
            get_tasks();
            
            break;
            
        case ZOK:
            LOG_DEBUG(("Assigning tasks"));

            struct String_vector *tmp_tasks = added_and_set(strings, &tasks);
            assign_tasks(tmp_tasks);
            free_vector(tmp_tasks);

            break;
        default:
            LOG_ERROR(("Something went wrong when checking tasks: %s", rc2string(rc)));

            break;
    }
}
コード例 #8
0
ファイル: trace_builder.c プロジェクト: tpatki/slurm_test
int main(int argc, char *argv[]){

		int i;
		int written;
		int  userfile;
		int  qosfile;
		int char_pos;
		int endfile = 0;
		char *name;
        int option_index;
        int opt_char;

        while((opt_char = getopt_long(argc, argv, "cjpamt",
                        long_options, &option_index)) != -1) {
            switch (opt_char) {
                case (int)'c':
                    total_cpus = atoi(optarg);

                case (int)'j':
                    total_jobs = atoi(optarg);
                    break;

                case (int)'p':
                    default_partition = strdup(optarg);
                    break;

                case (int)'a':
                    default_account = strdup(optarg);
                    break;

                case (int)'m':
                    cpus_per_task = atoi(optarg);
                    break;

                case (int)'t':
                    tasks_per_node = atoi(optarg);
                    break;

                case (int)'s':
                    submit_time = atoi(optarg);
                    break;

                default:
                    fprintf(stderr, "getopt error, returned %c\n",
                            opt_char);
                    exit(0);
            }
        }

        if(total_cpus == 0){
            printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]);
            return -1;
        }
		if(total_jobs == 0){
            printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]);
            return -1;
        }
		if(default_partition == NULL){
            printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]);
            return -1;
        }
		if(default_account == NULL){
            printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]);
            return -1;
        }

        if(cpus_per_task == 0){
            printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]);
            return -1;
        }

        if(tasks_per_node == 0){
            printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]);
            return -1;
        }

        if(submit_time == 0){
            printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]);
            return -1;
        }

		//PATKI: Replacing 40 with 16
		//if(total_cpus < 40){
		if(total_cpus < 16){
				printf("Setting total_cpus to the minimum value: 16\n");
				total_cpus = 16;
		}

		userfile = open("users.sim", O_RDONLY);

		if(userfile < 0){
			printf("users.sim file not found\n");
			return -1;
		}

		while(1){
		  	char_pos = 0;
			name = malloc(30);
			while(1){
				if(read(userfile, &name[char_pos], 1) <= 0){
					endfile = 1;
					break;
				};
				//printf("Reading char: %c\n", username[char_pos][total_users]);
				if(name[char_pos] == '\n'){
					name[char_pos] = '\0';
					break;
				}
				char_pos++;
			}
			if(endfile)
				break;
			username[total_users] = name;
			printf("Reading user: %s\n", username[total_users]);
			total_users++;
		}

		qosfile = open("qos.sim", O_RDONLY);

		if(qosfile < 0){
			printf("qos.sim file not found\n");
			return -1;
		}

		endfile = 0;
		while(1){
		  	char_pos = 0;
			name = malloc(30);
			while(1){
				if(read(qosfile, &name[char_pos], 1) <= 0){
					endfile = 1;
					break;
				};
				//printf("Reading char: %c\n", username[char_pos][total_users]);
				if(name[char_pos] == '\n'){
					name[char_pos] = '\0';
					break;
				}
				char_pos++;
			}
			if(endfile)
				break;
			qosname[total_qos] = name;
			printf("Reading qos: %s\n", qosname[total_qos]);
			total_qos++;
		}

		if((trace_file = open("test.trace", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0){
				printf("Error opening file test.trace\n");
				return -1;
		}

        submit_time = 1316242565;

		for(i = 0; i < total_jobs; i++){

				int j;

				new_trace.job_id = job_counter++;

				/* Submitting a job every 30s */
				new_trace.submit = submit_time;
				submit_time += 30;

				sprintf(new_trace.username, username[i % total_users]);

				sprintf(new_trace.qosname, qosname[i % total_qos]);

				/*PATKI: WHY CAN I HAVE A JOB WITH 0 TASKS and 0 SEC DURATION?? I AM FIXING THIS*/

				do{
				new_trace.duration = get_duration();
				if(new_trace.duration < 0){
						printf("frand did not work. Exiting...\n");
						return -1;
				}
				}while(new_trace.duration==0); //Patki, add a do-while check


				do{
				new_trace.tasks = get_tasks();
				if(new_trace.tasks < 0){
						printf("frand did not work. Exiting...\n");
						return -1;
				}
				}while(new_trace.tasks == 0);

				new_trace.wclimit = new_trace.duration + (new_trace.duration *0.30);


				if(new_trace.wclimit < 60)
					new_trace.wclimit = 60;

				sprintf(new_trace.account, "%s", default_account);
				sprintf(new_trace.partition, "%s", default_partition);

				new_trace.cpus_per_task = 1;
				new_trace.tasks_per_node = 4;

				written = write(trace_file, &new_trace, sizeof(new_trace));

				printf("JOB(%s): %d, %d, %d\n", new_trace.username, job_counter - 1, new_trace.duration, new_trace.tasks);
				if(written != sizeof(new_trace)){
						printf("Error writing to file: %d of %ld\n", written, sizeof(new_trace));
						return -1;
				}

		}

		return 0;
}
コード例 #9
0
ファイル: tasknc.c プロジェクト: skn/tasknc
int main(int argc, char **argv) /* {{{ */
{
	/* declare variables */
	int c;
	bool debug = false;
	char *debugopts = NULL;

	/* open log */
	logfp = fopen(LOGFILE, "a");
	tnc_fprintf(logfp, LOG_DEBUG, "%s started", PROGNAME);

	/* set defaults */
	cfg.loglvl = LOGLVL_DEFAULT;
	setlocale(LC_ALL, "");

	/* handle arguments */
	static struct option long_options[] =
	{
		{"help",     no_argument,       0, 'h'},
		{"debug",    required_argument, 0, 'd'},
		{"version",  no_argument,       0, 'v'},
		{"loglevel", required_argument, 0, 'l'},
		{"filter",   required_argument, 0, 'f'},
		{0, 0, 0, 0}
	};
	int option_index = 0;
	while ((c = getopt_long(argc, argv, "l:hvd:f:", long_options, &option_index)) != -1)
	{
		switch (c)
		{
			case 'l':
				cfg.loglvl = (char) atoi(optarg);
				printf("loglevel: %d\n", (int)cfg.loglvl);
				break;
			case 'v':
				print_version();
				return 0;
				break;
			case 'd':
				debug = true;
				debugopts = strdup(optarg);
				break;
			case 'f':
				active_filter = strdup(optarg);
				break;
			case 'h':
			case '?':
				help();
				return 0;
				break;
			default:
				return 1;
		}
	}

	/* run ncurses */
	if (!debug)
	{
		tnc_fprintf(logfp, LOG_DEBUG, "running gui");
		ncurses_init();
		mvwprintw(stdscr, 0, 0, "%s %s", PROGNAME, PROGVERSION);
		mvwprintw(stdscr, 1, 0, "configuring...");
		wrefresh(stdscr);
		tnc_fprintf(logfp, LOG_DEBUG_VERBOSE, "configuring...");
		configure();
		tnc_fprintf(logfp, LOG_DEBUG_VERBOSE, "configuration complete");
		mvwprintw(stdscr, 1, 0, "loading tasks...");
		wrefresh(stdscr);
		tnc_fprintf(logfp, LOG_DEBUG_VERBOSE, "loading tasks...");
		head = get_tasks(NULL);
		tnc_fprintf(logfp, LOG_DEBUG_VERBOSE, "%d tasks loaded", taskcount);
		mvwhline(stdscr, 0, 0, ' ', COLS);
		mvwhline(stdscr, 1, 0, ' ', COLS);
		tasklist_window();
		ncurses_end(0);
	}

	/* debug mode */
	else
	{
		configure();
		head = get_tasks(NULL);
		test(debugopts);
		free(debugopts);
	}

	/* done */
	tnc_fprintf(logfp, LOG_DEBUG, "exiting");
	return 0;
} /* }}} */