#include #include #include #include #include #include #include #include #include #define CPUINFO "/proc/cpuinfo"; #define CPUFREQ "/sys/devices/system/cpu/cpu0/cpufreq/"; #define REPOS "\033[H"; // Re-positions the cursor to top left of screen void move(int row, int col) { printf("\x1b[%d;%df", row, col); } void repos() { printf("\033[H"); } void clear() { printf("\033[2J"); } void die(const char* reason, int ret) { } int printcores() { return 0; } int printmemory() { return 0; } int printcpu() { return 0; } int main(int argc, char** argv) { short memory = 0; short cpu = 0; short cores = 0; int samples = 20; unsigned long tdelay = 500000; if ((atoi(argv[1]) != 0) || (strlen(argv[1]) == 1)) { samples = atoi(argv[1]); } if ((atoi(argv[2]) != 0) || (strlen(argv[2]) == 1)) { tdelay = atoi(argv[2]); } for (int i = 1; i < argc ; i++) { if (strstr(*argv, "--memory")) memory = 1; else if (strstr(*argv, "--cpu")) cpu = 1; else if (strstr(*argv, "--cores")) cores = 1; else if (strstr(argv[i], "--samples=")) samples = atoi(strstr(argv[i], "--samples=")); else if (strstr(argv[i], "--tdelay=")) tdelay = atoi(strstr(argv[i], "--tdelay=")); else { printf("Invalid argument!"); die("Invalid argument!", 1); return 1; } } for (int i = 0; i < samples; i++) { if (memory) { printmemory(); } if (cpu) { printcpu(); } } if (cores) printcores(); return 0; }