Пример #1
0
 static function addMemory($agentInfo, $memory)
 {
     $platform = $agentInfo['platform'];
     $params = array('agentkey' => $agentInfo['agentKey'], 'name' => 'memory@' . $agentInfo['name'], 'tag' => $agentInfo['name'] . '_whmcs', 'platform' => $agentInfo['platform']);
     foreach ($memory[$platform] as $key => $val) {
         $params[$key] = $val;
     }
     return MonitisApi::addMemoryMonitor($params);
 }
Пример #2
0
     } else {
         MonitisApp::addError($resp['error']);
     }
 } else {
     $hostname = $serverInfo['hostname'];
     $agents = MonitisApi::getAgent($hostname);
     if ($agents) {
         $agentKey = $agents[0]['key'];
         $platform = $agents[0]['platform'];
         $agentId = $agents[0]['id'];
         $params = array('agentkey' => $agentKey, 'name' => 'memory@' . $hostname, 'tag' => $hostname . '_whmcs', 'platform' => $platform);
         $memory = MonitisConf::$settings['memory'][$platform];
         foreach ($memory as $key => $val) {
             $params[$key] = isset($_POST[$key]) ? intval($_POST[$key]) : $memory[$key];
         }
         $resp = MonitisApi::addMemoryMonitor($params);
         if (isset($resp['data']) && isset($resp['data']['testId'])) {
             $memory_monitorId = $resp['data']['testId'];
             $pubKey = MonitisApi::monitorPublicKey(array('moduleType' => 'memory', 'monitorId' => $memory_monitorId));
             $values = array("server_id" => $serverInfo['id'], "available" => MonitisConf::$settings['memory']['available'], "monitor_id" => $memory_monitorId, "agent_id" => $agentId, "monitor_type" => 'memory', "client_id" => MONITIS_CLIENT_ID, "publickey" => $pubKey);
             insert_query('mod_monitis_int_monitors', $values);
             MonitisApp::addMessage('Memory Monitor successfully created');
             $serverInfo['agent']['memory'] = $serverMonitors->getMonitor($resp['data']['testId'], 'memory');
         } else {
             MonitisApp::addError($resp['error']);
         }
     } else {
         MonitisApp::addError('This server agent does not have Memory');
     }
 }
 break;