public function getAgentMonitorsById($agentId) { $this->agentInfo = null; $agents = MonitisApi::allAgentsSnapshot($agentId); if ($agents) { $agent = $agents['agents'][0]; $this->agentInfo = array('agentKey' => $agent['key'], 'agentId' => $agent['id'], 'name' => $agent['key'], 'tag' => $agent['key'] . '_whmcs', 'platform' => $agent['platform']); if (isset($agent['cpu'])) { $this->agentInfo['cpu'] = $agent['cpu']; } if (isset($agent['memory'])) { $this->agentInfo['memory'] = $agent['memory']; } if (isset($agent['drives'])) { $this->agentInfo['drives'] = $agent['drives']; } } return $this->agentInfo; }
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(); } }
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; }