/**
  * Naplní diagram
  */
 function fillUp()
 {
     $members = $this->hostgroup->getDataValue('members');
     $host = new IEHost();
     $hosts = $host->getColumnsFromMySQL(array('alias', 'address', 'parents', 'notifications_enabled', 'active_checks_enabled', 'passive_checks_enabled', '3d_coords', $host->myCreateColumn, $host->myLastModifiedColumn, $host->nameColumn, $host->myKeyColumn), 'host_id IN ( ' . implode(',', array_keys($members)) . ' )');
     foreach ($hosts as $hostNo => $host_info) {
         if (strstr($host_info['3d_coords'], ',')) {
             list($x, $y, $z) = explode(',', $host_info['3d_coords']);
         } else {
             $x = $y = 0;
         }
         if (strlen(trim($host_info['parents']))) {
             $host_info['parents'] = unserialize($host_info['parents']);
         }
         if (isset($host_info[$host->nameColumn])) {
             $name = $host_info[$host->nameColumn];
         } else {
             continue;
         }
         $alias = $host_info['alias'];
         $color = '';
         if ($host_info['active_checks_enabled']) {
             $color = 'lightgreen';
         }
         if ($host_info['passive_checks_enabled']) {
             $color = 'lightblue';
         }
         $this->addNode($name, array('id' => 'host_' . $host_info[$host->myKeyColumn], 'node_id' => $host_info[$host->myKeyColumn], 'color' => $color, 'x' => $x, 'y' => $y, 'fixed' => boolval($x + $y), 'shape' => 'point', 'style' => 'filled', 'tooltip' => $alias, 'label' => $name));
         if (isset($host_info[$host->nameColumn])) {
             if (is_array($host_info['parents'])) {
                 foreach ($host_info['parents'] as $parent_name) {
                     $this->addEdge(array($host_info[$host->nameColumn] => $parent_name));
                 }
             }
         }
     }
 }
Example #2
0
 public function delete($id = null)
 {
     if (is_null($id)) {
         $id = $this->getId();
     }
     if ($id != $this->getId()) {
         $this->loadFromMySQL($id);
     }
     $userGroup = new IEUserGroup();
     $userGroup->delUser($id);
     $command = new IECommand();
     $myCommand = $command->getOwned($id);
     if ($myCommand) {
         foreach ($myCommand as $command_id => $cmd) {
             $command->loadFromMySQL((int) $command_id);
             $command->delete();
         }
     }
     $contact = new IEContact();
     $myContact = $contact->getOwned($id);
     if ($myContact) {
         foreach ($myContact as $contact_id => $cmd) {
             if ($contact->loadFromMySQL((int) $contact_id)) {
                 $contact->delete();
             }
         }
     }
     $contactgroup = new IEContactgroup();
     $myContactgroup = $contactgroup->getOwned($id);
     if ($myContactgroup) {
         foreach ($myContactgroup as $contactgroup_id => $cmd) {
             $contactgroup->loadFromMySQL((int) $contactgroup_id);
             $contactgroup->delete();
         }
     }
     $hostgroup = new IEHostgroup();
     $myHostgroup = $hostgroup->getOwned($id);
     if ($myHostgroup) {
         foreach ($myHostgroup as $hostgroup_id => $cmd) {
             $hostgroup->loadFromMySQL((int) $hostgroup_id);
             $hostgroup->delete();
         }
     }
     $host = new IEHost();
     $myHost = $host->getOwned($id);
     if ($myHost) {
         foreach ($myHost as $host_id => $cmd) {
             $host->loadFromMySQL((int) $host_id);
             $host->delete();
         }
     }
     $servicegroup = new IEServicegroup();
     $myServicegroup = $servicegroup->getOwned($id);
     if ($myServicegroup) {
         foreach ($myServicegroup as $servicegroup_id => $cmd) {
             $servicegroup->loadFromMySQL((int) $servicegroup_id);
             $servicegroup->delete();
         }
     }
     $service = new IEService();
     $myService = $service->getOwned($id);
     if ($myService) {
         foreach ($myService as $service_id => $cmd) {
             $service->loadFromMySQL((int) $service_id);
             $service->delete();
         }
     }
     $timeperiod = new IETimeperiod();
     $myTimeperiod = $timeperiod->getOwned($id);
     if ($myTimeperiod) {
         foreach ($myTimeperiod as $timeperiod_id => $cmd) {
             $timeperiod->loadFromMySQL((int) $timeperiod_id);
             $timeperiod->delete();
         }
     }
     $cfgfile = constant('CFG_GENERATED') . '/' . $this->getUserLogin() . '.cfg';
     if (file_exists($cfgfile)) {
         if (unlink($cfgfile)) {
             $this->addStatusMessage(sprintf(_('Konfigurace uživatele %s byla smazána'), $this->getUserLogin()), 'success');
         } else {
             $this->addStatusMessage(sprintf(_('Konfigurace uživatele %s nebyla smazána'), $this->getUserLogin()), 'error');
         }
     }
     if ($this->deleteFromMySQL()) {
         $this->addStatusMessage(sprintf(_('Uživatel %s byl smazán'), $this->getUserLogin()));
         require_once 'Ease/EaseMail.php';
         $email = new EaseMail($this->getDataValue('email'), _('Oznámení o zrušení účtu'));
         $email->setMailHeaders(array('From' => EMAIL_FROM));
         $email->addItem(new EaseHtmlDivTag(null, "Právě jste byl/a smazán/a z Aplikace VSMonitoring s těmito přihlašovacími údaji:\n"));
         $email->addItem(new EaseHtmlDivTag(null, ' Login: ' . $this->GetUserLogin() . "\n"));
         $email->send();
         return true;
     } else {
         return FALSE;
     }
 }
