예제 #1
0
 static function update_config($vals)
 {
     if ($vals && isset($vals['apiKey']) && isset($vals['secretKey'])) {
         MonitisHelper::checkAdminName();
         self::$apiKey = $vals['apiKey'];
         self::$secretKey = $vals['secretKey'];
         self::$adminName = MonitisHelper::checkAdminName();
         $update = array('apiKey' => $vals['apiKey'], 'secretKey' => $vals['secretKey'], 'admin_name' => self::$adminName);
         $where = array('client_id' => MONITIS_CLIENT_ID);
         update_query(MONITIS_SETTING_TABLE, $update, $where);
         self::$settings["timezone"] = $vals['timezone'];
         self::$settings["order_behavior"] = self::setupBehavior(MONITIS_ORDER_BEHAVIOR);
         self::$settings["user_behavior"] = self::setupBehavior(MONITIS_USER_STATUS_BEHAVIOR);
         self::$parentDomain = MonitisHelper::parentDomain();
         self::$settings["parentDomain"] = self::$parentDomain;
         // set autoToken
         self::update_token();
         // setup notifications
         $oNot = new notificationsClass();
         $resp = $oNot->createDefaultGroup();
         self::update_settings(json_encode(self::$settings));
         // setup locations
         $locations = MonitisApiHelper::getExternalLocations();
         self::update_locations($locations);
     }
 }
예제 #2
0
<?php

$notifications = new notificationsClass();
if (isset($_POST['action'])) {
    switch ($_POST['action']) {
        case 'save_contacts':
            if (!isset($_POST['group_id']) || !isset($_POST['group_name']) || !isset($_POST['contacts_to_add']) || !isset($_POST['contacts_to_remove'])) {
                break;
            }
            $groupId = (int) $_POST['group_id'];
            $groupName = (int) $_POST['group_name'];
            $contactsToAdd = $_POST['contacts_to_add'] ? explode(',', $_POST['contacts_to_add']) : null;
            $contactsToRemove = $_POST['contacts_to_remove'] ? explode(',', $_POST['contacts_to_remove']) : null;
            if ($groupId == MonitisConf::$settings['groups']['external']['groupId']) {
                $monitorType = 'external';
            } elseif ($groupId == MonitisConf::$settings['groups']['internal']['groupId']) {
                $monitorType = 'internal';
            }
            $alertRules = MonitisApiHelper::getNotificationRuleByType($monitorType, $groupId);
            if (!$alertRules) {
                $alertRules = MonitisConf::$settings['groups'][$monitorType]['alert'];
            }
            if (is_array($contactsToRemove)) {
                foreach ($contactsToRemove as $contact) {
                    $contactInfo = $notifications->existContact($contact);
                    $ids = $notifications->getGroupIdsByContcatId($contactInfo['contactId']);
                    if (in_array($groupId, $ids)) {
                        $indexToRemove = array_search($groupId, $ids);
                        array_splice($ids, $indexToRemove, 1);
                    }
                    $params = array('contactId' => $contactInfo['contactId'], 'contactGroupIds' => implode(',', $ids), 'textType' => '0');
예제 #3
0
    $mtypes = explode(",", MONITIS_ADMIN_MONITOR_TYPES);
    $mprops = array('autocreate', 'available', 'suspendmsg');
    for ($i = 0; $i < count($mtypes); $i++) {
        $mtype = $mtypes[$i];
        for ($p = 0; $p < count($mprops); $p++) {
            if ($mprops[$p] == 'suspendmsg') {
                $newsets[$mtype][$mprops[$p]] = !isset($_POST[$mprops[$p] . '_' . $mtype]) ? 'Monitor suspended' : $_POST[$mprops[$p] . '_' . $mtype];
            } else {
                $newsets[$mtype][$mprops[$p]] = !isset($_POST[$mprops[$p] . '_' . $mtype]) ? 0 : 1;
            }
        }
    }
    $newsets_json = json_encode($newsets);
    MonitisConf::update_settings($newsets_json);
    if ($action_type == 'applyAll') {
        $oNot = new notificationsClass();
        $oNot->autoApplyAlertsToAll($_POST['apply_monitor_type']);
    }
    if ($isNewAcc) {
        MonitisApp::redirect(MONITIS_APP_URL . '&monitis_page=syncservers');
    }
} else {
    if ($isNewAcc) {
        MonitisApp::addMessage('Default monitor settings that will apply to newly provisioned servers.');
    }
}
$ping = MonitisConf::$settings['ping'];
$cpu = MonitisConf::$settings['cpu'][$newAgentPlatform];
$memory = MonitisConf::$settings['memory'][$newAgentPlatform];
$drive = MonitisConf::$settings['drive'];
$firstTime = $isNewAcc > 0 ? '&isNewAcc=1' : '';