#include "status.hpp" #include #include #include #include #include #include namespace dropshell { void check_status() { // Get current time auto now = std::chrono::system_clock::now(); auto time = std::chrono::system_clock::to_time_t(now); std::cout << "System Status:" << std::endl; std::cout << "Date: " << std::ctime(&time); // Get uptime struct sysinfo si; if (sysinfo(&si) == 0) { int days = si.uptime / 86400; int hours = (si.uptime % 86400) / 3600; int minutes = (si.uptime % 3600) / 60; std::cout << "Uptime: " << days << " days, " << hours << " hours, " << minutes << " minutes" << std::endl; } // Get memory usage std::ifstream meminfo("/proc/meminfo"); if (meminfo.is_open()) { std::string line; long total_mem = 0, free_mem = 0; while (std::getline(meminfo, line)) { if (line.find("MemTotal:") == 0) { total_mem = std::stol(line.substr(9)); } else if (line.find("MemAvailable:") == 0) { free_mem = std::stol(line.substr(13)); } } std::cout << "Memory Usage:" << std::endl; std::cout << "Total: " << total_mem / 1024 << " MB" << std::endl; std::cout << "Available: " << free_mem / 1024 << " MB" << std::endl; } // Get disk usage struct statvfs vfs; if (statvfs("/", &vfs) == 0) { uint64_t total = vfs.f_blocks * vfs.f_frsize; uint64_t free = vfs.f_bfree * vfs.f_frsize; uint64_t used = total - free; std::cout << "Disk Usage:" << std::endl; std::cout << "Total: " << total / (1024*1024*1024) << " GB" << std::endl; std::cout << "Used: " << used / (1024*1024*1024) << " GB" << std::endl; std::cout << "Free: " << free / (1024*1024*1024) << " GB" << std::endl; } } } // namespace dropshell