$active = 3; break; default: $active = 0; } } else { $active = 0; } if ($active == 0) { echo "This ist the cluster watchdog of the Gemeinschaft project \n", "- it should not be started directly by the user\n", "Please read the documentation for usage instructions.\n"; exit(1); } $starttime = time(); $endtime = $starttime + 60 - SLEEP_SECONDS * 2; readDataFile(DATAFILE); $node[0]['pid'] = getMyPid(); for ($node_id = 1; $node_id < count($node); $node_id++) { if ($node[$node_id]['status'] == STAT_FAILED && $node[$node_id]['timestamp'] < time() - REC_PERIOD * 60) { $node[$node_id]['status'] = STAT_NORMAL; } } $ips = getListenToIPs(); while (time() < $endtime) { for ($node_id = 1; $node_id < count($node); $node_id++) { $node_status = checkIfNodeAlive($node_id); if ($node_status > STAT_NORMAL) { if ($node_status == STAT_NORMAL) { $node[$node_id]['status'] = STAT_FAILED; $node[$node_id]['timestamp'] = time(); } write_log("*** Node {$node_id} is not alive with status " . $node[$node_id]['status'] . ". Tried " . $node[$node_id]['tries'] . " times.");
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. \*******************************************************************/ defined('GS_VALID') or die('No direct access.'); require_once GS_DIR . 'inc/util.php'; require_once GS_DIR . 'inc/log.php'; # The AGI environment is going to be made available in $AGI_ENV by this library. # The Asterisk environment is available in $_ENV['AST_...']. $AGI_ENV = array(); $agi_basename = baseName($_SERVER['SCRIPT_FILENAME']); $agi_log_prefix = $agi_basename . '[' . getMyPid() . ']| '; function gs_agi_log($level, $msg) { global $agi_log_prefix; return gs_log($level, $agi_log_prefix . $msg, 'agi.log', true); } gs_agi_log(GS_LOG_DEBUG, 'Launched ---------------------------'); $log_cmdline = baseName($argv[0]); for ($i = 1; $i < $argc; ++$i) { $log_cmdline .= ' ' . ($argv[$i] != '' ? escapeShellArg($argv[$i]) : '\'\''); } gs_agi_log(GS_LOG_DEBUG, 'Cmdline: ' . $log_cmdline); unset($log_cmd); function gs_agi_str_esc($str) { $str = str_replace(array('\\', ' ', "\n", "\r", "\t", '"'), array('\\\\', '\\ ', '\\ ', '\\ ', '\\ ', '\\"'), $str);