예제 #1
0
 public function allSnapshots()
 {
     $whmcsExt = monitisWhmcsServer::ext_monitors();
     if ($whmcsExt) {
         $this->whmcs_ext_ids = MonitisHelper::idsByField($whmcsExt, 'monitor_id');
     }
     $this->whmcs_int = monitisWhmcsServer::int_monitors();
     if ($this->whmcs_int) {
         $this->intSnapshotsIds();
     }
 }
예제 #2
0
<?php

require_once '../modules/addons/monitis_addon/lib/serverslisttab.class.php';
$oSrvrs = new serversListTab();
if (isset($_POST['create_NewMonitors']) && $_POST['create_NewMonitors'] > 0) {
    if (isset($_POST['serverId'])) {
        $servers = array_map("intval", $_POST['serverId']);
        $srv_ids = MonitisHelper::idsByField($servers, '');
        $srv_ids_str = implode(",", $srv_ids);
        $srvs = monitisWhmcsServer::serverByIds($srv_ids_str);
        $ext = monitisWhmcsServer::extMonitorsByServerIds($srv_ids_str);
        $int = monitisWhmcsServer::intMonitorsByServerIds($srv_ids_str);
        $whmcs = array('ext' => $ext, 'int' => $int);
        MonitisConf::$settings['ping']['autocreate'] = 1;
        MonitisConf::$settings['cpu']['autocreate'] = 1;
        MonitisConf::$settings['memory']['autocreate'] = 1;
        for ($i = 0; $i < count($srvs); $i++) {
            $resp = MonitisApiHelper::addAllDefault(MONITIS_CLIENT_ID, $srvs[$i], $whmcs);
            $ping = $resp['ping'];
            $msg = 'Server ' . $srvs[$i][name] . ' - PING monitor: ' . $ping['msg'];
            if ($ping['status'] == 'error') {
                MonitisApp::addError($msg);
            } elseif ($ping['status'] == 'warning') {
                //MonitisApp::addWarning($msg);
            }
            if ($resp['agent']['status'] == 'ok') {
                $internalMonitors = $resp['internal_monitors'];
                foreach ($internalMonitors as $key => $val) {
                    $msg = 'Server ' . $srvs[$i][name] . ' - ' . strtoupper($key) . ' monitor: ' . $internalMonitors[$key]['msg'];
                    if ($internalMonitors[$key]['status'] == 'error') {
                        MonitisApp::addError($msg);
예제 #3
0
 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();
     }
 }