Merge branch 'fix-2283' of https://github.com/Arnavion/plugins into Arnavion-fix-2283

This commit is contained in:
Ad Schellevis 2021-03-22 11:30:19 +01:00
commit dc1d703c5c
2 changed files with 18 additions and 27 deletions

View file

@ -57,6 +57,7 @@ class ServiceController extends ApiControllerBase
if ($this->request->isPost()) {
$device = $this->request->getPost('device');
$type = $this->request->getPost('type');
$json = $this->request->getPost('json');
if (!in_array($device, $this->getDevices())) {
return array("message" => "Invalid device name");
@ -70,7 +71,15 @@ class ServiceController extends ApiControllerBase
$backend = new Backend();
$output = $backend->configdpRun("smart", array("info", $type, "/dev/" . $device));
$params = array("info", $type, "/dev/" . $device);
if ($json != NULL) {
$params[0] = "info_json";
}
$output = $backend->configdpRun("smart", $params);
if ($json != NULL) {
$output = json_decode($output, true);
}
return array("output" => $output);
}

View file

@ -10,35 +10,17 @@ parameters:
type:script_output
message:list installed devices
[info.i]
command:/usr/local/sbin/smartctl -i
parameters:%s; exit 0
[info]
command:/usr/local/sbin/smartctl
parameters:-%s %s; exit 0
type:script_output
message:Get identity info for device %s
message:exec smartctl -%s for device %s
[info.H]
command:/usr/local/sbin/smartctl -H
parameters:%s; exit 0
[info_json]
command:/usr/local/sbin/smartctl
parameters:-%s --json=c %s; exit 0
type:script_output
message:Get SMART health status info for device %s
[info.c]
command:/usr/local/sbin/smartctl -c
parameters:%s; exit 0
type:script_output
message:Get capabilities for device %s
[info.A]
command:/usr/local/sbin/smartctl -A
parameters:%s; exit 0
type:script_output
message:Get vendor-specific attributes for device %s
[info.a]
command:/usr/local/sbin/smartctl -a
parameters:%s; exit 0
type:script_output
message:Get all SMART info for device %s
message:exec smartctl -%s (JSON) for device %s
[log.error]
command:/usr/local/sbin/smartctl -l error