Bonjour,
Bon j’ai pas été assez rapide, mais c’est bien le script dont je parlais.
Le mien est planifié toutes les 5 minutes.
Dans mon scénario j’ai 2 blocs code, le premier gère l’erreur « Not enough space in stream buffer detected » et le second test les noeuds morts.
Premier bloc :
$pathlog=log::getPathToLog('openzwaved');
if (file_exists($pathlog) && shell_exec('grep "Not enough space in stream buffer" ' . $pathlog . ' | wc -l') > 0)
{
$scenario->setLog('Not enough space in stream buffer detected');
log::add('openzwave', 'error', 'Not enough space in stream buffer detected');
log::clear('openzwaved');
shell_exec('sudo pkill -f openzwaved.py');
openzwave::deamon_stop();
sleep(5);
openzwave::deamon_start();
}
Deuxième bloc :
//**********************************************************
// Parameters
//**********************************************************
$API_Key = 'API KEY';
$Ping_Wait = 15;
//**********************************************************
//**********************************************************
// Get list of all elements on sector
//**********************************************************
$scenario->setLog('**********************************************************');
$scenario->setLog('***** Get list *****');
$scenario->setLog('**********************************************************');
$url_GetInfo = 'http://localhost:8083/network?apikey=' .$API_Key .'&type=info&info=getNodesList';
$Alim_List = array();
$ToPing_List = array();
$content = (file_get_contents($url_GetInfo));
$All_Info = json_decode($content, true);
$All_node = $All_Info["result"]["devices"];
foreach($All_node as $key => $value){
$Alim = $value["capabilities"]["isListening"];
$Controller = $value["description"]["is_static_controller"];
if(($Alim == 1) and ($Controller != 1)){
$test = $value["description"]["product_name"];
$Alim_List[] = $key;
}
}
$scenario->setLog('Number of elements: ' .count($Alim_List));
//**********************************************************
//**********************************************************
// Get health of a list of elements
//**********************************************************
$scenario->setLog('**********************************************************');
$scenario->setLog('***** Health *****');
$scenario->setLog('**********************************************************');
foreach($Alim_List as $id){
// $scenario->setLog('Module :'.$id);
$url_health = 'http://localhost:8083/node?apikey=' .$API_Key .'&node_id=' .$id .'&type=info&info=getHealth';
$Node_health_tmp = file_get_contents($url_health);
$Node_health = json_decode($Node_health_tmp);
if ($Node_health->result->data->isFailed->value){
$scenario->setLog('Module :'.$id .' is on error');
$ToPing_List[] = $id;
}
else{
//$scenario->setLog('no problem for Module ' .$id);
}
}
//**********************************************************
//**********************************************************
// Ping a list of elements
//**********************************************************
$scenario->setLog('**********************************************************');
$scenario->setLog('***** Ping *****');
$scenario->setLog('**********************************************************');
foreach($ToPing_List as $id){
$scenario->setLog('Ping Module :'.$id);
$url_ping = 'http://localhost:8083/node?apikey=' .$API_Key .'&node_id=' .$id .'&type=action&action=testNode';
file_get_contents($url_ping);
sleep($Ping_Wait);
}
//**********************************************************
J’ai jamais eu de problème avec ce scénario. Je suis en Jeedom V3 à jour.
Bonne soirée,