/* Server-related stuff for sysmon */ #ifndef SERVER_H #define SERVER_H #include #ifndef ETREE_H # include "etree.h" #endif /*************************************************************************/ /* Information about a server. */ #define MAX_DISKS 8 /* Number of filesystems to remember */ typedef struct { struct timeval last_update; char name[256]; int bsize, blocks, bused, bresv, inodes, iused, iresv; } DiskInfo; typedef struct server_struct Server; struct server_struct { Server *next, *prev; char *name; /* Hostname of the server */ int port; /* Port to connect to */ char *password; /* Password for the connection */ char *alias; /* Alias for the server */ int sock; /* Socket descriptor (-1 if not connected) */ int valid; /* Connection is valid (i.e. auth succeeded) */ /* Information on current read */ int response_len; /* -1 if no current read */ char *response_buf; /* Uptime data */ struct timeval last_uptime_update; int uptime, nusers, load1, load5, load15, nprocs; /* Memory data */ struct timeval last_memory_update; int memtotal, memfree, shared, buffers, cached, swaptotal, swapfree; /* Filesystem data (for most recently queried MAX_DISKS filesystems) */ DiskInfo disks[MAX_DISKS]; }; /*************************************************************************/ /* Create a new server record. */ extern Server *server_new(void); /* Return a pointer to the Server structure corresponding to the given name * or alias, or NULL if no such server exists. */ extern Server *server_find(const char *name); /* Attempt to connect to the server. */ extern void server_conn(Server *s); /* Retrieve information about the given server. Tries to connect to the * server if not already connected. Returns 0 if the information could not * be retrieved, else 1. The information is stored in the server record. */ extern int server_query(Server *s, int query, int nargs, ETree **args); /*************************************************************************/ #endif /* SERVER_H */