private function init_all_servers() { for ($i = 0; $i < count($this->whmcsAllServers); $i++) { $server = $this->whmcsAllServers[$i]; if ($this->allPings) { // define ping monitor by IP $ping = MonitisHelper::in_array($this->allPings, 'url', $server['ipaddress']); if ($ping) { $monitorId = $ping['id']; $ext = MonitisHelper::in_array($this->whmcsExt, 'monitor_id', $monitorId); if (!$ext) { // link monitor $ext = monitisSnapShots::linkPingMonitor($monitorId, 'ping', $server['id']); $this->result[] = array('server' => $server['name'], 'action' => 'link', 'monitor' => $ext); } } } $agent = MonitisHelper::in_array($this->allAgents['agents'], 'key', $server['hostname']); if ($agent && isset($agent['status']) && $agent['status'] == 'running') { $this->internalMonitors($agent, $server); } } // remove unlinked internal monitors $this->unlinkedInternal(); }
private function initServer(&$server) { $monitor = null; if ($this->allPings) { // define ping monitor by IP $ping = MonitisHelper::in_array($this->allPings, 'url', $server['ipaddress']); if ($ping) { $monitorId = $ping['id']; $linkedMon = MonitisHelper::in_array($this->whmcsExt, 'monitor_id', $monitorId); if (!$linkedMon) { // link ping monitor $linkedMon = monitisSnapShots::linkPingMonitor($monitorId, 'ping', $server['id']); } $monitor = $ping; $monitor['available'] = $linkedMon['available']; $monitor['publickey'] = $linkedMon['publickey']; } } $server['ping'] = $monitor; $agent = $this->agentFullInfo; if ($agent) { $info = $this->intMonitor($agent, $server['id']); $server['agent'] = $info; } return $server; }
private function init_all_servers() { for ($i = 0; $i < count($this->whmcsAllServers); $i++) { $monitors = array(); $server = $this->whmcsAllServers[$i]; if ($this->allPings) { // define ping monitor by IP $ping = MonitisHelper::in_array($this->allPings, 'url', $server['ipaddress']); if ($ping) { $monitorId = $ping['id']; $ext = MonitisHelper::in_array($this->whmcsExt, 'monitor_id', $monitorId); if (!$ext && $this->synchronize) { // link monitor $ext = monitisSnapShots::linkPingMonitor($monitorId, 'ping', $server['id']); } $status = MonitisHelper::in_array($this->pingsStatus, 'id', $monitorId); $monitors['ping'] = $status; if ($ping['isSuspended']) { $monitors['ping']['status'] = 'suspended'; } } } $agent = MonitisHelper::in_array($this->allAgents['agents'], 'key', $server['hostname']); if ($agent) { if (isset($agent['status']) && $agent['status'] == 'running') { $info = $this->intMonitor($agent, $server['id']); if ($info) { $this->whmcsAllServers[$i]['agent_id'] = $info['agent_id']; //$int['agent_id']; $this->whmcsAllServers[$i]['agent_status'] = $info['status']; $monitors['cpu'] = $info['cpu']; $monitors['drive'] = $info['drive']; $monitors['memory'] = $info['memory']; } } elseif (isset($agent['status']) && $agent['status'] == 'stopped') { $this->whmcsAllServers[$i]['agent_id'] = $agent['id']; //$int['agent_id']; $this->whmcsAllServers[$i]['agent_status'] = $agent['status']; } } if ($monitors && count($monitors) > 0) { $this->whmcsAllServers[$i]['monitors'] = $monitors; } } if ($this->synchronize) { $this->unlinkedInternal(); } }