Skip to content

Commit 1cc8b81

Browse files
committed
Merge branch 'dev' into 'master'
2 parents 6cf1b1e + 8096965 commit 1cc8b81

File tree

11 files changed

+52
-18
lines changed

11 files changed

+52
-18
lines changed

gpustat.plg

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!DOCTYPE PLUGIN [
33
<!ENTITY name "gpustat">
44
<!ENTITY author "b3rs3rk">
5-
<!ENTITY version "2022.02.22">
5+
<!ENTITY version "2022.11.23">
66
<!ENTITY launch "Settings/GPUStatSettings">
77
<!ENTITY gitURL "https://raw.githubusercontent.com/b3rs3rk/&name;-unraid/master">
88
<!ENTITY pluginURL "&gitURL;/&name;.plg">
@@ -48,6 +48,13 @@
4848
-->
4949

5050
<CHANGES>
51+
###2022-11-23
52+
- Add parent process checking for app detection
53+
- #40 Add Frigate app detection
54+
- #41 Add FileFlows app detection
55+
- #42 Add ErsatzTV app detection
56+
- #44 Attempt to fix Intel monitoring issues in 6.11
57+
5158
###2022-02-22
5259
- #35 Fix jellyfin app detection looking for the wrong image path
5360

pkg/gpustat-2022.11.23-x86_64.md5

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1a78d73533f5864f7f6ee2bc376ffd6f gpustat-2022.11.23-x86_64.txz

pkg/gpustat-2022.11.23-x86_64.txz

724 KB
Binary file not shown.

src/gpustat/usr/local/emhttp/plugins/gpustat/gpustatus.page

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Icon="gpustat.png"
3131
$gpu_nv = $gpu_intel = $gpu_amd = $gpu_unknown = false;
3232

3333
$apps = [
34-
'plex', 'jellyfin', 'handbrake', 'emby', 'tdarr', 'unmanic', 'dizquetv',
35-
'deepstack', 'nsfminer', 'shinobipro', 'foldinghome',
34+
'plex', 'jellyfin', 'handbrake', 'emby', 'tdarr', 'unmanic', 'dizquetv', 'ersatztv',
35+
'fileflows', 'frigate', 'deepstack', 'nsfminer', 'shinobipro', 'foldinghome',
3636
];
3737

3838
switch ($gpustat_cfg['VENDOR']) {

src/gpustat/usr/local/emhttp/plugins/gpustat/gpustatus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
$gpustat_cfg['inventory'] = true;
4848
// Settings page looks for $gpustat_data specifically -- inventory all supported GPU types
4949
$gpustat_data = (new Nvidia($gpustat_cfg))->getInventory();
50-
$gpustat_data += (new Intel($gpustat_cfg))->getInventory();
50+
$gpustat_data[] = (new Intel($gpustat_cfg))->getInventory();
5151
$gpustat_data += (new AMD($gpustat_cfg))->getInventory();
5252

5353
} else {
2.21 KB
Loading
8.16 KB
Loading
2.65 KB
Loading

src/gpustat/usr/local/emhttp/plugins/gpustat/lib/Intel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class Intel extends Main
3838
const INVENTORY_UTILITY = 'lspci';
3939
const INVENTORY_PARAM = "| grep VGA";
4040
const INVENTORY_REGEX =
41-
'/VGA.+\:\s+Intel\s+Corporation\s+(?P<model>.*)\s+(Family|Integrated|Graphics|Controller|Series|\()/iU';
41+
'/VGA.+:\s+Intel\s+Corporation\s+(?P<model>.*)\s+(\[|Family|Integrated|Graphics|Controller|Series|\()/iU';
4242
const STATISTICS_PARAM = '-J -s 250';
43-
const STATISTICS_WRAPPER = 'timeout -k .500 .400';
43+
const STATISTICS_WRAPPER = 'timeout -k .500 .600';
4444

4545
/**
4646
* Intel constructor.
@@ -59,7 +59,7 @@ public function __construct(array $settings = [])
5959
*/
6060
public function getInventory(): array
6161
{
62-
$result = $inventory = [];
62+
$result = [];
6363

6464
if ($this->cmdexists) {
6565
$this->checkCommand(self::INVENTORY_UTILITY, false);
@@ -70,7 +70,7 @@ public function getInventory(): array
7070
}
7171
if (!empty($this->inventory)) {
7272
// Only one iGPU per system, so mark it ID 99 and pad other results
73-
$inventory[0] = [
73+
$inventory = [
7474
'id' => 99,
7575
'model' => $this->inventory[0]['model'],
7676
'guid' => '0000-00-000-000000',

src/gpustat/usr/local/emhttp/plugins/gpustat/lib/Main.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function __construct(array $settings = [])
102102
* @param string $utility
103103
* @param bool $error
104104
*/
105-
protected function checkCommand(string $utility, $error = true)
105+
protected function checkCommand(string $utility, bool $error = true)
106106
{
107107
$this->cmdexists = false;
108108
// Check if vendor utility is available
@@ -125,7 +125,7 @@ protected function checkCommand(string $utility, $error = true)
125125
* @param string $argument
126126
* @param bool $escape
127127
*/
128-
protected function runCommand(string $command, string $argument = '', $escape = true)
128+
protected function runCommand(string $command, string $argument = '', bool $escape = true)
129129
{
130130
if ($escape) {
131131
$this->stdout = shell_exec(sprintf("%s %s", $command, escapeshellarg($argument)));
@@ -146,7 +146,26 @@ protected function getFullCommand(int $pid): string
146146
$file = sprintf('/proc/%0d/cmdline', $pid);
147147

148148
if (file_exists($file)) {
149-
$command = trim(file_get_contents($file), "\0");
149+
$command = trim(@file_get_contents($file), "\0");
150+
}
151+
152+
return $command;
153+
}
154+
155+
/**
156+
* Retrieves the full command of a parent process with arguments for a given process ID
157+
*
158+
* @param int $pid
159+
* @return string
160+
*/
161+
protected function getParentCommand(int $pid): string
162+
{
163+
$command = '';
164+
$pid_command = sprintf("ps j %0d | awk 'NR>1' | cut -d ' ' -f 1", $pid);
165+
166+
$ppid = (int)trim(shell_exec($pid_command));
167+
if ($ppid > 0) {
168+
$command = $this->getFullCommand($ppid);
150169
}
151170

152171
return $command;
@@ -216,7 +235,7 @@ protected static function convertCelsius(int $temp = 0): float
216235
{
217236
$fahrenheit = $temp*(9/5)+32;
218237

219-
return round($fahrenheit, -1, PHP_ROUND_HALF_UP);
238+
return round($fahrenheit, -1);
220239
}
221240

222241
/**
@@ -229,9 +248,9 @@ protected static function convertCelsius(int $temp = 0): float
229248
protected static function roundFloat(float $number, int $precision = 0): float
230249
{
231250
if ($precision > 0) {
232-
$result = number_format(round($number, $precision, PHP_ROUND_HALF_UP), $precision, '.','');
251+
$result = number_format(round($number, $precision), $precision, '.','');
233252
} else {
234-
$result = round($number, $precision, PHP_ROUND_HALF_UP);
253+
$result = round($number, $precision);
235254
}
236255

237256
return $result;

0 commit comments

Comments
 (0)