NagVis is a visualization addon for the well known network managment system Nagios.
NagVis can be used to visualize Nagios Data, e.g. to display IT processes like a mail system or a network infrastructure.
Useful Links:
NagVis is a visualization addon for the well known network managment system Nagios.
NagVis can be used to visualize Nagios Data, e.g. to display IT processes like a mail system or a network infrastructure.
These guidelines should support new developers by coding for or with NagVis. The guidelines have to be considered in NagVis 1.x by all developers due to clean up the code.
Here is a short overview off the file structure of NagVis. The best is, to download NagVis and have a look at the real structure and the code.
NagVis_Root _______/etc ______|__/maps ______|__|__/<map>.cfg ______|__/config.ini.php _______/nagvis ______|___/images ______|___|____/iconsets ______|___|____/internal ______|___|____/maps ______|___|____/templates ______|___|___|______/header ______|___|___|_____|___/<header>.png ______|___|___|______/hover ______|___|___|_____|___/<hover>.png ______|___|___|___/<background>.png ______|___/includes ______|___|____/classes ______|___|____/css ______|___|____/js ______|___|____/languages ______|___|____|_____/<language>.xml ______|___/templates ______|___|___/header ______|___|__|___/tmpl.<header>.html ______|___|___/hover ______|___|__|___/tmpl.<hover>.html ______|___/index.php ______|___/draw.php _______/wui ______|__/images ______|__|____/internal ______|__/includes ______|__|____/classes ______|__|____/css ______|__|____/js ______|__/addmodify.php ______|__/edit_config.php ______|__/index.php ______|__/map_management.php ______|__/wui.function.inc.php _______/index.php _______/config.php
User two slashes followed by a whitespace for single line comments:
// my comment
For multi line comments use the following:
/** * * My multi * line comment */
Brackets are always used like this:
if(...) {
...
} elseif() {
...
} else {
...
}
When there is only one command after an if/else statement, also use brackets. This makes the code easier to read for others.
For making the code more readable we use 4 whitespaces as 1 tabstop to indention the code.
First Char have to be upper case. Each new word is upper case too. We seperate classes in 3 types Global, NagVis, Wui. Global classes are used by NagVis and Wui. The other classes are used in the seperate packets. Global-Classes are manly extended by local classes in NagVis or Wui. Global- and NagVis- classes are stored under
nagvis/includes/classes/
, Wui classes under
wui/includes/classes/
.
Example for class definition:
class GlobalPage {
...
}
Objects are always upper case and named like the Class they are objects from.
Example for object initialisation:
$MAP = new NagVisMap(...);
Methods start with lower case, the first word should be a verb like get, set, make, create, update, ... the next words begin with an upper case letter and descript what the method does.
Example for a method definition:
function setRuntimeValue(...) {
...
}
Each method should have a multi line comment before it starts, like this example:
/**
*
* Gets an input row
*
* @param String $myString Description
* @return Boolean
* @author Lars Michelsen <lars@vertical-visions.de>
*/
function myMethod(...) {
...
}
Variables start with a lower case word, all following words begin with an upper case letter.
Example for a variable:
$correctExampleVar = TRUE;