Hallo,
ich habe hier ein Skript gefunden um Werte vom Raspberry auszulesen.
Leider bekomme ich aber immer die folgenden Fehlermeldungen:
Notice: A non well formed numeric value encountered in /var/lib/symcon/scripts/12405.ips.php on line 26
Notice: A non well formed numeric value encountered in /var/lib/symcon/scripts/12405.ips.php on line 26
Notice: A non well formed numeric value encountered in /var/lib/symcon/scripts/12405.ips.php on line 27
Notice: A non well formed numeric value encountered in /var/lib/symcon/scripts/12405.ips.php on line 27
Notice: A non well formed numeric value encountered in /var/lib/symcon/scripts/12405.ips.php on line 28
Notice: A non well formed numeric value encountered in /var/lib/symcon/scripts/12405.ips.php on line 28
Notice: A non well formed numeric value encountered in /var/lib/symcon/scripts/12405.ips.php on line 29
Notice: A non well formed numeric value encountered in /var/lib/symcon/scripts/12405.ips.php on line 29
Notice: A non well formed numeric value encountered in /var/lib/symcon/scripts/12405.ips.php on line 33
Notice: A non well formed numeric value encountered in /var/lib/symcon/scripts/12405.ips.php on line 33
Das ist das Skript:
<?
$id1 = CreateVariableByName($_IPS['SELF'], "Temperatur", 2);
$id2 = CreateVariableByName($_IPS['SELF'], "Volts", 2);
$id3 = CreateVariableByName($_IPS['SELF'], "Clock", 2);
$id4 = CreateVariableByName($_IPS['SELF'], "freier Speicher", 2);
$id5 = CreateVariableByName($_IPS['SELF'], "MemFree", 2);
SetValue($id1 ,(exec("cat /sys/class/thermal/thermal_zone0/temp "))/1000);
SetValue($id2 ,(float)(substr(exec("vcgencmd measure_volts"),5)));
SetValue($id3 ,(int)((exec("cat /sys/devices/system/cpu/cpu0//cpufreq/scaling_cur_freq")) / 1000));
//Get the memory info, and grab the cool stuf
$meminfo = file("/proc/meminfo");
for ($i = 0; $i < count($meminfo); $i++) {
list($item, $data) = explode(":", $meminfo[$i], 2);
$item = chop($item);
$data = chop($data);
if ($item == "MemTotal") { $total_mem =$data; }
if ($item == "MemFree") { $free_mem = $data; }
if ($item == "MemAvailable") { $MemAvailable = $data; }
if ($item == "SwapTotal") { $total_swap = $data; }
if ($item == "SwapFree") { $free_swap = $data; }
if ($item == "Buffers") { $buffer_mem = $data; }
if ($item == "Cached") { $cache_mem = $data; }
if ($item == "MemShared") {$shared_mem = $data; }
}
$used_mem = ( $total_mem - $free_mem . ' kB');
$used_swap = ( $total_swap - $free_swap . ' kB' );
$percent_free = round( $free_mem / $total_mem * 100 );
$percent_used = round( $used_mem / $total_mem * 100 );
//$percent_swap = round( ( $total_swap - $free_swap ) / $total_swap * 100 );
//$percent_swap_free = round( $free_swap / $total_swap * 100 );
//$percent_buff = round( $buffer_mem / $total_mem * 100 );
$percent_cach = round( $cache_mem / $total_mem * 100 );
//$percent_shar = round( $shared_mem / $total_mem * 100 );
SetValue($id4 ,(int)$MemAvailable);
SetValue($id5 ,(int)$free_mem);
var_dump ($MemAvailable);
function CreateVariableByName($id, $name, $type)
{
$vid = @IPS_GetVariableIDByName($name, $id);
if($vid===false) {
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, $id);
IPS_SetName($vid, $name);
}
return $vid;
}
function CreateEventIDByName($id, $name, $type)
{
$eid = @IPS_GetEventIDByName($name, $id);
if($eid===false) {
$eid = IPS_CreateEvent($type);
IPS_SetParent($eid, $id);
IPS_SetName($eid, $name);
}
return $eid;
}
?>
Woran liegt das und wie kann ich es korrigieren?
Danke und Gruß
Stephan