git-svn-id: svn://db.shs.com.ru/libs@566 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -90,14 +90,59 @@ void QPIIntrospector::buildDumpSection(QTreeWidgetItem * pi, PIString & str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QPIIntrospector::showInfo(const PIIntrospection::ProcessInfo & info) {
|
void QPIIntrospector::showInfo() {
|
||||||
PIString s;
|
PIString s;
|
||||||
s << info.execCommand << "\n";
|
s << info.execCommand << "\n";
|
||||||
s << info.execDateTime.toString() << "\n";
|
s << info.execDateTime.toString() << "\n";
|
||||||
s << info.OS_name << "(" << info.OS_version << ", " << info.architecture << ")\n";
|
s << info.OS_name << "(" << info.OS_version << ", " << info.architecture << ")\n";
|
||||||
s << info.user << "\n";
|
s << info.user << "\n";
|
||||||
s << info.build_options.join(", ");
|
s << info.build_options.join(", ") << "\n";
|
||||||
|
s << "\n";
|
||||||
|
s << "load k: " << PIString::fromNumber(stat.proc.cpu_load_system, 'f', 2) << " %\n";
|
||||||
|
s << "load u: " << PIString::fromNumber(stat.proc.cpu_load_user, 'f', 2) << " %\n";
|
||||||
|
s << "threads: " << stat.proc.threads << "\n";
|
||||||
|
s << "memory usage: " << stat.proc.physical_memsize_readable;
|
||||||
labelInfo->setText(PI2QString(s));
|
labelInfo->setText(PI2QString(s));
|
||||||
|
int tlic = treeStat->topLevelItemCount();
|
||||||
|
for (int i = tlic; i < stat.threads.size_s(); ++i)
|
||||||
|
treeStat->addTopLevelItem(new QTreeWidgetItem());
|
||||||
|
for (int i = tlic - 1; i >= stat.threads.size_s(); --i)
|
||||||
|
delete treeStat->topLevelItem(i);
|
||||||
|
tlic = piMini(treeStat->topLevelItemCount(), stat.threads.size_s());
|
||||||
|
for (int i = 0; i < tlic; ++i) {
|
||||||
|
QTreeWidgetItem * ti = treeStat->topLevelItem(i);
|
||||||
|
PISystemMonitor::ThreadStats & ts(stat.threads[i]);
|
||||||
|
ti->setText(0, QString::number(i + 1));
|
||||||
|
ti->setText(1, QString::number(ts.id));
|
||||||
|
ti->setText(2, PI2QString(ts.name));
|
||||||
|
ti->setText(3, durationStr(ts.work_time));
|
||||||
|
ti->setText(4, QString::number(ts.cpu_load_kernel, 'f', 2));
|
||||||
|
ti->setText(5, QString::number(ts.cpu_load_user, 'f', 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString QPIIntrospector::durationStr(PISystemTime t) {
|
||||||
|
QString ret;
|
||||||
|
double s = t.toSeconds();
|
||||||
|
int d, h, m;
|
||||||
|
d = piFloor(s / (24*60*60));
|
||||||
|
if (d > 0) {
|
||||||
|
ret += QString::number(d) + " d ";
|
||||||
|
s -= d * (24*60*60);
|
||||||
|
}
|
||||||
|
h = piFloor(s / (60*60));
|
||||||
|
if (h > 0) {
|
||||||
|
ret += QString::number(h) + " h ";
|
||||||
|
s -= h * (60*60);
|
||||||
|
}
|
||||||
|
m = piFloor(s / 60);
|
||||||
|
if (m > 0) {
|
||||||
|
ret += QString::number(m).rightJustified(2, '0') + " m ";
|
||||||
|
s -= m * 60;
|
||||||
|
}
|
||||||
|
ret += QString::number(piFloor(s)).rightJustified(2, '0') + " s";
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -124,13 +169,10 @@ void QPIIntrospector::peerReceived(const PIString & from, const PIByteArray & da
|
|||||||
switch (cs.read()) {
|
switch (cs.read()) {
|
||||||
case PIIntrospection::itInfo: {
|
case PIIntrospection::itInfo: {
|
||||||
cs.get(pba);
|
cs.get(pba);
|
||||||
PIIntrospection::ProcessInfo info;
|
|
||||||
PIIntrospection::unpackInfo(pba, info);
|
PIIntrospection::unpackInfo(pba, info);
|
||||||
showInfo(info);
|
|
||||||
} break;
|
} break;
|
||||||
case PIIntrospection::itProcStat: {
|
case PIIntrospection::itProcStat: {
|
||||||
cs.get(pba);
|
cs.get(pba);
|
||||||
PIIntrospection::ProcessStat stat;
|
|
||||||
PIIntrospection::unpackProcStat(pba, stat);
|
PIIntrospection::unpackProcStat(pba, stat);
|
||||||
//showInfo(info);
|
//showInfo(info);
|
||||||
} break;
|
} break;
|
||||||
@@ -156,6 +198,7 @@ void QPIIntrospector::peerReceived(const PIString & from, const PIByteArray & da
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
showInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,13 +24,16 @@ protected:
|
|||||||
void timerEvent(QTimerEvent * );
|
void timerEvent(QTimerEvent * );
|
||||||
|
|
||||||
void buildDumpSection(QTreeWidgetItem * pi, PIString & str);
|
void buildDumpSection(QTreeWidgetItem * pi, PIString & str);
|
||||||
void showInfo(const PIIntrospection::ProcessInfo & info);
|
void showInfo();
|
||||||
EVENT_HANDLER(void, reqProcPIEvents) {QMetaObject::invokeMethod(this, "procPIEvents", Qt::QueuedConnection);}
|
EVENT_HANDLER(void, reqProcPIEvents) {QMetaObject::invokeMethod(this, "procPIEvents", Qt::QueuedConnection);}
|
||||||
|
QString durationStr(PISystemTime t);
|
||||||
|
|
||||||
EVENT_HANDLER2(void, peerReceived, const PIString &, from, const PIByteArray &, data);
|
EVENT_HANDLER2(void, peerReceived, const PIString &, from, const PIByteArray &, data);
|
||||||
EVENT_HANDLER1(void, peersChanged, const PIString &, name);
|
EVENT_HANDLER1(void, peersChanged, const PIString &, name);
|
||||||
|
|
||||||
PIString cur_server;
|
PIString cur_server;
|
||||||
|
PIIntrospection::ProcessInfo info;
|
||||||
|
PIIntrospection::ProcessStat stat;
|
||||||
PIPeer peer;
|
PIPeer peer;
|
||||||
int request_timer;
|
int request_timer;
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidgetMain">
|
<widget class="QTabWidget" name="tabWidgetMain">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>3</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -141,6 +141,47 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Threads:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeWidget" name="treeStat">
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>#</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>id</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>name</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>uptime</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>kernel, %</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string>user, %</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_2">
|
<widget class="QWidget" name="tab_2">
|
||||||
|
|||||||
Reference in New Issue
Block a user