Beispiel #1
0
 public function getServerInfo($server_id)
 {
     $server = monitisWhmcsServer::serverInfo($server_id);
     // all linked ping monitors
     $this->whmcsExt = monitisWhmcsServer::extMonitorsByServerIds($server['id']);
     // get all ping monitors
     $this->allPings = MonitisApi::getExternalMonitors();
     if (@$this->allPings['status'] != 'error' && @$this->allPings['code'] != 101) {
         $this->pingsStatus = null;
         if ($this->allPings && isset($this->allPings['testList'])) {
             $this->allPings = $this->allPings['testList'];
             // get all ping monitors status
             $this->pingsStatus = MonitisApi::externalSnapshot();
         } else {
             $this->allPings = null;
         }
         // all linked internal monitors
         $this->whmcsInt = monitisWhmcsServer::intMonitorsByServerIds($server['id']);
         if (!$this->whmcsInt) {
             $this->whmcsInt = array();
         }
         $agent = $this->getAgent($server['hostname']);
         if ($agent && isset($agent['agentId'])) {
             $this->agentInfo = $agent;
             // get agent info
             $this->agentFullInfo = MonitisApi::getAgentInfo($agent['agentId'], true);
         }
         $server = $this->initServer($server);
     }
     return $server;
 }
Beispiel #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);
Beispiel #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();
     }
 }