Example #1
0
 $rigs_to_reboot = array();
 // Holds all notifications which will be send.
 $notifications = array();
 if (!empty($rig_notifications)) {
     foreach ($rig_notifications as $rig => $notification_data) {
         $rig_cfg = $config->get_rig($rig);
         $rpc = new PHPMinerRPC($rig_cfg['http_ip'], $rig_cfg['http_port'], $rig_cfg['rpc_key'], 10);
         if (!$rpc->ping()) {
             continue;
         }
         // Rig disabled.
         if (!empty($rig_cfg['disabled'])) {
             continue;
         }
         $is_cgminer_running = $rpc->is_cgminer_running();
         $has_defunc = $rpc->is_cgminer_defunc();
         $notify_cgminer_restart = $notification_data['notify_cgminer_restart'];
         $notify_reboot = $notification_data['notify_reboot'];
         // If PHPMiner should check for defunc.
         if (!empty($notification_data['reboot_defunc'])) {
             // Check if there is a defunced cgminer process.
             $rigs_to_reboot[$rig] = $has_defunc;
             if (!empty($rigs_to_reboot[$rig]) && $notify_reboot) {
                 $notifications['reboot'][$rig] = array('Needed to reboot rig ' . $rig . '.');
             }
         }
         // Precheck if cgminer is running
         if (!empty($notification_data['restart_cgminer']) && !$is_cgminer_running) {
             // Try to restart cgminer.
             $rpc->restart_cgminer();
             if ($notify_cgminer_restart) {