Code:
diff --git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php
index bdef7f5..bc478d7 100644
--- a/pts-core/functions/pts-functions.php
+++ b/pts-core/functions/pts-functions.php
@@ -114,6 +114,7 @@ if(($to_show = getenv("MONITOR")))
$monitor_power = in_array("all.power", $to_show) || $monitor_all;
$monitor_voltage = in_array("all.voltage", $to_show) || $monitor_all;
$monitor_freq = in_array("all.freq", $to_show) || $monitor_all;
+ $monitor_usage = in_array("all.usage", $to_show) || $monitor_all;
define("PTS_START_TIME", time());
if(in_array("gpu.temp", $to_show) || $monitor_temp)
@@ -163,6 +164,11 @@ if(($to_show = getenv("MONITOR")))
define("MONITOR_CPU_FREQ", 1);
$CPU_FREQ = array();
}
+ if(in_array("gpu.usage", $to_show) || $monitor_usage)
+ {
+ define("MONITOR_GPU_USAGE", 1);
+ $GPU_USAGE = array();
+ }
register_shutdown_function("pts_monitor_statistics");
}
diff --git a/pts-core/functions/pts-functions_monitor.php b/pts-core/functions/pts-functions_monitor.php
index 035af77..0a3a9e4 100644
--- a/pts-core/functions/pts-functions_monitor.php
+++ b/pts-core/functions/pts-functions_monitor.php
@@ -28,10 +28,12 @@ function pts_monitor_update()
pts_record_v12_voltage();
if(defined("MONITOR_CPU_FREQ"))
pts_record_cpu_frequency();
+ if(defined("MONITOR_GPU_USAGE"))
+ pts_record_gpu_usage();
}
function pts_monitor_arguments()
{
- return array("all", "all.temp", "all.power", "all.voltage", "all.freq", "gpu.temp", "cpu.temp", "sys.temp", "battery.power", "cpu.voltage", "v3.voltage", "v5.voltage", "v12.voltage", "cpu.freq");
+ return array("all", "all.temp", "all.power", "all.voltage", "all.freq", "gpu.temp", "cpu.temp", "sys.temp", "battery.power", "cpu.voltage", "v3.voltage", "v5.voltage", "v12.voltage", "cpu.freq", "gpu.usage");
}
function pts_monitor_statistics()
{
@@ -49,6 +51,7 @@ function pts_monitor_statistics()
$type_index["POWER"] = array();
$type_index["VOLTAGE"] = array();
$type_index["FREQUENCY"] = array();
+ $type_index["USAGE"] = array();
if(isset($GLOBALS["GPU_TEMPERATURE"]))
{
@@ -167,6 +170,19 @@ function pts_monitor_statistics()
array_push($type_index["FREQUENCY"], count($m_array) - 1);
}
}
+ if(isset($GLOBALS["GPU_USAGE"]))
+ {
+ $this_array = $GLOBALS["GPU_USAGE"];
+
+ if(is_array($this_array) && !empty($this_array[0]))
+ {
+ array_push($device, "GPU");
+ array_push($type, "Usage");
+ array_push($unit, "%");
+ array_push($m_array, $this_array);
+ array_push($type_index["USAGE"], count($m_array) - 1);
+ }
+ }
$info_report = "";
diff --git a/pts-core/functions/pts-functions_system_graphics.php b/pts-core/functions/pts-functions_system_graphics.php
index b7da406..1c93682 100644
--- a/pts-core/functions/pts-functions_system_graphics.php
+++ b/pts-core/functions/pts-functions_system_graphics.php
@@ -45,6 +45,14 @@ function graphics_processor_temperature()
return $temp_c;
}
+function pts_record_gpu_usage()
+{
+ global $GPU_USAGE;
+ $usage = graphics_gpu_usage();
+
+ if($usage != "")
+ array_push($GPU_USAGE, $usage);
+}
function graphics_antialiasing_level()
{
$aa_level = "";
@@ -294,5 +302,9 @@ function opengl_version()
return $info;
}
+function graphics_gpu_usage()
+{
+ return read_ati_extension("GPUActivity");
+}
?>
diff --git a/pts-core/functions/pts-functions_system_parsing.php b/pts-core/functions/pts-functions_system_parsing.php
index f61a981..8ce0622 100644
--- a/pts-core/functions/pts-functions_system_parsing.php
+++ b/pts-core/functions/pts-functions_system_parsing.php
@@ -209,6 +209,16 @@ function read_ati_extension($attribute)
$ati_info = $core_info . "," . $mem_info;
}
}
+ else if("GPUActivity" == $attribute)
+ {
+ $info = shell_exec("aticonfig --pplib-cmd \"get activity\" 2>&1");
+ if(($pos = strpos($info, "Activity")) > 0)
+ {
+ $activity_info = substr($info, strpos($info, "Activity:") + 8);
+ $activity_info = trim(substr($activity_info, 0, strpos($activity_info, "percent\n")));
+ $ati_info = $activity_info;
+ }
+ }
return $ati_info;
}
?>