6 static CMD_BIND(neonserv_cmd_netinfo) {
7 reply(getTextBot(), user, "NS_NETINFO_HEADER");
10 table = table_init(2, 7, 0);
13 content[0] = get_language_string(user, "NS_NETINFO_UPTIME");
14 content[1] = timeToStr(user, (time(0) - start_time), 3, tmp);
15 table_add(table, content);
17 content[0] = get_language_string(user, "NS_NETINFO_BOTS");
18 struct ClientSocket *cclient;
19 int bot_count = 0, connected_bot_count = 0;
20 float traffic_in = 0, traffic_out = 0;
21 for(cclient = getBots(0, NULL); cclient; cclient = getBots(0, cclient)) {
23 if(cclient->flags & SOCKET_FLAG_READY)
24 connected_bot_count++;
25 traffic_in += cclient->traffic_in;
26 traffic_out += cclient->traffic_out;
28 sprintf(tmp, "%d (%d connected)", bot_count, connected_bot_count);
30 table_add(table, content);
32 content[0] = get_language_string(user, "NS_NETINFO_TRAFFIC");
33 sprintf(tmp, "in: %.2f kb out: %.2f kb", traffic_in / 1024, traffic_out / 1024);
35 table_add(table, content);
37 int channel_count = getChannelCount();
38 float channel_memory = channel_count * sizeof(struct ChanNode);
39 int user_count = getUserCount();
40 float user_memory = user_count * sizeof(struct UserNode);
41 int chanuser_count = getChanUserCount();
42 float chanuser_memory = chanuser_count * sizeof(struct ChanUser);
43 float total_memory = channel_memory + user_memory + chanuser_memory;
45 content[0] = get_language_string(user, "NS_NETINFO_CACHE");
46 sprintf(tmp, "%.2f kB (%.2f MB)", total_memory / 1024, total_memory / 1024 / 1024);
48 table_add(table, content);
50 content[0] = get_language_string(user, "NS_NETINFO_CHANNEL");
51 sprintf(tmp, "%d %.2f kB (%d * %lu B = %.2f kB)", channel_count, channel_memory / 1024, channel_count, sizeof(struct ChanNode), channel_memory / 1024);
53 table_add(table, content);
55 content[0] = get_language_string(user, "NS_NETINFO_USER");
56 sprintf(tmp, "%d %.2f kB (%d * %lu B = %.2f kB)", user_count, user_memory / 1024, user_count, sizeof(struct UserNode), user_memory / 1024);
58 table_add(table, content);
60 content[0] = get_language_string(user, "NS_NETINFO_CHANUSER");
61 sprintf(tmp, "%d %.2f kB (%d * %lu B = %.2f kB)", chanuser_count, chanuser_memory / 1024, chanuser_count, sizeof(struct ChanUser), chanuser_memory / 1024);
63 table_add(table, content);
65 char **table_lines = table_end(table);
67 for(i = 0; i < table->entrys; i++) {
68 reply(getTextBot(), user, table_lines[i]);