Example #3
0
 /**
  * Vytvoří nového hosta patřícího rovnou do výchozí skupiny uživatele
  *
  * @param array $data asiciativní pole dat
  *
  * @return int|null id nově vloženého řádku nebo null, pokud se data
  * nepovede vložit
  */
 public function insertToMySQL($data = null)
 {
     if (!is_null($data)) {
         $this->takeData($data);
     }
     $hostgroup = new IEHostgroup($this->user->getUserLogin());
     $this->addMember('hostgroups', $hostgroup->getId(), $hostgroup->getName());
     return parent::insertToMySQL();
 }
Example #4
0
    $warning = $oPage->columnII->addItem(new EaseHtmlDivTag('Contactgroup', _('Nemáte definovanou skupinu kontaktů'), array('class' => 'alert alert-info')));
    $warning->addItem(new EaseTWBLinkButton('contactgroup.php', _('Založit první skupinu kontaktů ' . EaseTWBPart::GlyphIcon('edit'))));
}
$host = new IEHost();
$pocHostu = $host->getMyRecordsCount();
if ($pocHostu) {
    $success = $oPage->columnI->addItem(new EaseHtmlDivTag('Host', new EaseTWBLinkButton('hosts.php', _('<i class="icon-list"></i>') . ' ' . sprintf(_('Definováno %s hostů'), $pocHostu)), array('class' => 'alert alert-success')));
} else {
    if ($pocTimeperiods) {
        $warning = $oPage->columnI->addItem(new EaseHtmlDivTag('Host', _('Nemáte definovaný žádný host'), array('class' => 'alert alert-info')));
        $warning->addItem(new EaseTWBLinkButton('host.php', _('Založit první host') . ' ' . EaseTWBPart::GlyphIcon('edit')));
    } else {
        $warning = $oPage->columnI->addItem(new EaseHtmlDivTag('Host', _('Hosty vyžadují časovou periodu ..'), array('class' => 'alert alert-danger')));
    }
}
$hostgroup = new IEHostgroup();
$pocHostgroups = $hostgroup->getMyRecordsCount();
if ($pocHostgroups) {
    $success = $oPage->columnI->addItem(new EaseHtmlDivTag('Hostgroup', new EaseTWBLinkButton('hostgroups.php', _('<i class="icon-list"></i>') . ' ' . sprintf(_('Definováno %s skupin hostů'), $pocHostgroups)), array('class' => 'alert alert-success')));
} else {
    $warning = $oPage->columnI->addItem(new EaseHtmlDivTag('Host', _('Nemáte definovaný žádnou skupinu hostů'), array('class' => 'alert alert-info')));
    $warning->addItem(new EaseTWBLinkButton('hostgroup.php', _('Založit první skupinu hostů <i class="icon-edit"></i>')));
}
$command = new IECommand();
$PocCommands = $command->getMyRecordsCount();
if ($PocCommands) {
    $success = $oPage->columnIII->addItem(new EaseHtmlDivTag('Command', new EaseTWBLinkButton('commands.php', _('<i class="icon-list"></i>') . ' ' . sprintf(_('Definováno %s příkazů'), $PocCommands)), array('class' => 'alert alert-success')));
} else {
    $warning = $oPage->columnIII->addItem(new EaseHtmlDivTag('Host', _('Nemáte definovaný žádné příkazy'), array('class' => 'alert alert-info')));
    $warning->addItem(new EaseTWBLinkButton('importcommand.php', _('Importovat příkazy') . ' <i class="icon-download"></i>'));
}
Example #5
0
 /**
  * Smaže hostgrupu i její použití v hostech
  *
  * @param int $id
  * @return boolean
  */
 function delete($id = null)
 {
     if (isset($id) && $this->getId() != $id) {
         $this->loadFromSQL($id);
     } else {
         $id = $this->getId();
     }
     $host = new IEHost();
     $hosts = $host->getColumnsFromMySQL(array($host->myKeyColumn), array('hostgroups' => '%' . $this->getName() . '%'));
     foreach ($hosts as $hostInfo) {
         $hostId = intval(current($hostInfo));
         $host->loadFromMySQL($hostId);
         $hostgroupNames = $host->getDataValue('hostgroups');
         if ($hostgroupNames) {
             foreach ($hostgroupNames as $hostgroupId => $hostgroupName) {
                 if ($hostgroupId == $this->getId()) {
                     if ($host->delMember('hostgroups', $hostgroupId, $hostgroupName)) {
                         $this->addStatusMessage(sprintf(_('host %s byl odstraněn ze skupiny %s'), $host->getName(), $hostgroupName), 'success');
                     } else {
                         $this->addStatusMessage(sprintf(_('host %s byl odstraněn ze skupiny %s'), $host->getName(), $hostgroupName), 'error');
                     }
                 }
             }
         }
     }
     $subgroup = new IEHostgroup();
     $subgroups = $subgroup->getColumnsFromMySQL(array($subgroup->myKeyColumn), array('hostgroup_members' => '%' . $this->getName() . '%'));
     foreach ($subgroups as $subgroupInfo) {
         $subgroupId = intval(current($subgroupInfo));
         $subgroup->loadFromMySQL($subgroupId);
         $subgroupgroupNames = $subgroup->getDataValue('hostgroup_members');
         if ($subgroupgroupNames) {
             foreach ($subgroupgroupNames as $subgroupgroupId => $subgroupgroupName) {
                 if ($subgroupgroupId == $this->getId()) {
                     if ($subgroup->delMember('hostgroup_members', $subgroupgroupId, $subgroupgroupName)) {
                         $this->addStatusMessage(sprintf(_('subgroup %s byl odstraněn ze skupiny %s'), $subgroup->getName(), $subgroupgroupName), 'success');
                     } else {
                         $this->addStatusMessage(sprintf(_('subgroup %s byl odstraněn ze skupiny %s'), $subgroup->getName(), $subgroupgroupName), 'error');
                     }
                 }
             }
         }
     }
     return parent::delete($id);
 }
