Nagios XI – Integrating NagVis With Nagios XI Important:
Transcription
Nagios XI – Integrating NagVis With Nagios XI Important:
Nagios XI – Integrating NagVis With Nagios XI The Industry Standard in IT Infrastructure Monitoring Important: This document is outdated as all versions of Nagios XI (2012 and newer) ship with NagiVis by default and the “NagiosXI-Nagvis.sh” install script should NOT be run! Purpose This document describes how to install the NagVis network status visualization tool with Nagios XI. NagVis is a visualization addon for Nagios, which can be used to visualize Nagios data. NagVis is a useful tool to highlight issues in a visual manner. Target Audience This document is intended for use by Nagios XI administrators who wish to deploy NagVis for network status visualization. Requirements You must be running Nagios XI 2009R1.2 or later in order to use this documentation. Automated Installation The process of installing NagVis to a Nagios XI system can be automated with a Nagios XI – NagVis script that can be downloaded from: http://assets.nagios.com/downloads/nagiosxi/scripts/NagiosXI-Nagvis.sh Follow the steps below to install NagVis: 1. Open a terminal and Log in to the Nagios XI server as the root user 2. Download the automated installation script to the /tmp directory by running these commands: cd /tmp wget http://assets.nagios.com/downloads/nagiosxi/scripts/NagiosXI-Nagvis.sh 3. Make the script executable chmod +x NagiosXI-Nagvis.sh 4. Execute the script: ./NagiosXI-Nagvis.sh The installation script will perform the following steps for you: • Install prerequisite packages • Download and untar NagVis • Install and configure NagVis with options fitting a Nagios XI environment The script is also documented internally if you would like to see its operation in more detail. Nagios Enterprises, LLC US: 1-888-NAGIOS-1 P.O. Box 8154 Int'l: +1 651-204-9102 Saint Paul, MN 55108 Fax: +1 651-204-9103 USA Web: www.nagios.com Email:sales@nagios.com Page 1 Copyright © 2010 - 2014 Nagios Enterprises, LLC Revision 1.1 – October, 2014 Nagios XI – Integrating NagVis With Nagios XI Accessing NagVis To access your new NagVis installation, open the following URL in your web browser (replacing <yourserver> with your Nagios XI server's address). http://<yourserver>/nagvis NagVis uses a different authentication mechanism than Nagios XI, so you will need to re-authenticate in order access NagVis. When prompted, use the same username and password you use to login to Nagios XI. Once you authenticate you should see a default NagVis view with some demo maps: You have successfully installed NagVis! Note that NagVis has an included web based config tool called WUI. If you want to use it open the page http://<yourserver>/nagvis/frontend/wui/index.php in your browser and click the menus across the top. You may need to disable script or popup blockers to use the WUI. You can refer to the official NagVis documentation at http://www.nagvis.org/documentation for further usage, configuration, and map creation information. Customizing The Automap If you would like to use the Automap (an automatically generated display of defined hosts), there are some additional steps you will need to take. By default, the Automap shows a rather plain page with a single bubble for localhost (your monitoring server) in the middle, even if you have other hosts defined. In order for those other hosts to show up in the Automap, you will need to define parent/child relationships for each host you wish to appear. Those hosts must have a parent/child path back to localhost. Keep reading for instructions on how to configure parent/child relationships and customize the look of the Automap. Defining Parent/Child Relationships To define parent/child relationships between hosts, you will need to enter the Nagios Core Config Manager (Admin → Core Config Manager → Host). Select a host from the list to edit the host definition. You can specify its parent hosts by using the Manage Parents button on the Common Settings tab. Select the parent host from the list on the left and click Add Selected to move it to the right hand Assigned list. When finished, click Close, then Save, and finally Apply Configuration. Nagios Enterprises, LLC US: 1-888-NAGIOS-1 P.O. Box 8154 Int'l: +1 651-204-9102 Saint Paul, MN 55108 Fax: +1 651-204-9103 USA Web: www.nagios.com Email:sales@nagios.com Page 2 Copyright © 2010 - 2014 Nagios Enterprises, LLC Revision 1.1 – October, 2014 Nagios XI – Integrating NagVis With Nagios XI Hosts that are one network “hop” away from your Nagios XI monitoring server should have localhost as their parent host. After you have configured some hosts to have localhost as their parent, they will show up on the NagVis Automap. You can define multiple levels of parents, which will result in a more complex map. The hosts that are closest to and connected to localhost must have localhost defined as being their parent, or they and their children will not appear on the map. If you create a chain of parent/child related hosts, but do not define at least one of those hosts as being a child of localhost, you will not see any of them on the map. Multiple Parents As you may have already noticed, it is possible to define more than one parent for any given host. Multiple parents will work with the NagVis Automap, although it quickly becomes more confusing. By default there is no indication as to which host is the parent and which is the child. So while you can see that there is a relationship between hosts, it becomes ambiguous as to how exactly that relationship is defined. Read on for some tips on styling the Automap with directed lines to alleviate this confusion. Nagios Enterprises, LLC US: 1-888-NAGIOS-1 P.O. Box 8154 Int'l: +1 651-204-9102 Saint Paul, MN 55108 Fax: +1 651-204-9103 USA Web: www.nagios.com Email:sales@nagios.com Page 3 Copyright © 2010 - 2014 Nagios Enterprises, LLC Revision 1.1 – October, 2014 Nagios XI – Integrating NagVis With Nagios XI Advanced Automap Styling Under the hood, NagVis uses a utility called GraphViz to draw the automap. The NagVis PHP code is used to write a graph file in the DOT language format, and then GraphViz renders the graph into a PNG image. In order to change the styling of the image, we need to change what is written to the DOT file. The DOT language and GraphViz uses terminology of nodes and edges, which in our case are hosts and the parent-child relationship lines, respectively. Both of these items can be styled, with documentation on the details of doing so provided at http://www.graphviz.org/doc/info/attrs.html. Directed Lines Since an issue with multiple parents was the lack of direction in the parent/child relationships, we will start by styling the edges to show direction. Note: Some installations may come with this as the default style of the Automap and you can skip the following steps. By default NagVis treats the edges as having the attribute dir=none, meaning they are non-directional, and rendered as simple lines. To change the display to arrows, we will set the attribute dir=forward. To do this, log onto your Nagios XI server and edit the file /usr/local/nagvis/share/server/core/classes/objects/NagVisHost.php, looking for a line that looks like the following (as of this writing it is line #108): $strReturn .= $this->getType().'_'.$this->getObjectId().' -- '.$OBJ->getType().'_'.$OBJ>getObjectId().' [color=black, decorate=1, style=solid, weight=2 ];'."\n "; Add the dir=forward attribute to that line so it reads: $strReturn .= $this->getType().'_'.$this->getObjectId().' -- '.$OBJ->getType().'_'.$OBJ>getObjectId().' [color=black, decorate=1, style=solid, weight=2, dir=forward ];'."\n "; Save the file and refresh your Automap. You should see directed lines in the map. Nagios Enterprises, LLC US: 1-888-NAGIOS-1 P.O. Box 8154 Int'l: +1 651-204-9102 Saint Paul, MN 55108 Fax: +1 651-204-9103 USA Web: www.nagios.com Email:sales@nagios.com Page 4 Copyright © 2010 - 2014 Nagios Enterprises, LLC Revision 1.1 – October, 2014 Nagios XI – Integrating NagVis With Nagios XI Additional Styling It is also possible to style the nodes in the AutoMap if you would like. This is done in the same PHP file by setting the shape attribute in the parseGraphviz() function. You can also add your own PHP handling code to style different types of nodes separately. For instance, I modified my parseGraphviz() function to look like this: function parseGraphviz($layer=0, &$arrHostnamesParsed) { $strReturn = ''; if(!in_array($this->getName(), $arrHostnamesParsed)) { $strReturn .= $this->getType().'_'.$this->getObjectId().' [ '; $strReturn .= 'label=<<table border="0">'; if(isset($this->statusmap_image) && $this->statusmap_image != '') { $strReturn .= '<tr><td><img src="'.$this->CORE->MAINCFG>getValue('paths', 'shape').$this->statusmap_image.'"></img></td></tr>'; } $strReturn .= '<tr><td><img src="'.$this->iconPath.$this>icon.'"></img></td></tr>'; $strReturn .= '<tr><td>'.$this->getName().'</td></tr>'; $strReturn .= '</table>>, '; $strReturn .= 'URL="'.str_replace(array('[htmlcgi]', '[host_name]'), array($this->CORE->MAINCFG->getValue('backend_'.$this->backend_id, 'htmlcgi'), $this->getName()), $this->CORE->MAINCFG->getValue('defaults', 'hosturl')).'", '; $strReturn .= 'target="'.$this->url_target.'", '; $strReturn .= 'tooltip="'.$this->getType().'_'.$this->getObjectId().'",'; // The root host has to be highlighted, these are the options to do this if($layer == 0) { $strReturn .= 'shape="house",'; } else if($layer == 1) { $strReturn .= 'shape="box3d",'; } else if($layer == 2) { $strReturn .= 'shape="folder",'; } else { $strReturn .= 'shape="circle",'; } $strReturn .= 'layer="'.$layer.'"'; $strReturn .= ' ];'."\n "; // Add host to the list of parsed hosts $arrHostnamesParsed[] = $this->getName(); foreach($this->getChilds() As $OBJ) { if(is_object($OBJ)) { $strReturn .= $OBJ->parseGraphviz($layer+1, $arrHostnamesParsed); $strReturn .= $this->getType().'_'.$this>getObjectId().' -- '.$OBJ->getType().'_'.$OBJ->getObjectId().' [color=black, decorate=1, style=solid, weight=2, dir=forward ];'."\n "; } } } } return $strReturn; Nagios Enterprises, LLC US: 1-888-NAGIOS-1 P.O. Box 8154 Int'l: +1 651-204-9102 Saint Paul, MN 55108 Fax: +1 651-204-9103 USA Web: www.nagios.com Email:sales@nagios.com Page 5 Copyright © 2010 - 2014 Nagios Enterprises, LLC Revision 1.1 – October, 2014 Nagios XI – Integrating NagVis With Nagios XI You can change the font size of node labels by editing /usr/local/nagios/share/nagvis/nagvis/includes/classes/NagVisAutoMap.php. In my testing, line #253 contained the font size and color that could be modified, which I set to: $str .= 'fontcolor=black, fontsize=16'; After a font size change, along with the modification of node styles described above, you can end up with an Automap map that looks like the picture below. Pretty cool! Styling Reference For more information on available attributes in the DOT language, visit http://www.graphviz.org/doc/info/attrs.html. Version Note These instructions refer to the current stable branch of NagVis, which at the time of last update was 1.5.x. Finishing Up If you have any additional support issues that you cannot resolve, please, post your questions on the Nagios Support Forum: http://support.nagios.com/forum/ Nagios Enterprises, LLC US: 1-888-NAGIOS-1 P.O. Box 8154 Int'l: +1 651-204-9102 Saint Paul, MN 55108 Fax: +1 651-204-9103 USA Web: www.nagios.com Email:sales@nagios.com Page 6 Copyright © 2010 - 2014 Nagios Enterprises, LLC Revision 1.1 – October, 2014