Example #1
0
             MonitisApp::addError('This server agent does not have Memory');
         }
     }
     break;
 case 'drive':
     $hostname = $serverInfo['hostname'];
     $agents = MonitisApi::getAgent($hostname);
     $agentId = $agents[0]['id'];
     $agentKey = $agents[0]['key'];
     $platform = $agents[0]['platform'];
     $driveLetter = $_POST['driveLetter'];
     $freeLimit = $_POST['freeLimit'];
     if (isset($_POST['id'])) {
         $monitorId = (int) $_POST['id'];
         $params = array('testId' => $monitorId, 'freeLimit' => $freeLimit, 'name' => 'drive_' . $driveLetter . '@' . $serverInfo['hostname'], 'tag' => $serverInfo['hostname'] . '_whmcs');
         $resp = MonitisApi::editDriveMonitor($params);
         if ($resp) {
             if ($resp['status'] == 'ok') {
                 $pubKey = MonitisApi::monitorPublicKey(array('moduleType' => 'drive', 'monitorId' => $monitorId));
                 $values = array('server_id' => $serverInfo['id'], "available" => MonitisConf::$settings['drive']['available'], 'agent_id' => $agentId, 'monitor_id' => (int) $_POST['id'], 'monitor_type' => 'drive', 'client_id' => MONITIS_CLIENT_ID, "publickey" => $pubKey);
                 insert_query('mod_monitis_int_monitors', $values);
                 MonitisApp::addMessage('Drive Monitor successfully updated');
                 for ($i = 0; $i < count($serverInfo['agent']['drive']); $i++) {
                     if (isset($serverInfo['agent']['drive'][$i]['letter']) && $serverInfo['agent']['drive'][$i]['letter'] === $driveLetter) {
                         $serverInfo['agent']['drive'][$i] = $serverMonitors->getMonitor($monitorId, 'drive');
                     }
                 }
             } else {
                 MonitisApp::addError($resp['error']);
             }
         }