void update_infos(t_arena *a) { t_player *player; t_process *p; int line; int i; mvwprintw(a->display->w_info, 0, 24, "%-5d (%d processus)", a->cycle, count_processes(a)); mvwprintw(a->display->w_info, 3, 20, "%4d", a->display->cps); line = 6; player = a->players; while (player != NULL) { i = 0; p = a->processes; while (p != NULL) { if (p->player == player->id) i++; p = p->next; } mvwprintw(a->display->w_info, line, 20, "%6d", i); mvwprintw(a->display->w_info, line + 1, 20, "%6d", player->last_live); line += 4; player = player->next; } }
void checknas(void) // for broadcom v24 only { #if !defined(HAVE_MADWIFI) && !defined(HAVE_RT2880) char buf[32]; FILE *fnas = fopen("/tmp/.nas", "r"); if (fnas == NULL) return; fgets(buf, sizeof(buf), fnas); fclose(fnas); if (strlen(buf) != count_processes("nas")) // restart all nas // processes { sysprintf("stopservice nas"); sysprintf("startservice_f nas"); } return; #endif #ifdef HAVE_MADWIFI sysprintf("startservice_f checkhostapd"); #endif }
int search_process(char *name, int count) { int c = 0; c = count_processes(name); if (!c) { printf("Can't find %s\n", name); return 0; } else { printf("Find %s which count is %d\n", name, c); // if(count && c != count){ // cprintf("%s count is not match\n", name); // return 0; // } // else return 1; } }
void init_info_display(t_arena *arena) { int line; t_player *player; arena->display->w_info = newwin(30, 50, 10, 64 * 3 + 15); wtimeout(arena->display->w_info, 0); wprintw(arena->display->w_info, "Dumping memory at cycle %-5d (%d processus)" "\n\n\nCycles per second : %4d", 0, count_processes(arena), 0); player = arena->players; line = 5; while (player != NULL) { mvwprintw(arena->display->w_info, line, 0, "Player \n\tProcessus : %6d\n\tLast live: %6d", 1, 0); wattron(arena->display->w_info, COLOR_PAIR(player->id)); mvwprintw(arena->display->w_info, line, 8, player->name); wattroff(arena->display->w_info, COLOR_PAIR(player->id)); line += 4; player = player->next; } }
u_char * var_hrsys(struct variable * vp, oid * name, size_t * length, int exact, size_t * var_len, WriteMethod ** write_method) { static char string[1024]; #if defined(solaris2) /* max size of nvram property */ char bootparam[8192]; #endif time_t now; #ifndef NR_TASKS int nproc = 0; #endif #ifdef linux FILE *fp; #endif #if CAN_USE_SYSCTL && defined(CTL_KERN) && defined(KERN_MAXPROC) static int maxproc_mib[] = { CTL_KERN, KERN_MAXPROC }; int buf_size; #endif #if defined(hpux10) || defined(hpux11) struct pst_static pst_buf; #endif if (header_hrsys(vp, name, length, exact, var_len, write_method) == MATCH_FAILED) return NULL; switch (vp->magic) { case HRSYS_UPTIME: long_return = get_uptime(); return (u_char *) & long_return; case HRSYS_DATE: #if defined(HAVE_MKTIME) && defined(HAVE_STIME) *write_method=ns_set_time; #endif (void *) time(&now); return (u_char *) date_n_time(&now, var_len); case HRSYS_LOAD_DEV: long_return = get_load_dev(); return (u_char *) & long_return; case HRSYS_LOAD_PARAM: #ifdef linux if((fp = fopen("/proc/cmdline", "r")) != NULL) { fgets(string, sizeof(string), fp); fclose(fp); } else { return NULL; } #elif defined(solaris2) *write_method=set_solaris_bootcommand_parameter; if ( get_solaris_eeprom_parameter("boot-command",bootparam) ) { snmp_log(LOG_ERR,"unable to lookup boot-command from eeprom\n"); return NULL; } strlcpy(string,bootparam,sizeof(string)); #else #if NO_DUMMY_VALUES return NULL; #endif sprintf(string, "ask Dave"); /* XXX */ #endif *var_len = strlen(string); return (u_char *) string; case HRSYS_USERS: long_return = count_users(); return (u_char *) & long_return; case HRSYS_PROCS: #if USING_HOST_HR_SWRUN_MODULE long_return = count_processes(); #else #if NO_DUMMY_VALUES return NULL; #endif long_return = 0; #endif return (u_char *) & long_return; case HRSYS_MAXPROCS: #if defined(NR_TASKS) long_return = NR_TASKS; /* <linux/tasks.h> */ #elif CAN_USE_SYSCTL && defined(CTL_KERN) && defined(KERN_MAXPROC) buf_size = sizeof(nproc); if (sysctl(maxproc_mib, 2, &nproc, &buf_size, NULL, 0) < 0) return NULL; long_return = nproc; #elif defined(hpux10) || defined(hpux11) pstat_getstatic(&pst_buf, sizeof(struct pst_static), 1, 0); long_return = pst_buf.max_proc; #elif defined(solaris2) long_return=get_max_solaris_processes(); if(long_return == -1) return NULL; #elif defined(NPROC_SYMBOL) auto_nlist(NPROC_SYMBOL, (char *) &nproc, sizeof(int)); long_return = nproc; #else #if NO_DUMMY_VALUES return NULL; #endif long_return = 0; #endif return (u_char *) & long_return; default: DEBUGMSGTL(("snmpd", "unknown sub-id %d in var_hrsys\n", vp->magic)); } return NULL; } /* end var_hrsys */