int main(object me, string arg) { object obj; if (!arg) { printf( "%s目前共使用 %s bytes 记忆体。\n", MUD_NAME, memory_expression(memory_info()) ); return 1; } if( arg=="-m" ) { malloc_status(); write("\n"); return 1; } seteuid(geteuid(me)); obj = find_object(arg); if (!obj) obj = present(arg, me); if (!obj) obj = present(arg, environment(me)); if (!obj) obj = find_object( resolve_path(me->query("cwd"), arg) ); if (!obj) return notify_fail("没有这样物件....。\n"); printf( "%O 共使用 %s bytes 记忆体。\n", obj, memory_expression(memory_info(obj))); return 1; }
void create() { mapping r; return; memory = memory_info() / 1000; users = sizeof(users()); // rusage() not available everywhere. If you really // really need it, figure it out. #if 0 r = rusage(); #endif cpu = (r["utime"] + r["stime"]) / ( uptime() + 1 ) / 10.0; obs = sizeof(objects()); pastobs = allocate(TRACK_NUM); pastusers = allocate(TRACK_NUM); pastmem = allocate(TRACK_NUM); pastcpu = allocate(TRACK_NUM); pastmem[counter] = memory; pastusers[counter] = users; pastobs[counter] = obs; pastcpu[counter] = cpu; lastmem = 0; lastusers = 0; lastcpu = 0.0; lastobs = 0; counter = 0; times = 0.0; call_out("sample", CALL_TIME); }
int main(object me) { float value; mapping r; if (time() - me->query_temp("scan_time") < 10 && ! wizardp(me)) return notify_fail("等等,系统喘气中……\n"); r = rusage(); value = SCALE * (r["utime"] + r["stime"]) / uptime(); write(NOR + WHT "\n\t\t .__________ 系 统 资 讯 __________.\n"); write(NOR + WHT "\t\t ─────────────────────────\n"); write(NOR + WHT "\t\t 游戏的识别名称: " + MUD_NAME + "\n"); write(NOR + WHT "\t\t 界面系统的版本: " + __VERSION__ + "\n"); write(NOR + WHT "\t\t 系统函数库版本: Nitan Mudlib Version 2.1\n"); printf(NOR + WHT "\t\t CPU 使用百分比: %f %% 被这个游戏使用中\n", value ); write(NOR + WHT "\t\t CPU 的负担状况: " + query_load_average() + "\n"); printf(NOR + WHT "\t\t 共使用的记忆体: %s bytes\n", memory_expression(memory_info()) ); write(NOR + WHT "\t\t 线上使用者总数: " + sizeof( users() ) + " 个人在线上\n"); write(NOR + WHT "\t\t 注册使用者总数: " + count_ppls() + " 个人在本游戏注册\n"); write(NOR + WHT "\t\t 载入的物件总数: " + sizeof( objects() ) + " 个物件\n"); write(NOR + WHT "\t\t 心跳总数的资讯: " + sizeof(heart_beats()) + " 个\n"); write(NOR + WHT "\t\t 延迟呼叫数资讯: " + sizeof(call_out_info()) + " 个\n"); write(NOR + WHT "\t\t 系统负载的资讯: " + query_load_average() + "\n"); write(NOR + WHT "\t\t 讯息传输的资讯: " + query_rusage_message() + "\n"); write(NOR + WHT "\t\t 连续执行的时间: " + dotime() + "\n"); write(NOR + WHT "\t\t 游戏现在的状态: " + STATUS + "\n" NOR); write(NOR + WHT "\t\t 游戏对 PK 限制: 每天不超过 8 人,每人不超过 2 次\n\n" NOR); me->set_temp("scan_time", time()); return 1; }
string do_info(string args) { mapping r; float cpu; string mach, vers, name, up, memory, listing; int obs, i; mixed *info, *services; if(args && args != ""){ args = I3_D->query_network_name(args); if(!args){ return("Could not obtain information about that MUD\n"); } info = I3_D->query_mud(args); services = keys(info[10]); listing = ""; for(i=0;i<sizeof(services);i++) listing += services[i]+", "; listing += "\n"; return ( "" + pad( "MUD NAME: " + args, PAD ) + "MUDLIB: " + info[5] + "\n" + pad( "ADDRESS: " + info[1] + " " + info[2], PAD ) + "DRIVER: " + info[7] + "\n" + pad("MUD TYPE: " + info[8], PAD ) + "CPU USE: " + "Unknown" + " %\n" + pad("CURRENT USERS: " + "Unknown", PAD ) + "MEMORY: " + "Unknown" + "\n" + pad("MUD STATUS: " + info[9], PAD ) + "OBJECTS: " + "Unknown\n" + pad("SERVICES: " + listing, PAD) + "" ); } r = rusage(); obs = sizeof( objects() ); mach = arch(); name = capitalize( mud_name() ); vers = version(); cpu = SCALE * (r["utime"] + r["stime"]) / uptime(); memory = (string) CMD_MEM -> parse_mem( memory_info() ); up = format_time( uptime() ); return ( "" + pad( "MUD NAME: " + name, PAD ) + "MUDLIB: " + MUDLIB_NAME + " (" + MUDLIB_VERSION_NUMBER + ")\n" + pad( "ARCHITECTURE: " + mach, PAD ) + "DRIVER: " + vers + "\n" + pad("DRIVER UPTIME: " + up, PAD ) + "CPU USE: " + cpu + " %\n" + pad("CURRENT USERS: " + sizeof( users() ), PAD ) + "MEMORY: " + memory + "\n" + pad("MUD STATUS: " + STATUS, PAD ) + "OBJECTS: " + obs + " loaded.\n" + "" ); }
void ICACHE_FLASH_ATTR user_event_connect() { #if EVENTS_DEBUG debug("EVENTS: Station connected\n"); memory_info(); #endif char status[WEBSERVER_MAX_RESPONSE_LEN]; user_event_raise( USER_CONFIG_STATION_URL, json_data(status, ESP8266, CONNECTED, (char *)config_wifi_station(), NULL) ); }
SystemInfo model_reader::LoadSystemInfo() { LinuxCPULoadReader cpu_reader; auto cpu_util = cpu_reader.read_util(); struct sysinfo s_info; sysinfo (&s_info); vector<long> cpu_loads(s_info.loads, s_info.loads + 3); MemoryInfo memory_info(s_info.totalram, s_info.freeram); CPUInfo cpu_load(cpu_util); return SystemInfo(cpu_load, memory_info); };
int cbmc_parse_optionst::do_bmc( bmct &bmc, const goto_functionst &goto_functions) { bmc.set_ui(get_ui()); // do actual BMC bool result=(bmc.run(goto_functions)==safety_checkert::SAFE); // let's log some more statistics debug() << "Memory consumption:" << messaget::endl; memory_info(debug()); debug() << eom; // We return '0' if the property holds, // and '10' if it is violated. return result?0:10; }
void sample() { mapping r; memory = lastmem + memory + (lastmem = memory_info() / 1000); users = lastusers + users + (lastusers = sizeof(users())); obs = lastobs + obs + (lastobs = sizeof(objects())); #if 0 r = rusage(); #endif cpu = lastcpu + cpu + (lastcpu = (r["utime"] + r["stime"]) / uptime() / 10.0); times = times + 1.0; pastmem[counter] = memory / times / 2; pastusers[counter] = users / times / 2; pastobs[counter] = obs / times / 2; pastcpu[counter] = cpu / times / 2; if (times == AVERAGING_NUM.0) { times = 0.0; counter = counter + 1; if (counter == TRACK_NUM) counter = 0; memory = lastmem; users = lastusers; cpu = lastcpu; obs = lastobs; pastmem[counter] = memory; pastusers[counter] = users; pastobs[counter] = obs; pastcpu[counter] = cpu; lastmem = 0; lastusers = 0; lastcpu = 0.0; lastobs = 0; } call_out ("sample", CALL_TIME); }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void ICACHE_FLASH_ATTR user_init(void) { system_init_done_cb(user_init_done); // UART Devices mod_rfid_init(); mod_finger_init(); mod_emtr_init(); devices_init(); debug("\n\nSDK version: %s\n", system_get_sdk_version()); debug("Firmware: %s\n", config_firmware_bin()); memory_info(); user_config_init(); user_config_load(); #if SSL_ENABLE user_config_load_private_key(); user_config_load_certificate(); #endif user_events_init(); // Scan webserver_register_handler_callback(DEVICES_URL, devices_handler); webserver_register_handler_callback(WIFI_SCAN_URL, wifi_scan_handler); // Native Devices user_button_init(); user_relay_init(); user_adc_init(); // I2C Devices i2c_master_gpio_init(); mod_rgb_init(); mod_tc_mk2_init(); mod_io2_init(); mod_irda_init(); // SPI Devices mod_led_8x8_rgb_init(); webserver_init(); }
int cmd_mudstatus() { int utime=uptime(), mem=memory_info(), i=0, ct=0; object *o; if(!archp(this_player())) return 0; write("%^BLUE%^+=+=+=+( %^BOLD%^%^WHITE%^Mud Status%^RESET%^%^BLUE%^ )+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=%^RESET%^"); write(" The mud has been online for "+query_time(uptime())+""); write(" The mud will reboot in "+query_time((EVENTS_D->query_next_reboot())-time())+""); write(" Number of Objects Loaded: "+i=sizeof(o=objects())); write(" "+add_commas(mem)+" bytes of memory is loaded."); while(i--) if(query_heart_beat(o[i])) ct++; write(" Number of objects with heartbeats: "+ct+"."); write(" Number of callouts: "+sizeof(call_out_info())+"."); write(" Processing "+query_load_average()+"."); if(find_object("/d/nopk/standard/freezer")) write(" Number of link-dead players: "+ sizeof( all_inventory( find_object( "/d/nopk/standard/freezer" ) ) ) ); write(" Number of players online: "+(string)sizeof(users())); write("%^BLUE%^+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+%^RESET%^\n"); return 1; }
int symex_parseoptionst::doit() { if(cmdline.isset("version")) { std::cout << CBMC_VERSION << std::endl; return 0; } register_language(new_ansi_c_language); register_language(new_cpp_language); // // command line options // optionst options; get_command_line_options(options); eval_verbosity(); goto_functionst goto_functions; if(get_goto_program(options, goto_functions)) return 6; label_properties(goto_functions); if(cmdline.isset("show-properties")) { const namespacet ns(symbol_table); show_properties(ns, get_ui(), goto_functions); return 0; } if(set_properties(goto_functions)) return 7; if(cmdline.isset("show-locs")) { const namespacet ns(symbol_table); locst locs(ns); locs.build(goto_functions); locs.output(std::cout); return 0; } // do actual Symex try { const namespacet ns(symbol_table); path_searcht path_search(ns); path_search.set_message_handler(get_message_handler()); path_search.set_verbosity(get_verbosity()); if(cmdline.isset("depth")) path_search.depth_limit=unsafe_string2unsigned(cmdline.getval("depth")); if(cmdline.isset("context-bound")) path_search.context_bound=unsafe_string2unsigned(cmdline.getval("context-bound")); if(cmdline.isset("unwind")) path_search.unwind_limit=unsafe_string2unsigned(cmdline.getval("unwind")); if(cmdline.isset("show-vcc")) { path_search.show_vcc=true; path_search(goto_functions); return 0; } // do actual symex switch(path_search(goto_functions)) { case safety_checkert::SAFE: report_properties(path_search.property_map); report_success(); return 0; case safety_checkert::UNSAFE: report_properties(path_search.property_map); report_failure(); return 10; default: return 8; } } catch(const std::string error_msg) { error() << error_msg << messaget::eom; return 8; } catch(const char *error_msg) { error() << error_msg << messaget::eom; return 8; } #if 0 // let's log some more statistics debug() << "Memory consumption:" << messaget::endl; memory_info(debug()); debug() << eom; #endif }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void ICACHE_FLASH_ATTR user_init(void) { system_init_done_cb(user_init_done); // wifi_set_phy_mode(PHY_MODE_11N); // wifi_set_sleep_type(MODEM_SLEEP_T); #if UART0_SWAP stdout_disable(); system_uart_swap(); #endif #if UART1_ENABLE stdout_init(UART1); #endif // UART Devices #if DEVICE == PLUG user_plug_init(); #endif #if DEVICE == SWITCH1 user_switch1_init(); #endif #if DEVICE == SWITCH2 user_switch2_init(); #endif #if MOD_RFID_ENABLE mod_rfid_init(); #endif #if MOD_FINGER_ENABLE mod_finger_init(); #endif #if MOD_EMTR_ENABLE mod_emtr_init(); #endif devices_init(); debug("\n\nSDK version: %s\n", system_get_sdk_version()); debug("Firmware: %s\n", config_firmware_bin()); memory_info(); user_config_init(); user_config_load(); #if SSL_ENABLE user_config_load_private_key(); user_config_load_certificate(); #endif user_events_init(); // Scan webserver_register_handler_callback(DEVICES_URL, devices_handler); webserver_register_handler_callback(WIFI_SCAN_URL, wifi_scan_handler); // Native Devices #if BUTTON_ENABLE user_button_init(); #endif #if RELAY_ENABLE user_relay_init(); #endif #if ADC_ENABLE user_adc_init(); #endif #if BATTERY_ENABLE user_battery_init(); #endif #if I2C_ENABLE // I2C Devices i2c_master_gpio_init(); #if MOD_RGB_ENABLE mod_rgb_init(); #endif #if MOD_TC_MK2_ENABLE mod_tc_mk2_init(); #endif #if MOD_IO2_ENABLE mod_io2_init(); #endif #if MOD_IRDA_ENABLE mod_irda_init(); #endif #if DEVICE == DIMMER user_dimmer_init(); #endif #endif // SPI Devices #if MOD_LED_8x8_RGB_ENABLE mod_led_8x8_rgb_init(); #endif #if DEVICE == BADGE badge_init(); #endif key_init(); webserver_init(); }
int symex_parse_optionst::doit() { if(cmdline.isset("version")) { std::cout << CBMC_VERSION << std::endl; return 0; } register_language(new_ansi_c_language); register_language(new_cpp_language); register_language(new_java_bytecode_language); // // command line options // optionst options; get_command_line_options(options); eval_verbosity(); goto_model.set_message_handler(get_message_handler()); if(goto_model(cmdline.args)) return 6; if(process_goto_program(options)) return 6; label_properties(goto_model); if(cmdline.isset("show-properties")) { show_properties(goto_model, get_ui()); return 0; } if(set_properties()) return 7; if(cmdline.isset("show-locs")) { const namespacet ns(goto_model.symbol_table); locst locs(ns); locs.build(goto_model.goto_functions); locs.output(std::cout); return 0; } // do actual Symex try { const namespacet ns(goto_model.symbol_table); path_searcht path_search(ns); path_search.set_message_handler(get_message_handler()); if(cmdline.isset("depth")) path_search.set_depth_limit(unsafe_string2unsigned(cmdline.get_value("depth"))); if(cmdline.isset("context-bound")) path_search.set_context_bound(unsafe_string2unsigned(cmdline.get_value("context-bound"))); if(cmdline.isset("branch-bound")) path_search.set_branch_bound(unsafe_string2unsigned(cmdline.get_value("branch-bound"))); if(cmdline.isset("unwind")) path_search.set_unwind_limit(unsafe_string2unsigned(cmdline.get_value("unwind"))); if(cmdline.isset("dfs")) path_search.set_dfs(); if(cmdline.isset("bfs")) path_search.set_bfs(); if(cmdline.isset("locs")) path_search.set_locs(); if(cmdline.isset("show-vcc")) { path_search.show_vcc=true; path_search(goto_model.goto_functions); return 0; } path_search.eager_infeasibility= cmdline.isset("eager-infeasibility"); if(cmdline.isset("cover")) { // test-suite generation path_search(goto_model.goto_functions); report_cover(path_search.property_map); return 0; } else { // do actual symex, for assertion checking switch(path_search(goto_model.goto_functions)) { case safety_checkert::SAFE: report_properties(path_search.property_map); report_success(); return 0; case safety_checkert::UNSAFE: report_properties(path_search.property_map); report_failure(); return 10; default: return 8; } } } catch(const std::string error_msg) { error() << error_msg << messaget::eom; return 8; } catch(const char *error_msg) { error() << error_msg << messaget::eom; return 8; } #if 0 // let's log some more statistics debug() << "Memory consumption:" << messaget::endl; memory_info(debug()); debug() << eom; #endif }
// This is the add_action hook handling movement, commands, emotes and // channels. Optimization is needed. // private nomask int command_hook(string arg) nomask int command_hook(string arg) { string verb, file; object me=this_object(); #ifdef PROFILE_COMMANDS int mem, utime, stime; mapping info; int ecost; // added by mon. 2/25/98 mem = memory_info(); info = rusage(); utime = info["utime"]; stime = info["stime"]; ecost=eval_cost(); #endif verb = query_verb(); //added by mon 11/23/97 if(userp(me)&& (me->query_temp("d_mana"))>0) { if(me->query_temp("is_living")!=1) { if(verb!="bian" && verb!="say" && verb!="tell" && verb!="reply" && verb!="look") { write("别忘了你现在是一"+ (undefinedp(me->query_temp("unit"))? "个":me->query_temp("unit")) +me->name()+"!\n"); return 1; } } } /* mon 10/10/98 if( !arg && (environment() && stringp(environment()->query("exits/" + verb))) && stringp(file = find_command("go")) && call_other(file, "main", this_object(), verb)) ; */ if( !arg && (environment() && environment()->query("exits/" + verb)) && stringp(file = find_command("go")) && call_other(file, "main", this_object(), verb)) ; else if( stringp(file = find_command(verb)) && call_other(file, "main", this_object(), arg)) ; else if( EMOTE_D->do_emote( this_object(), verb, arg ) ) ; else if( CHANNEL_D->do_channel( this_object(), verb, arg ) ) ; else return 0; #ifdef PROFILE_COMMANDS info = rusage(); PROFILE_D->log_command(verb, memory_info() - mem, info["stime"] - stime, info["utime"] - utime, ecost-eval_cost()); #endif return 1; }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void ICACHE_FLASH_ATTR user_init(void) { system_init_done_cb(user_init_done); // UART Devices #if MOD_RFID_ENABLE mod_rfid_init(); #endif #if MOD_FINGER_ENABLE mod_finger_init(); #endif #if MOD_EMTR_ENABLE mod_emtr_init(); #endif devices_init(); debug("\n\nSDK version: %s\n", system_get_sdk_version()); debug("Firmware: %s\n", config_firmware_bin()); memory_info(); user_config_init(); user_config_load(); #if SSL_ENABLE user_config_load_private_key(); user_config_load_certificate(); #endif user_events_init(); // Scan webserver_register_handler_callback(DEVICES_URL, devices_handler); webserver_register_handler_callback(WIFI_SCAN_URL, wifi_scan_handler); // Native Devices #if BUTTON_ENABLE user_button_init(); #endif #if RELAY_ENABLE user_relay_init(); #endif #if ADC_ENABLE user_adc_init(); #endif #if BATTERY_ENABLE user_battery_init(); #endif // I2C Devices i2c_master_gpio_init(); #if MOD_RGB_ENABLE mod_rgb_init(); #endif #if MOD_TC_MK2_ENABLE mod_tc_mk2_init(); #endif #if MOD_IO2_ENABLE mod_io2_init(); #endif #if MOD_IRDA_ENABLE mod_irda_init(); #endif // SPI Devices #if MOD_LED_8x8_RGB_ENABLE mod_led_8x8_rgb_init(); #endif key_init(); webserver_init(); }
int clobber_parse_optionst::doit() { if(cmdline.isset("version")) { std::cout << CBMC_VERSION << std::endl; return 0; } register_language(new_ansi_c_language); register_language(new_cpp_language); // // command line options // optionst options; get_command_line_options(options); eval_verbosity(); goto_functionst goto_functions; if(get_goto_program(options, goto_functions)) return 6; label_properties(goto_functions); if(cmdline.isset("show-properties")) { const namespacet ns(symbol_table); show_properties(ns, get_ui(), goto_functions); return 0; } if(set_properties(goto_functions)) return 7; // do instrumentation try { const namespacet ns(symbol_table); std::ofstream out("simulator.c"); if(!out) throw std::string("failed to create file simulator.c"); dump_c(goto_functions, true, ns, out); status() << "instrumentation complete; compile and execute simulator.c" << eom; return 0; } catch(const std::string error_msg) { error() << error_msg << messaget::eom; return 8; } catch(const char *error_msg) { error() << error_msg << messaget::eom; return 8; } #if 0 // let's log some more statistics debug() << "Memory consumption:" << messaget::endl; memory_info(debug()); debug() << eom; #endif }