2019-05-16 18:47:47 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/HashMap.h>
|
2019-11-26 21:25:45 +01:00
|
|
|
#include <AK/String.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
struct CThreadStatistics {
|
|
|
|
int tid;
|
|
|
|
unsigned times_scheduled;
|
|
|
|
unsigned ticks;
|
2019-11-26 21:35:24 +01:00
|
|
|
unsigned syscall_count;
|
|
|
|
unsigned inode_faults;
|
|
|
|
unsigned zero_faults;
|
|
|
|
unsigned cow_faults;
|
2019-12-01 17:36:06 +01:00
|
|
|
unsigned unix_socket_read_bytes;
|
|
|
|
unsigned unix_socket_write_bytes;
|
|
|
|
unsigned ipv4_socket_read_bytes;
|
|
|
|
unsigned ipv4_socket_write_bytes;
|
|
|
|
unsigned file_read_bytes;
|
|
|
|
unsigned file_write_bytes;
|
2019-11-26 21:25:45 +01:00
|
|
|
String state;
|
|
|
|
String priority;
|
2019-12-07 12:50:30 -07:00
|
|
|
String name;
|
2019-11-26 21:25:45 +01:00
|
|
|
};
|
2019-05-16 18:47:47 +02:00
|
|
|
|
|
|
|
struct CProcessStatistics {
|
2019-07-17 22:22:22 +02:00
|
|
|
// Keep this in sync with /proc/all.
|
|
|
|
// From the kernel side:
|
2019-05-16 18:47:47 +02:00
|
|
|
pid_t pid;
|
2019-07-17 22:22:22 +02:00
|
|
|
unsigned pgid;
|
2019-07-17 21:24:47 +02:00
|
|
|
unsigned pgp;
|
2019-07-17 22:22:22 +02:00
|
|
|
unsigned sid;
|
2019-05-16 18:47:47 +02:00
|
|
|
uid_t uid;
|
2019-07-17 22:22:22 +02:00
|
|
|
gid_t gid;
|
|
|
|
pid_t ppid;
|
|
|
|
unsigned nfds;
|
|
|
|
String name;
|
|
|
|
String tty;
|
|
|
|
size_t amount_virtual;
|
|
|
|
size_t amount_resident;
|
|
|
|
size_t amount_shared;
|
2019-12-09 19:16:58 +01:00
|
|
|
size_t amount_purgeable_volatile;
|
|
|
|
size_t amount_purgeable_nonvolatile;
|
2019-07-29 07:26:01 +02:00
|
|
|
int icon_id;
|
2019-07-17 22:22:22 +02:00
|
|
|
|
2019-11-26 21:25:45 +01:00
|
|
|
Vector<CThreadStatistics> threads;
|
|
|
|
|
2019-07-17 22:22:22 +02:00
|
|
|
// synthetic
|
|
|
|
String username;
|
2019-05-16 18:47:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class CProcessStatisticsReader {
|
|
|
|
public:
|
2019-07-10 13:56:28 +02:00
|
|
|
static HashMap<pid_t, CProcessStatistics> get_all();
|
2019-05-16 18:47:47 +02:00
|
|
|
|
|
|
|
private:
|
2019-07-10 13:56:28 +02:00
|
|
|
static String username_from_uid(uid_t);
|
|
|
|
static HashMap<uid_t, String> s_usernames;
|
2019-05-16 18:47:47 +02:00
|
|
|
};
|