eqemu-server/zone/gm_commands/show/show_network_stats.cpp
Alex c84df0d5ba
Some checks are pending
Build / Linux (push) Waiting to run
Build / Windows (push) Waiting to run
Build Improvements (#5033)
* Start rewrite, add vcpkg

* Simple vcpkg manifest, will almost certainly need tweaking

* Remove cmake ext we wont be using anymore

* Update vcpkg to no longer be from 2022, update cmake lists (wip)

* Add finds to the toplevel cmakelists

* WIP, luabind and perlbind build.  Common only partially builds.

* Fix common build.

* shared_memory compiles

* client files compile

* Tests and more cmake version updates

* World, had to swap out zlib-ng for now because it wasn't playing nicely along side the zlib install.  May revisit.

* UCS compiles now too!

* queryserv and eqlaunch

* loginserver works

* Zone works but is messy, tomorrow futher cleanup!

* Cleanup main file

* remove old zlibng, remove perlwrap, remove hc

* More cleanup

* vcpkg baseline set for CI

* Remove pkg-config, it's the suggested way to use luajit with vcpkg but it causes issues with CI and might be a pain point for windows users

* Actually add file

* Set perlbind include dir

* Perl link got lost

* PERL_SET_INTERP causes an issue on newer versions of perl on windows because a symbol is not properly exported in their API, change the lines so it's basically what it used to be

* Remove static unix linking, we dont do automated released anymore and this was tightly coupled to that.  Can explore this again if we decide to change that.

* Remove unused submodules, set cmake policy for boost

* Fix some cereal includes

* Improve some boilerplate, I'd still like to do better about getting linker stuff set.

* Going through and cleaning up the build.

* Fix world, separate out data_buckets.

* add fixes for other servers

* fix zone

* Fix client files, loginserver and tests

* Newer versions of libmariadb default to tls forced on, return to the default of not forcing that.
auto_login were breaking on linux builds
loginserver wasn't setting proper openssl compile flag

* Move set out of a giant cpp file include.

* Convert show

* convert find

* Add uuid to unix builds

* Remove some cpp includes.

* Restructure to remove more things.

* change db update manifest to header
change build yml

* Move world CLI include cpps to cmake.

* Move zone cli out of source and into cmake

* Sidecar stuff wont directly include cpp files now too.

* Fix uuid-dev missing on linux runner

* Reorg common cmake file

* Some cleanup

* Fix libsodium support (oops). Fix perl support (more oops)

* Change doc

---------

Co-authored-by: KimLS <KimLS@peqtgc.com>
2025-12-13 19:56:37 -08:00

298 lines
7.4 KiB
C++

#include "../../client.h"
#include "../../dialogue_window.h"
void ShowNetworkStats(Client *c, const Seperator *sep)
{
const auto connection = c->Connection();
const auto opts = connection->GetManager()->GetOptions();
const auto eqs_stats = connection->GetStats();
const auto& stats = eqs_stats.ReliableStreamStats;
const auto sec_since_stats_reset = std::chrono::duration_cast<std::chrono::duration<double>>(
EQ::Net::Clock::now() - stats.created
).count();
std::string popup_table;
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Sent Bytes") +
DialogueWindow::TableCell(
fmt::format(
"{} ({:.2f} Per Second)",
Strings::Commify(stats.sent_bytes),
stats.sent_bytes / sec_since_stats_reset
)
)
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Received Bytes") +
DialogueWindow::TableCell(
fmt::format(
"{} ({:.2f} Per Second)",
Strings::Commify(stats.recv_bytes),
stats.recv_bytes / sec_since_stats_reset
)
)
);
popup_table += DialogueWindow::Break(2);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Sent Bytes Before Encode") +
DialogueWindow::TableCell(Strings::Commify(stats.bytes_before_encode)) +
DialogueWindow::TableCell("Compression Rate") +
DialogueWindow::TableCell(
fmt::format(
"{:.2f}%%",
static_cast<double>(stats.bytes_before_encode - stats.sent_bytes) /
static_cast<double>(stats.bytes_before_encode) * 100.0
)
)
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Sent Bytes After Encode") +
DialogueWindow::TableCell(Strings::Commify(stats.bytes_after_decode)) +
DialogueWindow::TableCell("Compression Rate") +
DialogueWindow::TableCell(
fmt::format(
"{:.2f}%%",
static_cast<double>(stats.bytes_after_decode - stats.recv_bytes) /
static_cast<double>(stats.bytes_after_decode) * 100.0
)
)
);
popup_table += DialogueWindow::Break(2);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Minimum Ping") +
DialogueWindow::TableCell(Strings::Commify(stats.min_ping))
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Maximum Ping") +
DialogueWindow::TableCell(Strings::Commify(stats.max_ping))
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Last Ping") +
DialogueWindow::TableCell(Strings::Commify(stats.last_ping))
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Average Ping") +
DialogueWindow::TableCell(Strings::Commify(stats.avg_ping))
);
popup_table += DialogueWindow::Break(2);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Real Time Received Packets") +
DialogueWindow::TableCell(
fmt::format(
"{} ({:.2f} Per Second)",
Strings::Commify(stats.recv_packets),
stats.recv_packets / sec_since_stats_reset
)
)
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Real Time Sent Packets") +
DialogueWindow::TableCell(
fmt::format(
"{} ({:.2f} Per Second)",
Strings::Commify(stats.sent_packets),
stats.sent_packets / sec_since_stats_reset
)
)
);
popup_table += DialogueWindow::Break(2);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Sync Received Packets") +
DialogueWindow::TableCell(Strings::Commify(stats.sync_recv_packets))
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Sync Sent Packets") +
DialogueWindow::TableCell(Strings::Commify(stats.sync_sent_packets))
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Sync Remote Received Packets") +
DialogueWindow::TableCell(Strings::Commify(stats.sync_remote_recv_packets))
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Sync Remote Sent Packets") +
DialogueWindow::TableCell(Strings::Commify(stats.sync_remote_sent_packets))
);
popup_table += DialogueWindow::Break(2);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Packet Loss In") +
DialogueWindow::TableCell(
fmt::format(
"{:.2f}%%",
(
100.0 *
(
1.0 -
static_cast<double>(stats.sync_recv_packets) /
static_cast<double>(stats.sync_remote_sent_packets)
)
)
)
)
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Packet Loss Out") +
DialogueWindow::TableCell(
fmt::format(
"{:.2f}%%",
(
100.0 *
(
1.0 -
static_cast<double>(stats.sync_remote_recv_packets) /
static_cast<double>(stats.sync_sent_packets)
)
)
)
)
);
popup_table += DialogueWindow::Break(2);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Resent Packets") +
DialogueWindow::TableCell(
fmt::format(
"{} ({:.2f} Per Second)",
Strings::Commify(stats.resent_packets),
stats.resent_packets / sec_since_stats_reset
)
)
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Resent Fragments") +
DialogueWindow::TableCell(
fmt::format(
"{} ({:.2f} Per Second)",
Strings::Commify(stats.resent_fragments),
stats.resent_fragments / sec_since_stats_reset
)
)
);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Resent Non-Fragments") +
DialogueWindow::TableCell(
fmt::format(
"{} ({:.2f} Per Second)",
Strings::Commify(stats.resent_full),
stats.resent_full / sec_since_stats_reset
)
)
);
popup_table += DialogueWindow::Break(2);
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Dropped Datarate Packets") +
DialogueWindow::TableCell(
fmt::format(
"{} ({:.2f} Per Second)",
Strings::Commify(stats.dropped_datarate_packets),
stats.dropped_datarate_packets / sec_since_stats_reset
)
)
);
if (opts.reliable_stream_options.outgoing_data_rate > 0.0) {
popup_table += DialogueWindow::TableRow(
DialogueWindow::TableCell("Outgoing Link Saturation") +
DialogueWindow::TableCell(
fmt::format(
"{:.2f}%% ({:.2f}kb Per Second)",
(
100.0 *
(
1.0 -
(
(
opts.reliable_stream_options.outgoing_data_rate -
stats.datarate_remaining
) /
opts.reliable_stream_options.outgoing_data_rate
)
)
),
opts.reliable_stream_options.outgoing_data_rate
)
)
);
}
popup_table += DialogueWindow::Break(2);
std::string sent_rows;
for (int i = 0; i < _maxEmuOpcode; ++i) {
const int count = eqs_stats.SentCount[i];
if (count) {
sent_rows += DialogueWindow::TableRow(
DialogueWindow::TableCell(OpcodeNames[i]) +
DialogueWindow::TableCell(
fmt::format(
"{} ({:.2f} Per Second)",
Strings::Commify(count),
count / sec_since_stats_reset
)
)
);
}
}
std::string recv_rows;
for (int i = 0; i < _maxEmuOpcode; ++i) {
const int count = eqs_stats.RecvCount[i];
if (count) {
recv_rows += DialogueWindow::TableRow(
DialogueWindow::TableCell(OpcodeNames[i]) +
DialogueWindow::TableCell(
fmt::format(
"{} ({:.2f} Per Second)",
Strings::Commify(count),
count / sec_since_stats_reset
)
)
);
}
}
popup_table += DialogueWindow::TableRow(DialogueWindow::TableCell("Sent Packet Types"));
popup_table += sent_rows;
popup_table += DialogueWindow::TableRow(DialogueWindow::TableCell("Received Packet Types"));
popup_table += recv_rows;
popup_table = DialogueWindow::Table(popup_table);
c->SendPopupToClient(
"Network Statistics",
popup_table.c_str()
);
}