Пример #1
0
 public function getMonitor($monitorId, $type)
 {
     $resp = null;
     if ($monitorId && $monitorId > 0) {
         if ($type == 'cpu') {
             $resp = MonitisApi::getCPUMonitor($monitorId);
             $resp = $this->whmcsInfo($resp, $monitorId, 'internal');
         } elseif ($type == 'memory') {
             $resp = MonitisApi::getMemoryInfo($monitorId);
             $resp = $this->whmcsInfo($resp, $monitorId, 'internal');
         } elseif ($type == 'drive') {
             $resp = MonitisApi::getDriveInfo($monitorId);
             $resp = $this->whmcsInfo($resp, $monitorId, 'internal');
         } elseif ($type == 'ping' || $type == 'external') {
             $ping = MonitisApi::getExternalMonitorInfo($monitorId);
             $locs = array();
             $intervals = array();
             for ($i = 0; $i < count($ping['locations']); $i++) {
                 $locs[] = $ping['locations'][$i]['id'];
                 $intervals[] = $ping['locations'][$i]['checkInterval'];
             }
             $ping['locations'] = implode(',', $locs);
             $ping['intervals'] = implode(',', $intervals);
             $ping['id'] = $monitorId;
             $resp = $this->whmcsInfo($ping, $monitorId, 'external');
         }
     }
     return $resp;
 }
Пример #2
0
         if (isset($resp['data']) && isset($resp['data']['testId'])) {
             $newId = $resp['data']['testId'];
             $publicKey = MonitisApi::monitorPublicKey(array('moduleType' => 'external', 'monitorId' => $newId));
             $values = array('server_id' => $serverInfo['id'], 'available' => MonitisConf::$settings['ping']['available'], 'monitor_id' => $newId, 'monitor_type' => 'ping', 'client_id' => MONITIS_CLIENT_ID, 'publickey' => $publicKey);
             insert_query('mod_monitis_ext_monitors', $values);
             MonitisApp::addMessage('Ping Monitor successfully created');
             $serverInfo['ping'] = $serverMonitors->getMonitor($resp['data']['testId'], 'ping');
         } else {
             MonitisApp::addError($resp['error']);
         }
     }
     break;
 case 'cpu':
     if (isset($_POST['id'])) {
         $monitorId = (int) $_POST['id'];
         $monitor = MonitisApi::getCPUMonitor($monitorId);
         $platform = $monitor['agentPlatform'];
         $params = array('testId' => $monitorId, 'name' => 'cpu@' . $serverInfo['hostname'], 'tag' => $serverInfo['hostname'] . '_whmcs');
         $cpu = MonitisConf::$settings['cpu'][$platform];
         foreach ($cpu as $key => $val) {
             $params[$key] = isset($_POST[$key]) ? intval($_POST[$key]) : $cpu[$key];
         }
         $resp = MonitisApi::editCPUMonitor($params);
         if ($resp && $resp['status'] == 'ok') {
             MonitisApp::addMessage('CPU Monitor successfully updated');
             $serverInfo['agent']['cpu'] = $serverMonitors->getMonitor($monitorId, 'cpu');
         } else {
             MonitisApp::addError($resp['error']);
         }
     } else {
         $hostname = $serverInfo['hostname'];