checkFreeSpace
|
$max_usage=90; //%
$output=array();
exec('df',$output);
//var_dump($output);
$problems=0;
$problems_details='';
foreach($output as $line) {
if (preg_match('/(\d+)% (\/.+)/',$line,$m))
$proc=$m[1];
$path=$m[2];
if ($proc>$max_usage) {
$problems++;
$problems_details.="$path: $proc; ";
}
//echo "$path: $proc%<br/>";
}
sg("ThisComputer.SpaceProblems",$problems);
sg("ThisComputer.SpaceProblems_Details",$problems_details);
setTimeOut('checkFreeSpace','runScript("checkFreeSpace");',5*60);
|
rebootSystem
|
$filename = ROOT . '/database_backup/db.sql';
$mysqlDumpPath = "/usr/bin/mysqldump";
$mysqlDumpParam = " --user=" . DB_USER . " --password=" . DB_PASSWORD;
$mysqlDumpParam .= " --no-create-db --add-drop-table --databases " . DB_NAME;
if (file_exists($filename)) rename($filename, $filename . '.prev');
exec($mysqlDumpPath . $mysqlDumpParam . " > " . $filename);
safe_exec('cp -rf /tmp/mysql/* /var/lib/mysql');
say(LANG_GENERAL_STARTING_REBOOT,2);
setTimeout("shutdownTimer","safe_exec('shutdown -r now');",15);
|
shutDown
|
$filename_main = ROOT . 'database_backup/db.sql';
$filename_history = ROOT . 'database_backup/db_history.sql';
$mysqlDumpPath = "/usr/bin/mysqldump";
$mysqlDumpParam = " --user=" . DB_USER . " --password=" . DB_PASSWORD;
$mysqlDumpParam .= " --no-create-db --add-drop-table --databases " . DB_NAME;
if (file_exists($filename_main)) rename($filename_main, $filename_main . '.prev');
$add_params = '--ignore-table='.DB_NAME.'.phistory --ignore-table='.DB_NAME.'.cached_values';
exec($mysqlDumpPath . $mysqlDumpParam . " ".$add_params."> " . $filename_main.'.tmp');
rename($filename_main.'.tmp', $filename_main);
if (file_exists($filename_history)) rename($filename_history, $filename_history . '.prev');
$add_params = 'phistory';
exec($mysqlDumpPath . $mysqlDumpParam . " ".$add_params."> " . $filename_history.'.tmp');
rename($filename_history.'.tmp', $filename_history);
// $filename = ROOT . '/database_backup/db.sql';
// $mysqlDumpPath = "/usr/bin/mysqldump";
// $mysqlDumpParam = " --user=" . DB_USER . " --password=" . DB_PASSWORD;
// $mysqlDumpParam .= " --no-create-db --add-drop-table --databases " . DB_NAME;
// if (file_exists($filename)) rename($filename, $filename . '.prev');
// exec($mysqlDumpPath . $mysqlDumpParam . " > " . $filename);
say(LANG_GENERAL_STARTING_SHUTDOWN,2);
//setTimeout("shutdownTimer","safe_exec('shutdown -h now');",15);
|
tellIPAddress
|
runScript('updateCPUId');
say("система в работе",2);
$res=exec('hostname -I');
$ipv6_regex='/(\w{4})/is';
$res = trim(preg_replace($ipv6_regex,'',$res));
$ipv6_regex='/:(\w+)/is';
$res = trim(preg_replace($ipv6_regex,'',$res));
$res = trim(str_replace(':','',$res));
say(LANG_GENERAL_IP_ADDRESS." ".$res,2);
|
updateCPUId
|
$data=trim(exec("cat /proc/cpuinfo | grep Serial | cut -d ':' -f 2"));
$data=ltrim($data,'0');
echo $data;
if ($data) {
setGlobal("ThisComputer.Serial",$data);
}
|
weatherReceived
|
setGlobal('ThisComputer.tempOutside',getGlobal('ow_fact.temperature'));
|