Ejemplo n.º 1
0
 static function externalSnapShots(&$whmcsExt, $server)
 {
     $ext = null;
     $allPings = MonitisApi::getExternalMonitors();
     if (isset($allPings['testList'])) {
         $allPings = $allPings['testList'];
         $ping = MonitisHelper::in_array($allPings, 'url', $server['ipaddress']);
         if ($ping) {
             $monitorId = $ping['id'];
             $ext = MonitisHelper::in_array($whmcsExt, 'monitor_id', $monitorId);
             if (!$ext) {
                 // link monitor
                 $ext = self::linkPingMonitor($monitorId, 'ping', $server['id']);
             }
             $ext['isSuspended'] = $ping['isSuspended'];
         } elseif ($whmcsExt && count($whmcsExt) > 0 && @$allPings['status'] != 'error' && @$allPings['code'] != 101) {
             for ($i = 0; $i < count($whmcsExt); $i++) {
                 monitisSqlHelper::altQuery('DELETE FROM ' . MONITIS_EXTERNAL_TABLE . ' WHERE monitor_id=' . $whmcsExt[$i]['monitor_id']);
             }
         }
     }
     return $ext;
 }
Ejemplo n.º 2
0
 public function getServerInfo($server_id)
 {
     $server = monitisWhmcsServer::serverInfo($server_id);
     // all linked ping monitors
     $this->whmcsExt = monitisWhmcsServer::extMonitorsByServerIds($server['id']);
     // get all ping monitors
     $this->allPings = MonitisApi::getExternalMonitors();
     if (@$this->allPings['status'] != 'error' && @$this->allPings['code'] != 101) {
         $this->pingsStatus = null;
         if ($this->allPings && isset($this->allPings['testList'])) {
             $this->allPings = $this->allPings['testList'];
             // get all ping monitors status
             $this->pingsStatus = MonitisApi::externalSnapshot();
         } else {
             $this->allPings = null;
         }
         // all linked internal monitors
         $this->whmcsInt = monitisWhmcsServer::intMonitorsByServerIds($server['id']);
         if (!$this->whmcsInt) {
             $this->whmcsInt = array();
         }
         $agent = $this->getAgent($server['hostname']);
         if ($agent && isset($agent['agentId'])) {
             $this->agentInfo = $agent;
             // get agent info
             $this->agentFullInfo = MonitisApi::getAgentInfo($agent['agentId'], true);
         }
         $server = $this->initServer($server);
     }
     return $server;
 }
Ejemplo n.º 3
0
 public function initServers()
 {
     $allSrvrsIds = MonitisHelper::idsByField($this->whmcsAllServers, 'id');
     $srvrsIds = implode(',', $allSrvrsIds);
     // all linked ping monitors
     // get all ping monitors
     $this->allPings = MonitisApi::getExternalMonitors();
     // if Monitis server ok
     if (@$this->allPings['status'] != 'error' && @$this->allPings['code'] != 101) {
         // remove unlinked ping monitors from whmcs
         $this->whmcsExt = monitisWhmcsServer::extMonitorsByServerIds($srvrsIds);
         if ($this->allPings && isset($this->allPings['testList'])) {
             // get all ping monitors
             $this->allPings = $this->allPings['testList'];
         } else {
             $this->allPings = null;
         }
         // remove unlinked ping monitors from whmcs
         if ($this->whmcsExt) {
             $this->unlinkedPings();
         }
         // all linked internal monitors
         $this->whmcsInt = monitisWhmcsServer::intMonitorsByServerIds($srvrsIds);
         if (!$this->whmcsInt) {
             $this->whmcsInt = array();
         }
         // get agents
         $this->allAgents = MonitisApi::allAgentsSnapshot('', true);
         $this->init_all_servers();
     }
 }