What Was Built
NetMon is a lightweight C++ console system monitor that polls system CPU load and memory stats at short intervals, rendering ASCII header graphics and formatted resource bars directly inside the terminal.
A fast C++ terminal monitor displaying real-time CPU and RAM usage with crisp ASCII art and dynamic [|||||| ] loading bars.
NetMon is a lightweight C++ console system monitor that polls system CPU load and memory stats at short intervals, rendering ASCII header graphics and formatted resource bars directly inside the terminal.
A dark developer terminal topped with a green NetMon ASCII banner followed by color-coded CPU, RAM, and swap loading bars ([|||||| ]) updating smoothly without screen flicker.
g++ -O2 -std=c++17 netmon.cpp -o netmon && ./netmon
Sample for learning, not my actual file
// Sample for learning, not my actual file.
#include <chrono>
#include <fstream>
#include <iostream>
#include <string>
#include <thread>
static std::string make_bar(int pct) {
int filled = (pct * 16) / 100;
return "[" + std::string(filled, '|') + std::string(16 - filled, ' ') + "]";
}
static int read_ram_pct() {
std::ifstream f("/proc/meminfo");
std::string key;
long val = 0, total = 0, avail = 0;
while (f >> key >> val) {
std::string unit; std::getline(f, unit);
if (key == "MemTotal:") total = val;
else if (key == "MemAvailable:") avail = val;
if (total && avail) break;
}
return total > 0 ? static_cast<int>(((total - avail) * 100) / total) : 0;
}
static void read_cpu(long &idle, long &total) {
std::ifstream f("/proc/stat");
std::string tag; long a=0, b=0, c=0, d=0, e=0, g=0, h=0;
f >> tag >> a >> b >> c >> d >> e >> g >> h;
idle = d + e; total = a + b + c + d + e + g + h;
}
int main() {
long i1 = 0, t1 = 0, i2 = 0, t2 = 0;
read_cpu(i1, t1);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
read_cpu(i2, t2);
long dt = t2 - t1, di = i2 - i1;
int cpu = dt > 0 ? static_cast<int>(100 * (dt - di) / dt) : 0;
int ram = read_ram_pct();
std::cout << "NetMon (Sample)\n";
std::cout << "CPU " << make_bar(cpu) << " " << cpu << "%\n";
std::cout << "RAM " << make_bar(ram) << " " << ram << "%\n";
return 0;
}_ _ _ __ __ | \ | | ___| |_| \/ | ___ _ __ CPU [|||||||||| ] 62% RAM [|||||||| ] 51% Refresh interval: 1000ms