git-svn-id: svn://db.shs.com.ru/pip@513 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
const char self_name[] = "__self__";
|
||||
extern PIScreen * screen;
|
||||
extern PISystemMonitor sys_mon;
|
||||
//bool Daemon::inited__ = false;
|
||||
|
||||
Daemon::Remote::Remote(const PIString & n): PIThread() {
|
||||
@@ -467,6 +468,13 @@ void Daemon::tileEvent(PIScreenTile * t, TileEvent e) {
|
||||
|
||||
|
||||
void Daemon::keyEvent(PIKbdListener::KeyEvent key) {
|
||||
/*if (key.key == PIKbdListener::F2) {
|
||||
PICout::setBufferActive(true, true);
|
||||
piCout << sys_mon.threadsStatistic();
|
||||
PIFile f("_.txt", PIIODevice::ReadWrite);
|
||||
f.clear();
|
||||
f << PICout::buffer(true);
|
||||
}*/
|
||||
if (!tile_root->visible) return;
|
||||
if (screen->dialogTile()) return;
|
||||
switch (key.key) {
|
||||
|
||||
@@ -101,15 +101,17 @@ public:
|
||||
return ret;
|
||||
}
|
||||
PIScreenTile * infoTile() {
|
||||
TileSimple * ret = new TileSimple();
|
||||
ret->content << TileSimple::Row("Exec command: " + PISystemInfo::instance()->execCommand, CellFormat());
|
||||
ret->content << TileSimple::Row(" Executed on " + PISystemInfo::instance()->execDateTime.toString(), CellFormat());
|
||||
ret->content << TileSimple::Row(" Hostname: " + PISystemInfo::instance()->hostname, CellFormat());
|
||||
ret->content << TileSimple::Row(" Username: " + PISystemInfo::instance()->user, CellFormat());
|
||||
ret->content << TileSimple::Row(" OS name: " + PISystemInfo::instance()->OS_name, CellFormat());
|
||||
ret->content << TileSimple::Row(" OS version: " + PISystemInfo::instance()->OS_version, CellFormat());
|
||||
ret->content << TileSimple::Row("Architecture: " + PISystemInfo::instance()->architecture, CellFormat());
|
||||
ret->content << TileSimple::Row(" CPU count: " + PIString::fromNumber(PISystemInfo::instance()->processorsCount), CellFormat());
|
||||
TileList * ret = new TileList();
|
||||
local_info_base << TileList::Row("Exec command: " + PISystemInfo::instance()->execCommand, CellFormat());
|
||||
local_info_base << TileList::Row(" Executed on " + PISystemInfo::instance()->execDateTime.toString(), CellFormat());
|
||||
local_info_base << TileList::Row(" Hostname: " + PISystemInfo::instance()->hostname, CellFormat());
|
||||
local_info_base << TileList::Row(" Username: " + PISystemInfo::instance()->user, CellFormat());
|
||||
local_info_base << TileList::Row(" OS name: " + PISystemInfo::instance()->OS_name, CellFormat());
|
||||
local_info_base << TileList::Row(" OS version: " + PISystemInfo::instance()->OS_version, CellFormat());
|
||||
local_info_base << TileList::Row("Architecture: " + PISystemInfo::instance()->architecture, CellFormat());
|
||||
local_info_base << TileList::Row(" CPU count: " + PIString::fromNumber(PISystemInfo::instance()->processorsCount), CellFormat());
|
||||
local_info_base << TileList::Row("", CellFormat());
|
||||
local_info_base << TileList::Row("PIThreads:", CellFormat());
|
||||
return ret;
|
||||
}
|
||||
PIScreenTile * peerDiagTile() {
|
||||
@@ -208,9 +210,30 @@ public:
|
||||
daemon_.unlock();
|
||||
screen->unlock();
|
||||
}
|
||||
void tick(void* data_, int delimiter) {
|
||||
void updateSysMon() {
|
||||
TileList * tile = (TileList*)tinfo;
|
||||
PIVector<PISystemMonitor::ThreadStats> ts = sys_mon.threadsStatistic();
|
||||
screen->lock();
|
||||
tile->content = local_info_base;
|
||||
int num = 0, maxlen = 0;
|
||||
piForeachC (PISystemMonitor::ThreadStats & t, ts)
|
||||
maxlen = piMaxi(maxlen, t.name.length());
|
||||
piForeachC (PISystemMonitor::ThreadStats & t, ts) {
|
||||
PIString line = PIString(num++).expandLeftTo(2, ' ') + ": ";
|
||||
line += PIString(t.name).expandRightTo(maxlen, ' ') + ": k ";
|
||||
PIString ns = PIString::fromNumber(t.cpu_load_kernel); ns = ns.left(ns.find('.') + 2);
|
||||
line += ns.expandLeftTo(5, ' ') + " %, u ";
|
||||
ns = PIString::fromNumber(t.cpu_load_user); ns = ns.left(ns.find('.') + 2);
|
||||
line += ns.expandLeftTo(5, ' ') + " %";
|
||||
tile->content << TileList::Row(line, CellFormat());
|
||||
}
|
||||
screen->unlock();
|
||||
}
|
||||
void tick(void* data_, int delimiter) {
|
||||
if (tpeerdiag->visible || tpeer->visible)
|
||||
updatePeerInfo();
|
||||
if (tinfo->visible)
|
||||
updateSysMon();
|
||||
}
|
||||
EVENT_HANDLER(void, menuRequest) {
|
||||
piForeach (PIScreenTile * t, mtiles)
|
||||
@@ -277,6 +300,7 @@ public:
|
||||
TileSimple * peerinfo_tl, * peerinfo_header;
|
||||
TileSimple * peerdiagdata_tl, * peerdiagservice_tl;
|
||||
PIVector<PIScreenTile * > mtiles;
|
||||
PIDeque<TileList::Row> local_info_base;
|
||||
int cur_peer;
|
||||
};
|
||||
|
||||
@@ -372,6 +396,7 @@ int main(int argc, char * argv[]) {
|
||||
screen->waitForFinish();
|
||||
screen->stop(true);
|
||||
}
|
||||
sys_mon.stop();
|
||||
delete menu;
|
||||
delete daemon;
|
||||
delete screen;
|
||||
|
||||
Reference in New Issue
Block a user