больше данных о системе в состоянии устройства (load average + RAM total/free)
This commit is contained in:
@@ -77,10 +77,10 @@ public:
|
||||
TerminalNetworkSettings& operator= (const TerminalNetworkSettings& src) = default;
|
||||
|
||||
void loadDefaults() {
|
||||
managementIp = "0.0.0.0/0";
|
||||
managementIp = "0.0.0.0";
|
||||
managementGateway = "";
|
||||
mode = "l2";
|
||||
dataIp = "0.0.0.0/0";
|
||||
dataIp = "0.0.0.0";
|
||||
dataMtu = 1500;
|
||||
}
|
||||
};
|
||||
@@ -799,6 +799,46 @@ void api_driver::ApiDriver::resetPacketStatistics() const {
|
||||
this->daemon->resetPacketStatistics();
|
||||
}
|
||||
|
||||
static void generateModcode(std::ostream& out, const char* paramName, uint32_t modcod) {
|
||||
struct _modcodDef {const char* modulation; const char* speed;};
|
||||
const static _modcodDef defs[] = {
|
||||
{.modulation = "DUMMY", .speed = "0"},
|
||||
{.modulation = "QPSK", .speed = "1/4"},
|
||||
{.modulation = "QPSK", .speed = "1/3"},
|
||||
{.modulation = "QPSK", .speed = "2/5"},
|
||||
{.modulation = "QPSK", .speed = "1/2"},
|
||||
{.modulation = "QPSK", .speed = "3/5"},
|
||||
{.modulation = "QPSK", .speed = "2/3"},
|
||||
{.modulation = "QPSK", .speed = "3/4"},
|
||||
{.modulation = "QPSK", .speed = "4/5"},
|
||||
{.modulation = "QPSK", .speed = "5/6"},
|
||||
{.modulation = "QPSK", .speed = "8/9"},
|
||||
{.modulation = "QPSK", .speed = "9/10"},
|
||||
{.modulation = "8PSK", .speed = "3/5"},
|
||||
{.modulation = "8PSK", .speed = "2/3"},
|
||||
{.modulation = "8PSK", .speed = "3/4"},
|
||||
{.modulation = "8PSK", .speed = "5/6"},
|
||||
{.modulation = "8PSK", .speed = "8/9"},
|
||||
{.modulation = "8PSK", .speed = "9/10"},
|
||||
{.modulation = "16APSK", .speed = "2/3"},
|
||||
{.modulation = "16APSK", .speed = "3/4"},
|
||||
{.modulation = "16APSK", .speed = "4/5"},
|
||||
{.modulation = "16APSK", .speed = "5/6"},
|
||||
{.modulation = "16APSK", .speed = "8/9"},
|
||||
{.modulation = "16APSK", .speed = "9/10"},
|
||||
{.modulation = "32APSK", .speed = "3/4"},
|
||||
{.modulation = "32APSK", .speed = "4/5"},
|
||||
{.modulation = "32APSK", .speed = "5/6"},
|
||||
{.modulation = "32APSK", .speed = "8/9"},
|
||||
{.modulation = "32APSK", .speed = "9/10"},
|
||||
};
|
||||
const _modcodDef* d = defs;
|
||||
if (modcod < 28) {
|
||||
d = defs + modcod;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string api_driver::ApiDriver::loadSettings() const {
|
||||
if (daemon == nullptr) {
|
||||
return R"({"error": "api daemon not started!"})";
|
||||
@@ -819,24 +859,24 @@ std::string api_driver::ApiDriver::loadSettings() const {
|
||||
|
||||
std::stringstream result;
|
||||
#ifdef MODEM_IS_SCPC
|
||||
result << "{\n\"general.isCinC\":" << boolAsStr(modSettings.is_cinc);
|
||||
result << ",\"general.txEn\":" << boolAsStr(modSettings.tx_is_on);
|
||||
result << ",\"general.modulatorMode\":" << (modSettings.is_carrier ? "\"normal\"" : "\"test\"");
|
||||
result << ",\"general.autoStartTx\":" << boolAsStr(modSettings.is_save_current_state);
|
||||
result << ",\"general.isTestInputData\":" << boolAsStr(modSettings.is_test_data);
|
||||
result << ",\n\"tx.attenuation\":"; writeDouble(result, modSettings.attenuation);
|
||||
result << ",\"tx.rolloff\":" << static_cast<int>(modSettings.rollof * 100);
|
||||
result << ",\"tx.cymRate\":" << modSettings.baudrate;
|
||||
result << ",\"tx.centerFreq\":"; writeDouble(result, modSettings.central_freq_in_kGz, 3);
|
||||
result << "{\n\"isCinC\":" << boolAsStr(modSettings.is_cinc);
|
||||
result << ",\"txEn\":" << boolAsStr(modSettings.tx_is_on);
|
||||
result << ",\"txModulatorIsTest\":" << boolAsStr(!modSettings.is_carrier);
|
||||
result << ",\"txAutoStart\":" << boolAsStr(modSettings.is_save_current_state);
|
||||
result << ",\"txIsTestInput\":" << boolAsStr(modSettings.is_test_data);
|
||||
result << ",\n\"txAttenuation\":"; writeDouble(result, modSettings.attenuation);
|
||||
result << ",\"txRolloff\":" << static_cast<int>(modSettings.rollof * 100);
|
||||
result << ",\"txBaudrate\":" << modSettings.baudrate;
|
||||
result << ",\"txCentralFreq\":"; writeDouble(result, modSettings.central_freq_in_kGz, 3);
|
||||
result << ",\"dvbs2.frameSizeNormal\":" << boolAsStr(!(modSettings.modcod_tx & 2));
|
||||
result << ",\"dvbs2.ccm_modcod\":" << (modSettings.modcod_tx >> 2);
|
||||
|
||||
// result << ",\"dvbs2.isPilots\":" << "null";
|
||||
result << ",\n\"dvbs2.isAcm\":" << boolAsStr(acmSettings.enable);
|
||||
result << ",\n\"dvbIsAcm\":" << boolAsStr(acmSettings.enable);
|
||||
result << ",\"dvbs2.acm_maxModcod\":" << (acmSettings.max_modcod >> 2);
|
||||
result << ",\"dvbs2.acm_minModcod\":" << (acmSettings.min_modcod >> 2);
|
||||
result << ",\"dvbs2.snrReserve\":"; writeDouble(result, acmSettings.snr_treashold_acm);
|
||||
result << ",\"dvbs2.servicePacketPeriod\":" << acmSettings.period_pack;
|
||||
result << ",\"dvbServicePacketPeriod\":" << acmSettings.period_pack;
|
||||
|
||||
result << ",\n\"acm.en\":" << boolAsStr(acmSettings.enable_auto_atten);
|
||||
result << ",\"acm.maxAttenuation\":"; writeDouble(result, acmSettings.max_attenuation);
|
||||
@@ -1098,35 +1138,34 @@ std::string api_driver::ApiDriver::loadSysInfo() {
|
||||
struct sysinfo info{};
|
||||
sysinfo(&info);
|
||||
|
||||
struct sysinfo {
|
||||
long uptime; /* Seconds since boot */
|
||||
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
unsigned long totalram; /* Total usable main memory size */
|
||||
unsigned long freeram; /* Available memory size */
|
||||
unsigned long sharedram; /* Amount of shared memory */
|
||||
unsigned long bufferram; /* Memory used by buffers */
|
||||
unsigned long totalswap; /* Total swap space size */
|
||||
unsigned long freeswap; /* Swap space still available */
|
||||
unsigned short procs; /* Number of current processes */
|
||||
unsigned long totalhigh; /* Total high memory size */
|
||||
unsigned long freehigh; /* Available high memory size */
|
||||
unsigned int mem_unit; /* Memory unit size in bytes */
|
||||
};
|
||||
// struct sysinfo {
|
||||
// long uptime; /* Seconds since boot */
|
||||
// unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
// unsigned long totalram; /* Total usable main memory size */
|
||||
// unsigned long freeram; /* Available memory size */
|
||||
// unsigned long sharedram; /* Amount of shared memory */
|
||||
// unsigned long bufferram; /* Memory used by buffers */
|
||||
// unsigned long totalswap; /* Total swap space size */
|
||||
// unsigned long freeswap; /* Swap space still available */
|
||||
// unsigned short procs; /* Number of current processes */
|
||||
// unsigned long totalhigh; /* Total high memory size */
|
||||
// unsigned long freehigh; /* Available high memory size */
|
||||
// unsigned int mem_unit; /* Memory unit size in bytes */
|
||||
// };
|
||||
|
||||
double f_load = 1.0 / (1 << SI_LOAD_SHIFT);
|
||||
|
||||
result << "{\n\"uptime\":" << info.uptime;
|
||||
result << ",\"load1min\":" << info.loads[0];
|
||||
result << ",\"load5min\":" << info.loads[1];
|
||||
result << ",\"load15min\":" << info.loads[2];
|
||||
result << ",\"totalram\":" << info.totalram;
|
||||
result << ",\"freeram\":" << info.freeram;
|
||||
result << ",\"sharedram\":" << info.sharedram;
|
||||
result << ",\"bufferram\":" << info.bufferram;
|
||||
result << ",\"totalswap\":" << info.totalswap;
|
||||
result << ",\"freeswap\":" << info.freeswap;
|
||||
result << ",\"load1min\":"; writeDouble(result, f_load * static_cast<double>(info.loads[0]), 2);
|
||||
result << ",\"load5min\":"; writeDouble(result, f_load * static_cast<double>(info.loads[1]), 2);
|
||||
result << ",\"load15min\":"; writeDouble(result, f_load * static_cast<double>(info.loads[2]), 2);
|
||||
result << ",\"totalram\":" << ((info.totalram * info.mem_unit) >> 20); // Mb
|
||||
result << ",\"freeram\":" << ((info.freeram * info.mem_unit) >> 20); // Mb
|
||||
result << ",\"sharedram\":" << ((info.sharedram * info.mem_unit) >> 20); // Mb
|
||||
result << ",\"bufferram\":" << ((info.bufferram * info.mem_unit) >> 20); // Mb
|
||||
// result << ",\"totalswap\":" << info.totalswap * info.mem_unit;
|
||||
// result << ",\"freeswap\":" << info.freeswap * info.mem_unit;
|
||||
result << ",\"procs\":" << static_cast<long>(info.procs);
|
||||
result << ",\"totalhigh\":" << info.totalhigh;
|
||||
result << ",\"freehigh\":" << info.freehigh;
|
||||
result << ",\"mem_unit\":" << info.mem_unit;
|
||||
result << "\n}";
|
||||
return result.str();
|
||||
}
|
||||
|
Reference in New Issue
Block a user