|
|
|
@ -26,6 +26,7 @@
|
|
|
|
|
#include <QProcessEnvironment>
|
|
|
|
|
#include <QRegExp>
|
|
|
|
|
#include <QTextCodec>
|
|
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
|
|
|
|
@ -104,6 +105,15 @@ QStringList ExtendedSysMon::sources() const
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ExtendedSysMon::initValues()
|
|
|
|
|
{
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[initValues]";
|
|
|
|
|
QStringList sourceList = sources();
|
|
|
|
|
for (int i=0; i<sourceList.count(); i++)
|
|
|
|
|
sourceRequestEvent(sourceList[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ExtendedSysMon::readConfiguration()
|
|
|
|
|
{
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[readConfiguration]";
|
|
|
|
@ -197,6 +207,8 @@ void ExtendedSysMon::setKeys()
|
|
|
|
|
setData(source, key, QString(""));
|
|
|
|
|
key = QString("psTotal");
|
|
|
|
|
setData(source, key, QString("0"));
|
|
|
|
|
// initialization of values
|
|
|
|
|
initValues();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -311,7 +323,9 @@ void ExtendedSysMon::getCustomCmd(const QString cmd, const int number)
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run function with cmd" << cmd;
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run function with number" << number;
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getCustomCmd]" << ":" << "Run cmd" << QString("bash -c \"") + cmd + QString("\"");
|
|
|
|
|
processes[QString("custom")][number]->start(QString("bash -c \"") + cmd + QString("\""));
|
|
|
|
|
if ((processes[QString("custom")][number]->state() != QProcess::Running) &&
|
|
|
|
|
(processes[QString("custom")][number]->state() != QProcess::Starting))
|
|
|
|
|
processes[QString("custom")][number]->start(QString("bash -c \"") + cmd + QString("\""));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -347,7 +361,9 @@ void ExtendedSysMon::getGpu(const QString device)
|
|
|
|
|
else if (device == QString("ati"))
|
|
|
|
|
cmd = QString("aticonfig --od-getclocks");
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getGpu]" << ":" << "Run cmd" << cmd;
|
|
|
|
|
processes[QString("gpu")][0]->start(cmd);
|
|
|
|
|
if ((processes[QString("gpu")][0]->state() != QProcess::Running) &&
|
|
|
|
|
(processes[QString("gpu")][0]->state() != QProcess::Starting))
|
|
|
|
|
processes[QString("gpu")][0]->start(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -400,7 +416,9 @@ void ExtendedSysMon::getGpuTemp(const QString device)
|
|
|
|
|
else if (device == QString("ati"))
|
|
|
|
|
cmd = QString("aticonfig --od-gettemperature");
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getGpuTemp]" << ":" << "Run cmd" << cmd;
|
|
|
|
|
processes[QString("gputemp")][0]->start(cmd);
|
|
|
|
|
if ((processes[QString("gputemp")][0]->state() != QProcess::Running) &&
|
|
|
|
|
(processes[QString("gputemp")][0]->state() != QProcess::Running))
|
|
|
|
|
processes[QString("gputemp")][0]->start(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -446,7 +464,9 @@ void ExtendedSysMon::getHddTemp(const QString cmd, const QString device, const i
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with device" << device;
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run function with number" << number;
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getHddTemp]" << ":" << "Run cmd" << cmd + QString(" ") + device;
|
|
|
|
|
processes[QString("hddtemp")][number]->start(cmd + QString(" ") + device);
|
|
|
|
|
if ((processes[QString("hddtemp")][number]->state() != QProcess::Running) &&
|
|
|
|
|
(processes[QString("hddtemp")][number]->state() != QProcess::Starting))
|
|
|
|
|
processes[QString("hddtemp")][number]->start(cmd + QString(" ") + device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -483,31 +503,23 @@ void ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run function with MPD parameters" <<
|
|
|
|
|
mpdAddress + QString(":") + mpdPort;
|
|
|
|
|
QString cmd;
|
|
|
|
|
if (playerName == QString("amarok")) {
|
|
|
|
|
if (playerName == QString("amarok"))
|
|
|
|
|
// amarok
|
|
|
|
|
cmd = QString("bash -c \"qdbus org.kde.amarok /Player GetMetadata && qdbus org.kde.amarok /Player PositionGet\"");
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
|
|
|
|
processes[QString("player")][0]->start(cmd);
|
|
|
|
|
}
|
|
|
|
|
else if (playerName == QString("clementine")) {
|
|
|
|
|
else if (playerName == QString("clementine"))
|
|
|
|
|
// clementine
|
|
|
|
|
cmd = QString("bash -c \"qdbus org.mpris.clementine /Player GetMetadata && qdbus org.mpris.clementine /Player PositionGet\"");
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
|
|
|
|
processes[QString("player")][0]->start(cmd);
|
|
|
|
|
}
|
|
|
|
|
else if (playerName == QString("mpd")) {
|
|
|
|
|
else if (playerName == QString("mpd"))
|
|
|
|
|
// mpd
|
|
|
|
|
cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://") +
|
|
|
|
|
mpdAddress + QString(":") + mpdPort + QString("\"");
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
|
|
|
|
processes[QString("player")][0]->start(cmd);
|
|
|
|
|
}
|
|
|
|
|
else if (playerName == QString("qmmp")) {
|
|
|
|
|
else if (playerName == QString("qmmp"))
|
|
|
|
|
// qmmp
|
|
|
|
|
cmd = QString("qmmp --status");
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
|
|
|
|
cmd = QString("bash -c \"pgrep qmmp && qmmp --status || echo 'null'\"");
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
|
|
|
|
if ((processes[QString("player")][0]->state() != QProcess::Running) &&
|
|
|
|
|
(processes[QString("player")][0]->state() != QProcess::Starting))
|
|
|
|
|
processes[QString("player")][0]->start(cmd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -635,10 +647,14 @@ void ExtendedSysMon::getPsStats()
|
|
|
|
|
QString cmd;
|
|
|
|
|
cmd = QString("ps --no-headers -o command");
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
|
|
|
|
processes[QString("ps")][0]->start(cmd);
|
|
|
|
|
if ((processes[QString("ps")][0]->state() != QProcess::Running) &&
|
|
|
|
|
(processes[QString("ps")][0]->state() != QProcess::Starting))
|
|
|
|
|
processes[QString("ps")][0]->start(cmd);
|
|
|
|
|
cmd = QString("ps -e --no-headers -o command");
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getPsStats]" << ":" << "Run cmd" << cmd;
|
|
|
|
|
processes[QString("ps")][1]->start(cmd);
|
|
|
|
|
if ((processes[QString("ps")][1]->state() != QProcess::Running) &&
|
|
|
|
|
(processes[QString("ps")][1]->state() != QProcess::Starting))
|
|
|
|
|
processes[QString("ps")][1]->start(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -662,7 +678,7 @@ void ExtendedSysMon::setPs(int exitCode, QProcess::ExitStatus exitStatus)
|
|
|
|
|
psList.append(qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]);
|
|
|
|
|
QString source = QString("ps");
|
|
|
|
|
QString key = QString("psCount");
|
|
|
|
|
setData(source, key, QString::number(psList.count()));
|
|
|
|
|
setData(source, key, psList.count());
|
|
|
|
|
key = QString("ps");
|
|
|
|
|
setData(source, key, psList.join(QString(",")));
|
|
|
|
|
}
|
|
|
|
@ -670,7 +686,7 @@ void ExtendedSysMon::setPs(int exitCode, QProcess::ExitStatus exitStatus)
|
|
|
|
|
// pstotal
|
|
|
|
|
QString source = QString("ps");
|
|
|
|
|
QString key = QString("psTotal");
|
|
|
|
|
setData(source, key, QString::number(qoutput.split(QChar('\n'), QString::SkipEmptyParts).count()));
|
|
|
|
|
setData(source, key, qoutput.split(QChar('\n'), QString::SkipEmptyParts).count());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -684,7 +700,9 @@ void ExtendedSysMon::getUpgradeInfo(const QString pkgCommand, const int number)
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run function with number" << number;
|
|
|
|
|
QString cmd = QString("bash -c \"") + pkgCommand + QString(" | wc -l\"");
|
|
|
|
|
if (debug) qDebug() << "[DE]" << "[getUpgradeInfo]" << ":" << "Run cmd" << cmd;
|
|
|
|
|
processes[QString("pkg")][number]->start(cmd);
|
|
|
|
|
if ((processes[QString("pkg")][number]->state() != QProcess::Running) &&
|
|
|
|
|
(processes[QString("pkg")][number]->state() != QProcess::Starting))
|
|
|
|
|
processes[QString("pkg")][number]->start(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|