File size: 1,774 Bytes
bad179a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Everything that depends on the operating system of the monitored machines: how to start a shell, the
// collector script with its parser (MetricsEngine::process), and the control commands. Linux and Windows
// editions differ only in Platform.cpp.
#pragma once
#include <QStringList>
#include <QVector>

struct Def { QString key, label, unit; };                                               // rule metric / action catalogue
struct Cmd { QString label, cmd; bool danger = false, confirm = true, button = true; }; // cmd: %1 = pid or quoted name

namespace P {
extern const char *const prioLabel, *const kernelPrefix, *const sshHint, *const cleanup; // cleanup: default disk cleanup command
extern const bool sudo, posixCpu;      // "sudo -n" exists; CPU time has I/O wait + steal
extern const int interval, normalPrio; // default sample interval (s); priority value of an ordinary process
QStringList shell(int interval = 0);            // argv of a shell that runs a script from stdin (interval > 0: collector arguments)
QByteArray collector(int interval);             // stdin for the collector
QByteArray wrap(const QString &cmd, bool sudo); // stdin for a one-shot command
QString quote(QString s);                       // shell quoting
QString command(const QString &action, const QString &arg); // kill_pid | renice | restart_service | restart_failed | drop_caches
QString serviceLogs(const QString &unit, int lines);
QString power(bool reboot);
bool isProtected(int pid, int ppid, double rss, const QString &name); // never killed automatically, no leak / runaway findings
const QVector<Def> &ruleActions();              // unit = argument hint ("" = none)
const QVector<Cmd> &procActions(), &priorities(), &serviceActions(), &diagnostics(), &systemActions();
}