Hi,
nettes Modul. Wenn Du ‚Docker‘ noch als Betriebssystem neben Ubuntu und Raspberry aufnimmst wird es noch netter:-)
Das Synology, und vermutlich andere, Docker basieren auf Ubuntu. Ich habe ein SHR (Synology Hybrid Raid) eingerichtet und mit /dev/vg1000/lv bekomme ich da die Daten bei Partition 1 angezeigt. Mit /dev/md3 als 2 Partition bekomme ich eine SSD angezeigt auf der meine Docker-Daten liegen.
Ich schau mal nach den anderen Daten.
So hab mal geschaut.
Mit dieser get_version liefert Docker auch Linux-Infos:
private function get_version()
{
$sys = IPS_GetKernelPlatform();
switch ($sys) {
case 'Docker':
$res = $this->execute('cat /proc/version');
break;
default:
$res = $this->execute('lsb_release -ds');
break;
}
if ($res == '' || count($res) < 1) {
$this->SendDebug(__FUNCTION__, 'bad data: ' . print_r($res, true), 0);
return false;
}
$OsVersion = $res[0];
$this->SendDebug(__FUNCTION__, 'OsVersion=' . $OsVersion, 0);
$this->SetValue('OsVersion', $OsVersion);
return true;
}
und mit dieser get_cpuinfo werden auch CPU-Infos geliefert:
private function get_cpuinfo()
{
$res = $this->execute('lscpu ');
if ($res == '' || count($res) < 1) {
$this->SendDebug(__FUNCTION__, 'bad data: ' . print_r($res, true), 0);
return false;
}
$CpuModel = '';
$CpuCount = 0;
$CpuCurFrequency = 0;
$v = [];
foreach ($res as $r) {
$s = preg_split("/:[\s]+/", $r);
if (count($s) < 2) {
$this->SendDebug(__FUNCTION__, 'bad data: ' . $r, 0);
continue;
}
$name = $s[0];
$value = $s[1];
$v[$name] = $value;
}
$sys = IPS_GetKernelPlatform();
switch ($sys) {
case 'Docker':
$CpuModel = isset($v['Model name']) ? $v['Model name'] : '';
$CpuCount = isset($v['CPU(s)']) ? $v['CPU(s)'] : 0;
$CpuCurFrequency = isset($v['CPU MHz']) ? $v['CPU MHz'] : 0;
break;
case 'Ubuntu':
$CpuModel = isset($v['Modellname']) ? $v['Modellname'] : '';
$CpuCount = isset($v['CPU(s)']) ? $v['CPU(s)'] : 0;
$CpuCurFrequency = isset($v['CPU MHz']) ? $v['CPU MHz'] : 0;
break;
case 'Raspberry Pi':
$CpuModel = isset($v['Model name']) ? $v['Model name'] : '';
$CpuCount = isset($v['CPU(s)']) ? $v['CPU(s)'] : 0;
$res = $this->execute('vcgencmd measure_clock arm ');
if ($res == '' || count($res) < 1) {
$this->SendDebug(__FUNCTION__, 'bad data: ' . print_r($res, true), 0);
return false;
}
$s = preg_split('/=/', $res[0]);
if (preg_match('/^frequency/', $s[0])) {
$CpuCurFrequency = (int) ((float) $s[1] / 1024 / 1024);
}
break;
}
$this->SendDebug(__FUNCTION__, 'CpuModel=' . $CpuModel . ', CpuCurFrequency=' . $CpuCurFrequency . ' MHz, CpuCount=' . $CpuCount, 0);
$this->SetValue('CpuModel', $CpuModel);
$this->SetValue('CpuCurFrequency', $CpuCurFrequency);
$this->SetValue('CpuCount', $CpuCount);
return true;
}
btw. ist „Modellname“ mit 2 L richtig?
Ein kleiner Wunsch. Könnte man Anzahl Platten vielleicht auf 4 erhöhen? Docker und NAS läuft schon öfter auf mehreren Platten.
Ralf