git-svn-id: svn://db.shs.com.ru/pip@519 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -63,7 +63,6 @@
|
|||||||
# include <termios.h>
|
# include <termios.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# include <sys/ioctl.h>
|
# include <sys/ioctl.h>
|
||||||
# include <linux/serial.h>
|
|
||||||
# ifndef B50
|
# ifndef B50
|
||||||
# define B50 0000001
|
# define B50 0000001
|
||||||
# endif
|
# endif
|
||||||
@@ -113,6 +112,9 @@
|
|||||||
#ifndef CRTSCTS
|
#ifndef CRTSCTS
|
||||||
# define CRTSCTS 020000000000
|
# define CRTSCTS 020000000000
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(LINUX)
|
||||||
|
# include <linux/serial.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*! \class PISerial
|
/*! \class PISerial
|
||||||
@@ -828,7 +830,7 @@ void PISerial::optionsChanged() {
|
|||||||
|
|
||||||
void PISerial::threadedReadBufferSizeChanged() {
|
void PISerial::threadedReadBufferSizeChanged() {
|
||||||
if (!isOpened()) return;
|
if (!isOpened()) return;
|
||||||
#ifndef WINDOWS
|
#if defined(LINUX)
|
||||||
serial_struct ss;
|
serial_struct ss;
|
||||||
ioctl(fd, TIOCGSERIAL, &ss);
|
ioctl(fd, TIOCGSERIAL, &ss);
|
||||||
//piCoutObj << "b" << ss.xmit_fifo_size;
|
//piCoutObj << "b" << ss.xmit_fifo_size;
|
||||||
|
|||||||
@@ -27,11 +27,20 @@
|
|||||||
# include <psapi.h>
|
# include <psapi.h>
|
||||||
# include <tlhelp32.h>
|
# include <tlhelp32.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef MAC_OS
|
||||||
|
# include <sys/proc_info.h>
|
||||||
|
# include <libproc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
PRIVATE_DEFINITION_START(PISystemMonitor)
|
PRIVATE_DEFINITION_START(PISystemMonitor)
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
llong cpu_u_cur, cpu_u_prev, cpu_s_cur, cpu_s_prev;
|
# ifdef MAC_OS
|
||||||
|
PISystemTime
|
||||||
|
# else
|
||||||
|
llong
|
||||||
|
# endif
|
||||||
|
cpu_u_cur, cpu_u_prev, cpu_s_cur, cpu_s_prev;
|
||||||
PIString proc_dir;
|
PIString proc_dir;
|
||||||
PIFile file, filem;
|
PIFile file, filem;
|
||||||
#else
|
#else
|
||||||
@@ -77,7 +86,9 @@ bool PISystemMonitor::startOnProcess(int pID, int interval_ms) {
|
|||||||
stop();
|
stop();
|
||||||
self_ = false;
|
self_ = false;
|
||||||
pID_ = pID;
|
pID_ = pID;
|
||||||
|
cycle = -1;
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
|
# ifndef MAC_OS
|
||||||
PRIVATE->proc_dir = PIStringAscii("/proc/") + PIString::fromNumber(pID_) + PIStringAscii("/");
|
PRIVATE->proc_dir = PIStringAscii("/proc/") + PIString::fromNumber(pID_) + PIStringAscii("/");
|
||||||
PRIVATE->file. open(PRIVATE->proc_dir + "stat", PIIODevice::ReadOnly);
|
PRIVATE->file. open(PRIVATE->proc_dir + "stat", PIIODevice::ReadOnly);
|
||||||
PRIVATE->filem.open(PRIVATE->proc_dir + "statm", PIIODevice::ReadOnly);
|
PRIVATE->filem.open(PRIVATE->proc_dir + "statm", PIIODevice::ReadOnly);
|
||||||
@@ -85,7 +96,7 @@ bool PISystemMonitor::startOnProcess(int pID, int interval_ms) {
|
|||||||
piCoutObj << "Can`t find process with ID = " << pID_ << "!";
|
piCoutObj << "Can`t find process with ID = " << pID_ << "!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cycle = -1;
|
# endif
|
||||||
#else
|
#else
|
||||||
PRIVATE->hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pID_);
|
PRIVATE->hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pID_);
|
||||||
if (PRIVATE->hProc == 0) {
|
if (PRIVATE->hProc == 0) {
|
||||||
@@ -125,6 +136,12 @@ void PISystemMonitor::stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef MAC_OS
|
||||||
|
PISystemTime uint64toST(uint64_t v) {
|
||||||
|
return PISystemTime(((uint*)&(v))[1], ((uint*)&(v))[0]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void PISystemMonitor::run() {
|
void PISystemMonitor::run() {
|
||||||
cur_tm.clear();
|
cur_tm.clear();
|
||||||
tbid.clear();
|
tbid.clear();
|
||||||
@@ -136,7 +153,29 @@ void PISystemMonitor::run() {
|
|||||||
tbid[t->tid()] = t->name();
|
tbid[t->tid()] = t->name();
|
||||||
pitc->unlock();
|
pitc->unlock();
|
||||||
//piCout << tbid.keys().toType<uint>();
|
//piCout << tbid.keys().toType<uint>();
|
||||||
|
stat.ID = pID_;
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
|
# ifdef MAC_OS
|
||||||
|
rusage_info_current ru;
|
||||||
|
proc_pid_rusage(pID_, RUSAGE_INFO_CURRENT, (rusage_info_t*)&ru);
|
||||||
|
//piCout << PISystemTime(((uint*)&(ru.ri_user_time))[1], ((uint*)&(ru.ri_user_time))[0]);
|
||||||
|
if (cycle < 0) {
|
||||||
|
PRIVATE->cpu_u_prev = PRIVATE->cpu_u_cur = uint64toST(ru.ri_user_time);
|
||||||
|
PRIVATE->cpu_s_prev = PRIVATE->cpu_s_cur = uint64toST(ru.ri_system_time);
|
||||||
|
}
|
||||||
|
cycle++;
|
||||||
|
//if (cycle >= 4) {
|
||||||
|
PRIVATE->cpu_u_prev = PRIVATE->cpu_u_cur;
|
||||||
|
PRIVATE->cpu_s_prev = PRIVATE->cpu_s_cur;
|
||||||
|
PRIVATE->cpu_u_cur = uint64toST(ru.ri_user_time);
|
||||||
|
PRIVATE->cpu_s_cur = uint64toST(ru.ri_system_time);
|
||||||
|
stat.cpu_load_system = 100.f * (PRIVATE->cpu_s_cur - PRIVATE->cpu_s_prev).toMilliseconds() / delay_;
|
||||||
|
stat.cpu_load_user = 100.f * (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_;
|
||||||
|
//stat.cpu_load_system /= cpu_count;
|
||||||
|
//stat.cpu_load_user /= cpu_count;
|
||||||
|
cycle = 0;
|
||||||
|
//piCout << (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_;
|
||||||
|
# else
|
||||||
PRIVATE->file.seekToBegin();
|
PRIVATE->file.seekToBegin();
|
||||||
PIString str(PRIVATE->file.readAll(true));
|
PIString str(PRIVATE->file.readAll(true));
|
||||||
int si = str.find('(') + 1, fi = 0, cc = 1;
|
int si = str.find('(') + 1, fi = 0, cc = 1;
|
||||||
@@ -194,8 +233,8 @@ void PISystemMonitor::run() {
|
|||||||
continue;
|
continue;
|
||||||
gatherThread(i.name().toInt());
|
gatherThread(i.name().toInt());
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
stat.ID = pID_;
|
|
||||||
// HMODULE hMod;
|
// HMODULE hMod;
|
||||||
// DWORD cbNeeded;
|
// DWORD cbNeeded;
|
||||||
if (GetProcessMemoryInfo(PRIVATE->hProc, &PRIVATE->mem_cnt, sizeof(PRIVATE->mem_cnt)) != 0) {
|
if (GetProcessMemoryInfo(PRIVATE->hProc, &PRIVATE->mem_cnt, sizeof(PRIVATE->mem_cnt)) != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user