$oPage->onlyForLogged();
$hostName = trim($oPage->getRequestValue('host_name'));
$platform = trim($oPage->getRequestValue('platform'));
$host_group = $oPage->getRequestValue('host_group', 'int');
$host = new IEHost();
$host->owner =& $oUser;
if ($hostName && $platform) {
    $host->setData(array($host->userColumn => $oUser->getUserID(), 'host_name' => $hostName, 'use' => 'generic-host', 'platform' => 'generic', 'register' => true, 'generate' => TRUE, 'platform' => $platform, 'alias' => $hostName, 'active_checks_enabled' => 0, 'passive_checks_enabled' => 1, 'check_freshness' => 1, 'freshness_threshold' => 900, 'flap_detection_enabled' => 0, 'check_command' => 'return-unknown'));
    if ($host_group) {
        $hostgroup = new IEHostgroup($host_group);
        $host->addMember('hostgroups', $hostgroup->getId(), $hostgroup->getName());
        $hostgroup->addMember('members', $host->getId(), $host->getName());
        $hostgroup->saveToMySQL();
    }
    if ($host->saveToMysql()) {
        $hostGroup = new IEHostgroup();
        if ($hostGroup->loadDefault()) {
            $hostGroup->setDataValue($hostGroup->nameColumn, EaseShared::user()->getUserLogin());
            $hostGroup->addMember('members', $host->getId(), $host->getName());
            $hostGroup->saveToMySQL();
            $host->addMember('hostgroups', $hostGroup->getId(), $hostGroup->getName());
            $host->saveToMysql();
        }
        $oPage->redirect('host.php?host_id=' . $host->getId());
        exit;
    }
} else {
    if ($oPage->isPosted()) {
        $oPage->addStatusMessage(_('Prosím zastejte název sledovaného hosta'), 'warning');
    }
}
Example #7
0
 /**
  * Add Groups/Hosts into menu
  *
  * @param IEBootstrapMenu $nav
  */
 private function groupsHostsMenu($nav)
 {
     EaseShared::webPage()->addCss('.dropdown-menu { overflow-y: auto } ');
     EaseShared::webPage()->addJavaScript("\$('.dropdown-menu').css('max-height',\$(window).height()-100);", null, true);
     $user = EaseShared::user();
     $host = new IEHost();
     $hosts = $host->getListing(null, null, array('icon_image', 'platform'));
     $hostsNotInGroup = array();
     $hnames = array();
     foreach ($hosts as $hID => $hInfo) {
         $hnames[$hInfo['host_name']] =& $hosts[$hID];
         $hostsNotInGroup[$hInfo['host_name']] = $hInfo;
     }
     $topItems = array('wizard-host.php' => EaseTWBPart::GlyphIcon('forward') . ' ' . _('Průvodce založením hostu'));
     $topItems['wizard-active-host.php'] = EaseTWBPart::GlyphIcon('star') . ' ' . _('Nový aktivní Host');
     $hostgroup = new IEHostgroup();
     $topItems['hostgroup.php'] = EaseTWBPart::GlyphIcon('plus') . ' ' . _('Nová skupina hostů');
     /* ,
        'exthostinfo.php' => _('Rozšířené informace hostů'),
        'hostdependency.php' => _('Závislosti hostů'),
        'hostescalation.php' => _('Eskalace hostů') */
     $pocHostgroup = $hostgroup->getMyRecordsCount();
     $hostGroupMenuItem = array();
     if ($pocHostgroup) {
         //$hostgroups = $hostgroup->myDbLink->queryToArray('SELECT ' . $hostgroup->getmyKeyColumn() . ', hostgroup_name, DatSave FROM ' . $hostgroup->myTable . ' WHERE user_id=' . $user->getUserID(), 'hostgroup_id');
         $hostgroups = $hostgroup->getListing(null, null, array('members'));
         foreach ($hostgroups as $cID => $hgInfo) {
             $hostGroupMenuItem['hostgroup.php?hostgroup_id=' . $hgInfo['hostgroup_id']] = EaseTWBPart::GlyphIcon('cloud') . ' ' . $hgInfo['hostgroup_name'];
             if (count($hgInfo['members'])) {
                 foreach ($hgInfo['members'] as $hgMember) {
                     if ($hgMember == '*') {
                         $image = null;
                     } else {
                         $hInfo =& $hnames[$hgMember];
                         $image = $hInfo['icon_image'];
                         unset($hostsNotInGroup[$hgMember]);
                     }
                     if (!$image) {
                         $image = 'unknown.gif';
                     }
                     if (isset($hInfo) && !is_null($hInfo)) {
                         $hostGroupMenuItem['host.php?host_id=' . $hInfo['host_id']] = '&nbsp;' . new IEHostIcon($hInfo) . ' ' . $hInfo['host_name'] . ' ' . new IEPlatformIcon($hInfo['platform']);
                     }
                 }
             }
         }
         $topItems['hostgroups.php'] = EaseTWBPart::GlyphIcon('list-alt') . ' ' . _('Přehled skupin hostů');
     } else {
         if (count($hostGroupMenuItem)) {
             $hostGroupMenuItem[] = '';
         }
     }
     if (count($hostsNotInGroup)) {
         foreach ($hostsNotInGroup as $menuHost) {
             $hostGroupMenuItem['host.php?host_id=' . $menuHost['host_id']] = '&nbsp;' . new IEHostIcon($menuHost) . ' ' . $menuHost['host_name'] . ' ' . new IEPlatformIcon($menuHost['platform']);
         }
     }
     $topItems['hosts.php'] = EaseTWBPart::GlyphIcon('list') . ' ' . _('Detailní přehled hostů');
     $topItems['map.php'] = EaseTWBPart::GlyphIcon('globe') . ' ' . _('Topologie');
     $nav->addDropDownMenu(_('Hosti'), array_merge($topItems, array('' => ''), $hostGroupMenuItem));
 }
