diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-01-03 23:09:44 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-01-03 23:09:44 +0100 |
commit | 4e934bee5c0b162d76f1a5883909d162c7faf05e (patch) | |
tree | e6a049c4f092b4ee6a1537735597dbed31b4e2c5 | |
parent | 4b73f78d98d3bbdf3c488759c376c2013bb5683d (diff) |
Reformatted com_uptime()
-rw-r--r-- | FICS/comproc.c | 102 |
1 files changed, 60 insertions, 42 deletions
diff --git a/FICS/comproc.c b/FICS/comproc.c index 526c5a5..c4abad7 100644 --- a/FICS/comproc.c +++ b/FICS/comproc.c @@ -589,49 +589,67 @@ com_password(int p, param_list param) return COM_OK; } -PUBLIC int com_uptime(int p, param_list param) +PUBLIC int +com_uptime(int p, param_list param) { - unsigned long uptime = time(NULL) - startuptime; - struct rusage ru; - int days = (uptime / (60*60*24)); - int hours = ((uptime % (60*60*24)) / (60*60)); - int mins = (((uptime % (60*60*24)) % (60*60)) / 60); - int secs = (((uptime % (60*60*24)) % (60*60)) % 60); - - pprintf(p, "Server location: %s Server version : %s\n", fics_hostname,VERS_NUM); - pprintf(p, "The server has been up since %s.\n", strltime(&startuptime)); - if ((days==0) && (hours==0) && (mins==0)) { - pprintf(p, "(Up for %d second%s)\n", - secs, (secs==1) ? "" : "s"); - } else if ((days==0) && (hours==0)) { - pprintf(p, "(Up for %d minute%s and %d second%s)\n", - mins, (mins==1) ? "" : "s", - secs, (secs==1) ? "" : "s"); - } else if (days==0) { - pprintf(p, "(Up for %d hour%s, %d minute%s and %d second%s)\n", - hours, (hours==1) ? "" : "s", - mins, (mins==1) ? "" : "s", - secs, (secs==1) ? "" : "s"); - } else { - pprintf(p, "(Up for %d day%s, %d hour%s, %d minute%s and %d second%s)\n", - days, (days==1) ? "" : "s", - hours, (hours==1) ? "" : "s", - mins, (mins==1) ? "" : "s", - secs, (secs==1) ? "" : "s"); - } - pprintf(p, "\nAllocs: %u Frees: %u Allocs In Use: %u\n", - malloc_count, free_count, malloc_count - free_count); - if (parray[p].adminLevel >= ADMIN_ADMIN) { - pprintf(p, "\nplayer size:%d, game size:%d, con size:%d, g_num:%d\n", - sizeof(player), sizeof(game), net_consize(), g_num); - getrusage(RUSAGE_SELF, &ru); - pprintf(p, "pagesize = %d, maxrss = %d, total = %d\n", getpagesize(), ru.ru_maxrss, getpagesize() * ru.ru_maxrss); - } - pprintf(p, "\nPlayer limit: %d\n", max_connections-10); - pprintf(p, "\nThere are currently %d players, with a high of %d since last restart.\n", player_count(1), player_high); - pprintf(p, "There are currently %d games, with a high of %d since last restart.\n", game_count(), game_high); - pprintf(p, "\nCompiled on %s\n", COMP_DATE); - return COM_OK; + int days, hours, mins, secs; + struct rusage ru; + unsigned long int uptime = (time(NULL) - startuptime); + + days = (uptime / (60*60*24)); + hours = ((uptime % (60*60*24)) / (60*60)); + mins = (((uptime % (60*60*24)) % (60*60)) / 60); + secs = (((uptime % (60*60*24)) % (60*60)) % 60); + + pprintf(p, "Server location: %s Server version : %s\n", fics_hostname, + VERS_NUM); + pprintf(p, "The server has been up since %s.\n", + strltime(&startuptime)); + + if (days == 0 && hours == 0 && mins == 0) { + pprintf(p, "(Up for %d second%s)\n", + secs, (secs == 1 ? "" : "s")); + } else if (days == 0 && hours == 0) { + pprintf(p, "(Up for %d minute%s and %d second%s)\n", + mins, (mins == 1 ? "" : "s"), + secs, (secs == 1 ? "" : "s")); + } else if (days == 0) { + pprintf(p, "(Up for %d hour%s, %d minute%s and %d second%s)\n", + hours, (hours == 1 ? "" : "s"), + mins, (mins == 1 ? "" : "s"), + secs, (secs == 1 ? "" : "s")); + } else { + pprintf(p, "(Up for %d day%s, %d hour%s, %d minute%s and %d " + "second%s)\n", + days, (days == 1 ? "" : "s"), + hours, (hours == 1 ? "" : "s"), + mins, (mins == 1 ? "" : "s"), + secs, (secs == 1 ? "" : "s")); + } + + pprintf(p, "\nAllocs: %u Frees: %u Allocs In Use: %u\n", + malloc_count, free_count, (malloc_count - free_count)); + if (parray[p].adminLevel >= ADMIN_ADMIN) { + pprintf(p, "\nplayer size:%d, game size:%d, con size:%d, " + "g_num:%d\n", sizeof(player), sizeof(game), net_consize(), + g_num); + + getrusage(RUSAGE_SELF, &ru); + + pprintf(p, "pagesize = %d, maxrss = %d, total = %d\n", + getpagesize(), + ru.ru_maxrss, + (getpagesize() * ru.ru_maxrss)); + } + + pprintf(p, "\nPlayer limit: %d\n", (max_connections - 10)); + pprintf(p, "\nThere are currently %d players, with a high of %d " + "since last restart.\n", player_count(1), player_high); + pprintf(p, "There are currently %d games, with a high of %d " + "since last restart.\n", game_count(), game_high); + pprintf(p, "\nCompiled on %s\n", COMP_DATE); + + return COM_OK; } PUBLIC int |