git-svn-id: svn://db.shs.com.ru/pip@513 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2017-06-21 14:00:45 +00:00
parent 6ac45691cc
commit ed1a89508a
7 changed files with 253 additions and 18 deletions

View File

@@ -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;