git-svn-id: svn://db.shs.com.ru/pip@4 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
93
utils/system_daemon/daemon.h
Normal file
93
utils/system_daemon/daemon.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef DAEMON_H
|
||||
#define DAEMON_H
|
||||
|
||||
#include "piconsole.h"
|
||||
#include "pipeer.h"
|
||||
|
||||
extern PIConsole console;
|
||||
extern PISystemMonitor sys_mon;
|
||||
|
||||
class Daemon: public PIPeer {
|
||||
PIOBJECT(Daemon)
|
||||
public:
|
||||
Daemon();
|
||||
|
||||
struct HostInfo {
|
||||
PIString execCommand;
|
||||
PIString hostname;
|
||||
PIString user;
|
||||
PIString OS_name;
|
||||
PIString OS_version;
|
||||
PIString architecture;
|
||||
PIDateTime execDateTime;
|
||||
int processorsCount;
|
||||
|
||||
int ID;
|
||||
int threads;
|
||||
int priority;
|
||||
ulong physical_memsize;
|
||||
ulong share_memsize;
|
||||
float cpu_load_system;
|
||||
float cpu_load_user;
|
||||
};
|
||||
|
||||
void enable() {enabled = true;}
|
||||
void disable() {enabled = false;}
|
||||
|
||||
PIStringList availableDaemons() const;
|
||||
void connectToDaemon(const PIString & dn);
|
||||
void disconnect();
|
||||
|
||||
PIString connectedDaemon() const;
|
||||
|
||||
private:
|
||||
enum PacketType {
|
||||
RequestHostInfo = 10,
|
||||
|
||||
ReplyHostInfo = 20
|
||||
|
||||
};
|
||||
|
||||
EVENT_HANDLER1(void, keyEvent, char, key);
|
||||
EVENT_HANDLER2(void, timerEvent, void * , _d, int, delim);
|
||||
EVENT(menuRequest);
|
||||
void peerDisconnected(const PIString & name);
|
||||
void dataReceived(const PIString & from, const PIByteArray & data);
|
||||
void makeMyHostInfo();
|
||||
void makeOtherHostInfo();
|
||||
void updateConsole();
|
||||
void tabConnectedHeader(int cols = 1);
|
||||
void tabConnect();
|
||||
void tabFeature();
|
||||
void tabInfo();
|
||||
|
||||
mutable PIStringList available_daemons;
|
||||
PITimer timer;
|
||||
PIString conn_name;
|
||||
PIMap<int, PIString> dnames;
|
||||
PISystemMonitor sys_mon_other;
|
||||
HostInfo info_my, info_other;
|
||||
bool enabled;
|
||||
int mode, offset, cur, height;
|
||||
|
||||
|
||||
};
|
||||
|
||||
inline PIByteArray & operator <<(PIByteArray & b, const Daemon::HostInfo & v) {
|
||||
b << v.execCommand << v.hostname << v.user << v.OS_name
|
||||
<< v.OS_version << v.architecture << v.execDateTime
|
||||
<< v.processorsCount << v.ID << v.threads << v.priority
|
||||
<< v.physical_memsize << v.share_memsize
|
||||
<< v.cpu_load_system << v.cpu_load_user;
|
||||
return b;
|
||||
}
|
||||
inline PIByteArray & operator >>(PIByteArray & b, Daemon::HostInfo & v) {
|
||||
b >> v.execCommand >> v.hostname >> v.user >> v.OS_name
|
||||
>> v.OS_version >> v.architecture >> v.execDateTime
|
||||
>> v.processorsCount >> v.ID >> v.threads >> v.priority
|
||||
>> v.physical_memsize >> v.share_memsize
|
||||
>> v.cpu_load_system >> v.cpu_load_user;
|
||||
return b;
|
||||
}
|
||||
|
||||
#endif // DAEMON_H
|
||||
Reference in New Issue
Block a user