Nagvis provides powerful visual representation of status of monitored devices.
Offical site: http://www.nagvis.org/
Graphviz package is needed:
yum install graphviz graphviz-gd graphviz-php
Source used: nagvis-1.5.10 from http://www.nagvis.org/downloads
Extract and run the install.sh script to install it:
tar zxvf nagvis-1.5.10.tar.gz cd cd nagvis-1.5.1 ./install.sh -B /usr/sbin/nagios -m /usr/local/bin/ndo2db
./install.sh -B /usr/sbin/nagios -m /usr/local/bin/ndo2db +------------------------------------------------------------------------------+ | Welcome to NagVis Installer 0.2.17 | +------------------------------------------------------------------------------+ | This script is built to facilitate the NagVis installation and update | | procedure for you. The installer has been tested on the following systems: | | - Debian Etch, Hardy (4.0, 5.0) | | - Ubuntu Hardy, Intrepid, Jaunty, Karmic, Lucid (8.04 to 10.04) | | - SuSE Linux Enterprise Server 10 and 11 | | | | Similar distributions to the ones mentioned above should work as well. | | That (hopefully) includes RedHat, Fedora, CentOS, OpenSuSE | | | | If you experience any problems using these or other distributions, please | | report that to the NagVis team. | +------------------------------------------------------------------------------+ | Do you want to proceed? [y]: +------------------------------------------------------------------------------+ | Starting installation of NagVis 1.5.10 | +------------------------------------------------------------------------------+ | OS : CentOS release 5.7 (Final) | | Perl: 5.008008 | | | +--- Checking for tools -------------------------------------------------------+ | Using packet manager /bin/rpm found | | | +--- Checking paths -----------------------------------------------------------+ | Please enter the path to the nagios base directory [/usr/sbin/nagios]: /usr/share/nagios | nagios path /usr/share/nagios found | | Please enter the path to NagVis base [/usr/sbin/nagvis]: /usr/share/nagvis | | +--- Checking prerequisites ---------------------------------------------------+ | Nagios Core 3.2.2 found | | PHP 5.1 found | | PHP Module: gd php found | | PHP Module: mbstring php found | | PHP Module: gettext compiled_in found | | PHP Module: session compiled_in found | | PHP Module: xml php found | | Apache mod_php found | | Checking Backends. (Available: mklivestatus,ndo2db,ido2db,merlinmy) | | Do you want to use backend mklivestatus? [y]: n | Do you want to use backend ndo2db? [n]: y | Do you want to use backend ido2db? [n]: n | Do you want to use backend merlinmy? [n]: n | /usr/local/bin/ndo2db (ndo2db) found | | PHP Module: mysql php found | | Graphviz 2.12 found | | Error: Version >= 2.14 needed | Graphviz Module dot 2.12 found | | Error: Version >= 2.14 needed | Graphviz Module neato 2.12 found | | Error: Version >= 2.14 needed | Graphviz Module twopi 2.12 found | | Error: Version >= 2.14 needed | Graphviz Module circo 2.12 found | | Error: Version >= 2.14 needed | Graphviz Module fdp 2.12 found | | Error: Version >= 2.14 needed | | +--- Trying to detect Apache settings -----------------------------------------+ | Please enter the web path to NagVis [/nagvis]: | Please enter the name of the web-server user [apache]: | Please enter the name of the web-server group [apache]: | create Apache config file [y]: | | +--- Checking for existing NagVis ---------------------------------------------+ | | +------------------------------------------------------------------------------+ | Summary | +------------------------------------------------------------------------------+ | NagVis home will be: /usr/share/nagvis | | Owner of NagVis files will be: apache | | Group of NagVis files will be: apache | | Path to Apache config dir is: /etc/httpd/conf.d | | Apache config will be created: yes | | | | Installation mode: install | | | | Do you really want to continue? [y]: +------------------------------------------------------------------------------+ | Starting installation | +------------------------------------------------------------------------------+ | Creating directory /usr/share/nagvis... done | | Creating directory /usr/share/nagvis/var... done | | Creating directory /usr/share/nagvis/var/tmpl/cache... done | | Creating directory /usr/share/nagvis/var/tmpl/compile... done | | Creating directory /usr/share/nagvis/share/var... done | | Copying files to /usr/share/nagvis... done | | Creating main configuration file... done | | adding base="/usr/share/nagvis" done | | setting backend to ndomy_1 done | | Creating web configuration file... done | | Setting permissions for web configuration file... done | | | | | | | +--- Setting permissions... ---------------------------------------------------+ | /usr/share/nagvis/etc/nagvis.ini.php-sample done | | /usr/share/nagvis/etc done | | /usr/share/nagvis/etc/maps done | | /usr/share/nagvis/etc/maps/* done | | /usr/share/nagvis/etc/automaps done | | /usr/share/nagvis/etc/automaps/* done | | /usr/share/nagvis/share/userfiles/images/maps done | | /usr/share/nagvis/share/userfiles/images/maps/* done | | /usr/share/nagvis/share/userfiles/images/shapes done | | /usr/share/nagvis/share/userfiles/images/shapes/* done | | /usr/share/nagvis/var done | | /usr/share/nagvis/var/* done | | /usr/share/nagvis/var/tmpl done | | /usr/share/nagvis/var/tmpl/cache done | | /usr/share/nagvis/var/tmpl/compile done | | /usr/share/nagvis/share/var done | | | +------------------------------------------------------------------------------+ | Installation complete | | | | You can safely remove this source directory. | | | | For later update/upgrade you may use this command to have a faster update: | | ./install.sh -n /usr/share/nagios -p /usr/share/nagvis -B /usr/sbin/nagios -b ndo2db -u apache -g apache -w /etc/httpd/conf.d -a y | | | What to do next? | | - Read the documentation | | - Maybe you want to edit the main configuration file? | | Its location is: /usr/share/nagvis/etc/nagvis.ini.php | | - Configure NagVis via browser | | <http://localhost/nagvis/config.php> | | - Initial admin credentials: | | Username: nagiosadmin | | Password: nagiosadmin | +------------------------------------------------------------------------------+ [root@nagios nagvis-1.5.10]#
Edit the ini file /usr/share/nagvis/etc/nagvis.ini.php to enable access to the ndo2db database:
[backend_ndomy_1] backendtype="ndomy" ; database name for NDO-db dbname="nagios" ; username for NDO-db dbuser="nagios" ; password for NDO-db dbpass="<password>"
Edit the web servers's php.ini to make sure date.timezone is set. Example for Hong Kong:
[Date] ; Defines the default timezone used by the date functions date.timezone = "Asia/Hong_Kong"
nagvis/includes/classes/GlobalPage.php has a BOM embedded in the beginning and causes problem. Please create new using cut and paste.
Attached here the file content:
<?php
/*****************************************************************************
*
* GlobalPage.php - Class for managing the common page layout
*
* Copyright (c) 2004-2008 NagVis Project (Contact: lars@vertical-visions.de)
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
/**
* @author Lars Michelsen <lars@vertical-visions.de>
*/
class GlobalPage {
protected $CORE;
// arrays for the header
private $title;
private $cssIncludes;
private $jsIncludes;
private $extHeader;
// String for the body
private $body;
// logged in user
private $user;
private $languageRoot;
/**
* Class Constructor
*
* @param GlobalCore $CORE
* @param Array $prop Array('name'=>'myform','id'=>'myform','method'=>'POST','action'=>'','onSubmit'=>'','cols'=>'2','enctype'=>''
* @author Lars Michelsen <lars@vertical-visions.de>
*/
public function __construct($CORE, $givenProperties=Array()) {
$this->CORE = $CORE;
// Define default Properties here
$defaultProperties = Array('title'=>'NagVis Page',
'cssIncludes' => Array($this->CORE->MAINCFG->getValue('paths','htmlbase').'/nagvis/includes/css/style.css'),
'jsIncludes' => Array(),
'extHeader' => '',
'allowedUsers' => Array('EVERYONE'),
'languageRoot' => 'nagvis');
$prop = array_merge($defaultProperties,$givenProperties);
$this->body = '';
$this->title = $prop['title'];
$this->cssIncludes = $prop['cssIncludes'];
$this->jsIncludes = $prop['jsIncludes'];
$this->allowedUsers = $prop['allowedUsers'];
$this->languageRoot = $prop['languageRoot'];
$this->extHeader = $prop['extHeader'];
// Append additional header information
$this->extHeader .= '<meta http-equiv="Content-Type" content="text/html;charset=utf-8">';
$this->extHeader .= '<title>'.$prop['title'].'</title>';
// Hint for iphone scaling (not verified - have no iphone)
// http://www.nagios-portal.org/wbb/index.php?page=Thread&threadID=13885
$this->extHeader .= '<meta name="viewport" content="width=480; initial-scale=0.6666; maximum-scale=1.0; minimum-scale=0.6666" />';
$this->user = getUser();
$this->CORE->MAINCFG->setRuntimeValue('user',$this->user);
self::checkPreflight();
}
/**
* Checks for valid php version
*
* @param Boolean $printErr
* @return Boolean Is Check Successful?
* @author Lars Michelsen <lars@vertical-visions.de>
*/
private function checkPHPVersion($printErr) {
if(version_compare(PHP_VERSION, CONST_NEEDED_PHP_VERSION, ">=")) {
return TRUE;
} else {
if($printErr) {
new GlobalFrontendMessage('ERROR', $this->CORE->LANG->getText('wrongPhpVersion','CURRENT_VERSION~'.PHP_VERSION.',NEEDED_VERSION~'.CONST_NEEDED_PHP_VERSION));
}
return FALSE;
}
}
/**
* Checks for logged in Users
*
* @param Boolean $printErr
* @return Boolean Is Check Successful?
* @author Lars Michelsen <lars@vertical-visions.de>
*/
private function checkUser($printErr) {
if($this->user != '') {
return TRUE;
} else {
if($printErr) {
new GlobalFrontendMessage('ERROR', $this->CORE->LANG->getText('noUser'));
}
return FALSE;
}
}
/**
* Checks for valid Permissions
*
* @param String $allowed
* @param Boolean $printErr
* @return Boolean Is Check Successful?
* @author Lars Michelsen <lars@vertical-visions.de>
*/
private function checkPermissions(&$allowed,$printErr) {
if(isset($allowed) && !in_array('EVERYONE', $allowed) && !in_array($this->CORE->MAINCFG->getRuntimeValue('user'), $allowed)) {
if($printErr) {
new GlobalFrontendMessage('ERROR', $this->CORE->LANG->getText('permissionDenied','USER~'.$this->CORE->MAINCFG->getRuntimeValue('user')));
}
return FALSE;
} else {
return TRUE;
}
return TRUE;
}
/**
* Does the Prflight checks before building the page
*
* @return Boolean Is Check Successful?
* @author Lars Michelsen <lars@vertical-visions.de>
*/
private function checkPreflight() {
$ret = TRUE;
$ret = $ret & $this->checkUser(TRUE);
$ret = $ret & $this->checkPHPVersion(TRUE);
$ret = $ret & $this->checkPermissions($this->allowedUsers,TRUE);
return $ret;
}
/**
* Adds one or more elements (lines) to the Body Array
*
* @param String/Array $lines String or Array with HTML Code
* @return Boolean TRUE
* @author Lars Michelsen <lars@vertical-visions.de>
*/
public function addBodyLines($lines) {
if(is_array($lines)) {
$lines = implode("\n", $lines);
}
$this->body .= $lines;
return TRUE;
}
/**
* Gets the Header of the HTML Page
*
* @return String HTML Code of the Header
* @author Lars Michelsen <lars@vertical-visions.de>
*/
private function getHeader() {
return $this->getExtHeader().$this->getJsIncludes().$this->getCssIncludes();
}
/**
* Gets the Body of the HTML Page
*
* @return String HTML Code of the Header
* @author Lars Michelsen <lars@vertical-visions.de>
*/
private function getBody() {
$ret = $this->body;
return $ret;
}
/**
* Gets the lines of extended header information
*
* @return String HTML Code
* @author Lars Michelsen <lars@vertical-visions.de>
*/
private function getExtHeader() {
return $this->extHeader;
}
/**
* Gets the lines of javascript inclusions
*
* @return String HTML Code
* @author Lars Michelsen <lars@vertical-visions.de>
*/
protected function getJsIncludes() {
$sRet = '';
if(count($this->jsIncludes) > 0) {
foreach($this->jsIncludes AS $var => &$val) {
$sRet .= '<script type="text/javascript" src="'.$val.'"></script>';
}
}
return $sRet;
}
/**
* Gets the lines of css file inclusions
*
* @return String HTML Code
* @author Lars Michelsen <lars@vertical-visions.de>
*/
private function getCssIncludes() {
$sRet = '';
if(count($this->cssIncludes) > 0) {
foreach($this->cssIncludes AS $var => &$val) {
$sRet .= '<link rel="stylesheet" type="text/css" href="'.$val.'">';
}
}
return $sRet;
}
/**
* Builds the HTML Page
*
* @return String HTML Code
* @author Lars Michelsen <lars@vertical-visions.de>
*/
private function buildPage() {
$ret = '';
$ret .= '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'."\n";
$ret .= '<html><head>'."\n";
$ret .= $this->getHeader();
$ret .= '</head><body class="main">'."\n";
$ret .= $this->getBody();
$ret .= '</body></html>';
return $ret;
}
/**
* Prints the complete HTML Page
*
* @author Lars Michelsen <lars@vertical-visions.de>
*/
public function printPage() {
echo $this->buildPage();
if (DEBUG&&DEBUGLEVEL&4) debugFinalize();
// printing the page is the end of everything else - good bye! ;-)
exit;
}
/**
* Parses given Js code
*
* @param String $js Javascript code to parse
* @return Array Html
* @author Lars Michelsen <lars@vertical-visions.de>
*/
public function parseJs($js) {
$ret = '';
if($js != '') {
$ret .= "<script type=\"text/javascript\"> ";
if(is_array($js)) {
$ret .= implode("\n", $js);
} else {
$ret .= $js;
}
$ret .= "</script>";
}
return $ret;
}
/**
* Resizes the window to individual calculated size
*
* @param Int $x X-Coordinates
* @param Int $y Y-Coordinates
* @return Array JS Code
* @author Lars Michelsen <lars@vertical-visions.de>
*/
public function resizeWindow($x,$y) {
$ret = Array('window.resizeTo('.$x.','.$y.')');
return $ret;
}
}
?>
Open the following link to the main page:
http://<server_name>/nagios/nagvis/nagvis/index.php
Open the following to create new maps:
http://<server_name>/nagios/nagvis/wui/index.php
Quick installation:
# cd extracted source ./install.sh -n /usr/share/nagios -p /usr/share/nagvis -B /usr/sbin/nagios -b ndo2db -u apache -g apache -w /etc/httpd/conf.d -a y
The authentication is changed. A SQLite database is used to store user accounts and permissions. The default user created is nagiosadmin with Administrators rights, and password: nagiosadmin.
To login Nagvis after installation, edit nagvis.ini.php:
logonmodule="LogonEnv" logonenvvar="REMOTE_USER"
And in /etc/httpd/conf.d/nagvis.conf, enable:
AuthName "NagVis Access" AuthType Basic AuthUserFile /etc/nagios/htpasswd.users Require valid-user
Of course, the /etc/nagios/htpasswd.users must have an entry for nagiosadmin.
That way, after openning the nagvis url and login as nagiosadmin, you can open the user manager interface to add more users and set their roles: