You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
883 B
C
55 lines
883 B
C
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
#include <sys/socket.h>
|
|
#include <unistd.h>
|
|
#include <arpa/inet.h>
|
|
#include <netdb.h>
|
|
#include <string.h>
|
|
|
|
#define JIM_IMPLEMENTATION
|
|
#include "jim.h"
|
|
|
|
#define JIMP_IMPLEMENTATION
|
|
#include "jimp.h"
|
|
|
|
#define SYSINFO_IMPLEMENTATION
|
|
#include "sysinfo.h"
|
|
|
|
#define PORT 7778
|
|
|
|
#define MAX_MESSAGE_SIZE 1024
|
|
|
|
enum Type {
|
|
REQUEST = 1,
|
|
RESPONSE = 2,
|
|
};
|
|
|
|
enum Request_Type {
|
|
NEW_SERVER_CLIENT = 1,
|
|
NEW_DESKTOP_CLIENT = 2,
|
|
DATA = 3,
|
|
};
|
|
|
|
enum Response_Type {
|
|
OK = 1,
|
|
CREATED = 2,
|
|
ERROR = 3,
|
|
};
|
|
|
|
typedef struct {
|
|
long timestamp;
|
|
double cpu_usage_percentage;
|
|
double memory_used_gb;
|
|
double memory_total_gb;
|
|
double swap_used_gb;
|
|
double swap_total_gb;
|
|
} Monitoring_Data;
|
|
|
|
typedef struct {
|
|
enum Type type;
|
|
enum Request_Type request;
|
|
enum Response_Type response;
|
|
char *hostname;
|
|
Monitoring_Data monitoring_data;
|
|
} Data;
|