Files
FERRUM/system_monitor.h
marcusDenslow c53e22efef implemented system monitor
simple system monitor to view cpu usage, ram and so on. this is not a
finished implementation but i just made refreshing work fine. used
alternative screen buffer, and buffered output which build the entire
display in memory and then outputs once.

there are still many bugs, like the list isnt displaying processes
sorted, or maybe not working at all. some of the border characters are
misaligned, and there is alot more usefull info that could be added.

if there is anything in specific that you would want to see in this
command, or in the program in general, just hit me up on github and
request it, and ill add it as fast as i can.

--marcus
2025-05-31 15:02:18 +02:00

50 lines
1.2 KiB
C

#ifndef SYSTEM_MONITOR_H
#define SYSTEM_MONITOR_H
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/statvfs.h>
#include <sys/sysinfo.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <ctype.h>
typedef struct {
float cpu_percent;
unsigned long memory_used;
unsigned long memory_total;
unsigned long disk_read;
unsigned long disk_write;
unsigned long net_rx;
unsigned long net_tx;
int process_count;
} SystemStats;
typedef struct {
int pid;
char name[256];
float cpu_percent;
unsigned long memory;
char state;
} ProcessInfo;
int builtin_monitor(char **args);
void display_dashboard(SystemStats *stats, ProcessInfo *processes,
int proc_count);
void get_system_stats(SystemStats *stats);
int get_process_info(ProcessInfo *processes, int max_processes);
void clear_screen(void);
void move_cursor(int row, int col);
void hide_cursor(void);
void show_cursor(void);
int kbhit(void);
void draw_progress_bar(int percentage, int width);
void format_progress_bar(int percentage, int width, char *buffer);
void format_bytes(unsigned long bytes, char *buffer);
#endif