5 static CMD_BIND(neonserv_cmd_netinfo) {
6 reply(getTextBot(), user, "NS_NETINFO_HEADER");
9 table = table_init(2, 5, 0);
12 content[0] = get_language_string(user, "NS_NETINFO_UPTIME");
13 content[1] = timeToStr(user, (time(0) - start_time), 3, tmp);
14 table_add(table, content);
16 content[0] = get_language_string(user, "NS_NETINFO_BOTS");
17 struct ClientSocket *cclient;
18 int bot_count = 0, connected_bot_count = 0;
19 unsigned long traffic_in = 0, traffic_out = 0;
20 for(cclient = getBots(0, NULL); cclient; cclient = getBots(0, cclient)) {
22 if(cclient->flags & SOCKET_FLAG_READY)
23 connected_bot_count++;
24 traffic_in += cclient->traffic_in;
25 traffic_out += cclient->traffic_out;
27 sprintf(tmp, "%d (%d connected)", bot_count, connected_bot_count);
29 table_add(table, content);
31 content[0] = get_language_string(user, "NS_NETINFO_TRAFFIC");
32 sprintf(tmp, "in: %lu kb out: %lu kb", traffic_in / 1024, traffic_out / 1024);
34 table_add(table, content);
36 int channel_count = getChannelCount();
37 float channel_memory = channel_count * sizeof(struct ChanNode);
38 int user_count = getUserCount();
39 float user_memory = user_count * sizeof(struct UserNode);
40 int chanuser_count = getChanUserCount();
41 float chanuser_memory = chanuser_count * sizeof(struct ChanUser);
42 float total_memory = channel_memory + user_memory + chanuser_memory;
44 content[0] = get_language_string(user, "NS_NETINFO_CACHE");
45 sprintf(tmp, "%f kB (%f MB)", total_memory / 1024, total_memory / 1024 / 1024);
47 table_add(table, content);
49 content[0] = get_language_string(user, "NS_NETINFO_CHANNEL");
50 sprintf(tmp, "%d %f kB (%d * %lu B = %f kB)", channel_count, channel_memory / 1024, channel_count, sizeof(struct ChanNode), channel_memory / 1024);
52 table_add(table, content);
54 content[0] = get_language_string(user, "NS_NETINFO_USER");
55 sprintf(tmp, "%d %f kB (%d * %lu B = %f kB)", user_count, user_memory / 1024, user_count, sizeof(struct UserNode), user_memory / 1024);
57 table_add(table, content);
59 content[0] = get_language_string(user, "NS_NETINFO_CHANUSER");
60 sprintf(tmp, "%d %f kB (%d * %lu B = %f kB)", chanuser_count, chanuser_memory / 1024, chanuser_count, sizeof(struct ChanUser), chanuser_memory / 1024);
62 table_add(table, content);
64 char **table_lines = table_end(table);
66 for(i = 0; i < table->entrys; i++) {
67 reply(getTextBot(), user, table_lines[i]);