Example #8
0
 function fixHostHostgroupID()
 {
     $hostgroupsOK = array();
     $hostgroupsErr = array();
     $host = new IEHost();
     $hostgroup = new IEHostgroup();
     $hosts = $host->getColumnsFromMySQL(array($host->myKeyColumn));
     foreach ($hosts as $hostInfo) {
         $hostId = intval(current($hostInfo));
         $host->loadFromMySQL($hostId);
         $hostgroupNames = $host->getDataValue('hostgroups');
         if ($hostgroupNames) {
             foreach ($hostgroupNames as $hostgroupId => $hostgroupName) {
                 $hostgroupFound = $hostgroup->loadFromMySQL($hostgroupName);
                 if ($hostgroupId != $hostgroup->getId()) {
                     if ($host->delMember('hostgroups', $hostgroupId, $hostgroupName) && $host->addMember('hostgroups', $hostgroup->getId(), $hostgroupName)) {
                         $hostgroupsOK[] = $hostgroupName;
                     } else {
                         $hostgroupsErr[] = $hostgroupName;
                     }
                 }
             }
         }
         if (count($hostgroupsOK)) {
             if ($host->saveToMySQL()) {
                 $this->addItemSmart(sprintf(_('<strong>%s</strong> : %s'), $host->getName(), implode(',', $hostgroupsOK)), array('class' => 'list-group-item'));
                 $this->addStatusMessage(sprintf(_('%s : %s'), $host->getName(), implode(',', $hostgroupsOK)), 'success');
                 $hostgroupsOK = array();
             }
         }
     }
 }
