コード例 #1
0
 public function initServers()
 {
     $allSrvrsIds = MonitisHelper::idsByField($this->whmcsAllServers, 'id');
     $srvrsIds = implode(',', $allSrvrsIds);
     // all linked ping monitors
     $this->whmcsExt = monitisWhmcsServer::extMonitorsByServerIds($srvrsIds);
     // get all ping monitors
     $this->allPings = MonitisApi::getExternalMonitors();
     // if Monitis server ok
     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;
         }
         // remove unlinked ping monitors from whmcs
         if ($this->whmcsExt && $this->synchronize) {
             $this->unlinkedPings();
         } else {
             $this->whmcsExt = array();
         }
         // 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();
     }
 }
コード例 #2
0
ファイル: servermonitors.php プロジェクト: carriercomm/WHMCS
 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;
 }
コード例 #3
0
ファイル: billing.php プロジェクト: carriercomm/WHMCS
 public function planDetails($sss)
 {
     $result = array('clients' => 0, 'clientsMonitors' => 0, 'uptimeMonitors' => 0, 'locations' => 0, 'agents' => 0);
     /*
      * parent user info, plan
      */
     $params = array('loadUserPlan' => 'true');
     $userInfo = MonitisApi::userInfo($params);
     if (isset($userInfo['status']) && $userInfo['status'] == 'error' && isset($userInfo['code']) && $userInfo['code'] == 101) {
         return null;
     }
     $plan = array('roleName' => '', 'uptimePlan' => 0, 'intMonitors' => 0);
     if ($userInfo) {
         $roleName = $userInfo['plan']['roleName'];
         $basketItems = $userInfo['plan']['basketItems'];
         $plan['roleName'] = $roleName;
         if (strtoupper($roleName) == 'TRIAL') {
             $trial = MonitisHelper::in_array($basketItems, 'name', $roleName);
             if ($trial) {
                 $ext = MonitisHelper::in_array($trial['permissions'], 'actionId', $this->plans["uptimes"]["id"]);
                 // External monitoring / Uptime
                 $plan['uptimePlan'] = $ext['value'];
                 $int = MonitisHelper::in_array($trial['permissions'], 'actionId', $this->plans["servers"]["id"]);
                 // Server
                 $plan['serverPlan'] = $int['value'];
             }
         } else {
             $ext = $this->basketItemById($basketItems, $this->plans["uptimes"]["id"]);
             $plan['uptimePlan'] = $ext['quantity'];
             $int = $this->basketItemById($basketItems, $this->plans["servers"]["id"]);
             $plan['serverPlan'] = $int['quantity'];
         }
         $result['plan'] = $plan;
     }
     /*
      * clients info
      */
     $params = array('loadUserPlan' => 'true', 'loadMonitors' => 'true');
     $subUsers = MonitisApi::clientsList($params);
     $userMonitors = 0;
     for ($i = 0; $i < count($subUsers); $i++) {
         $userMonitors += count($subUsers[$i]['monitors']);
     }
     $result['clients'] = 0;
     if ($subUsers && count($subUsers) > 0) {
         $result['clients'] = count($subUsers);
     }
     $result['clientsMonitors'] = $userMonitors;
     /*
      * parent info
      * get all uptime monitors
      */
     $snapshots = MonitisApi::externalSnapshot();
     $result['uptimeMonitors'] = 0;
     if ($snapshots && count($snapshots) > 0) {
         $result['uptimeMonitors'] = count($snapshots);
     }
     /*
      * Server / Device monitors
      *
      */
     $agentsSnapshot = MonitisApi::allAgentsSnapshot('', true);
     if ($agentsSnapshot && isset($agentsSnapshot['agents'])) {
         $result['agents'] = count($agentsSnapshot['agents']);
     }
     $result['internalMonitors'] = 0;
     $internalMonitors = MonitisApi::getInternalMonitors();
     if ($internalMonitors) {
         if (isset($internalMonitors['cpus'])) {
             $result['internalMonitors'] += count($internalMonitors['cpus']);
         }
         if (isset($internalMonitors['memories'])) {
             $result['internalMonitors'] += count($internalMonitors['memories']);
         }
         if (isset($internalMonitors['drives'])) {
             $result['internalMonitors'] += count($internalMonitors['drives']);
         }
     }
     return $result;
 }