Example #9
0
<?php

/**
 * Icinga Editor - skupina hostů
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$hostgroup = new IEHostgroup($oPage->getRequestValue('hostgroup_id', 'int'));
switch ($oPage->getRequestValue('action')) {
    case 'contactAsign':
        $contact = new IEContact($oPage->getRequestValue('contact_id', 'int'));
        if ($contact->getId()) {
            $host = new IEHost();
            $groupMembers = $hostgroup->getMembers();
            foreach ($groupMembers as $gmID => $hostName) {
                $host->loadFromSQL((int) $gmID);
                $host->addMember('contacts', $contact->getId(), $contact->getName());
                if ($host->saveToMySQL()) {
                    $host->addStatusMessage(sprintf(_('<strong>%s</strong> byl přidán mezi kontakty <strong>%s</strong>'), $contact->getName(), $host->getName()), 'success');
                } else {
                    $host->addStatusMessage(sprintf(_('<strong>%s</strong> nebyl přidán mezi kontakty <strong>%s</strong>'), $contact->getName(), $host->getName()), 'warning');
                }
            }
        } else {
            $hostgroup->addStatusMessage(_('Chyba přiřazení kontaktu'), 'warning');
        }
Example #10
0
 * Icinga Editor - titulní strana
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
$oPage->onlyForLogged();
$oPage->addPageColumns();
$userID = $oPage->getRequestValue('user_id', 'int');
if ($userID) {
    $oPage->onlyForAdmin();
}
$host = new IEHost();
$hostgroup = new IEHostgroup();
$contact = new IETimeperiod();
$command = new IECommand();
$service = new IEService();
$serviceGroup = new IEServicegroup();
$ownership = $oPage->getRequestValue('ownership');
if ($ownership) {
    $host->switchOwners($userID, $ownership);
    $hostgroup->switchOwners($userID, $ownership);
    $contact->switchOwners($userID, $ownership);
    $command->switchOwners($userID, $ownership);
    $service->switchOwners($userID, $ownership);
    $serviceGroup->switchOwners($userID, $ownership);
    $oPage->addStatusMessage(_('Vlastnictví byla předána'));
}
$user = new IEUser($userID);
Example #11
0
    $ip = $oPage->getRequestValue('ip');
    if (!$ip) {
        $destHost = new IEHost($oPage->getRequestValue('dest_host_id', 'int'));
        $ip = $destHost->getDataValue('address');
    }
    $forceIP = true;
} else {
    $forceIP = false;
}
if (is_null($hostId) || !$ip) {
    $oPage->container->addItem(endRouteForm($host));
} else {
    $defaultContactId = $oUser->getDefaultContact()->getId();
    $defaultContactName = $oUser->getDefaultContact()->getName();
    $hgName = sprintf(_('Cesta k %s'), $host->getName());
    $hostGroup = new IEHostgroup($hgName);
    if ($hostGroup->getId()) {
    } else {
        $hostGroup->setUpUser($oUser);
        $hostGroup->setName($hgName);
    }
    $listing = new EaseHtmlOlTag();
    $infopanel = $oPage->container->addItem(new EaseTWBPanel($hostGroup->getName(), 'info', $listing));
    $trace = array();
    //??? $mtr = shell_exec('mtr -4 --no-dns -c 1 -p   ' . $ip);
    $mtr = shell_exec('traceroute -n -w 1 ' . $ip);
    $mtrlines = explode("\n", $mtr);
    foreach ($mtrlines as $mtrline) {
        $linea = explode(' ', trim($mtrline));
        if ($linea[0] == 'traceroute' || !isset($linea[2])) {
            continue;
            if ($mailID) {
                $oUser->addStatusMessage(_('Mailový kontakt byl založen'), 'success');
            } else {
                $oUser->addStatusMessage(_('Mailový kontakt nebyl založen'), 'warning');
            }
            $contactGroup = new IEContactgroup();
            $contactGroup->setData(array('contactgroup_name' => _('Skupina') . '_' . $login, 'alias' => _('Skupina') . '_' . $login, 'generate' => true, $contactGroup->userColumn => $userID));
            $contactGroup->addMember('members', $contactID, $login);
            $contactGroup->addMember('members', $mailID, $contact->getName());
            $cgID = $contactGroup->saveToMySQL();
            if ($cgID) {
                $oUser->addStatusMessage(_('Prvotní kontaktní skupina byla založena'), 'success');
            } else {
                $oUser->addStatusMessage(_('Prvotní kontaktní skupina nebyla založena'), 'warning');
            }
            $hostGroup = new IEHostgroup();
            $hostGroup->setName($newOUser->getUserLogin());
            $hostGroup->setDataValue('alias', _('Výchozí skupina') . ' ' . $newOUser->getUserLogin());
            $hostGroup->setDataValue('generate', true);
            $hostGroup->setUpUser($newOUser);
            $hostGroup->insertToMySQL();
            $oPage->redirect('wizard-host.php');
            exit;
        } else {
            $oUser->addStatusMessage(_('Zápis do databáze se nezdařil!'), 'error');
            $email = $oPage->addItem(new EaseMail(constant('SEND_ORDERS_TO'), 'Registrace uzivatel se nezdařila'));
            $email->addItem(new EaseHtmlDivTag('Fegistrace', $oPage->PrintPre($CustomerData)));
            $email->send();
        }
    }
}