Skip to content

Commit

Permalink
New Features
Browse files Browse the repository at this point in the history
The following changes were made:
- Implementing z-index control when using Leaflet API.
- Deployed hosts filter in ChangesBar. #10
- README update.
- VERSION update.
  • Loading branch information
jocafamaka committed Nov 2, 2018
1 parent 25e9171 commit d5e09ef
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
config.php
migrate.php
keys.txt
random*
tests/*
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
# NagMap Reborn Introduction

NagMap Reborn is an initiative to improve the NagMap project developed by [Marcel Hecko](https://github.com/hecko) which according to his own description is an "... super-simple application to integrate Nagios or Icinga with Google maps. The integration aims to visualize current status of network devices on aerial photography images..."
NagMap Reborn is based on NagMap project developed by [Marcel Hecko](https://github.com/hecko) which according to his own description is an "... super-simple application to integrate Nagios or Icinga with Google maps. The integration aims to visualize current status of network devices on aerial photography images..."

## Features

* Updating hosts status without refresh on page.
* Support for multiple languages.
* System of last occurrences (ChangesBar).
* Content filter. <sup>(NEW)</sup>
* System of sound warning.
* Notification system on the page.
* Almost total control of page characteristics.
* Powerful debug page.
* Service filter.
* Self report of errors.
* Access control.
* Support for multiple API's. <sup>(NEW)</sup>
* Support for multiple API's.

## What you can control

* Map center.
* Zoom level.
* Language.
* Currently only available: English and Portuguese. (Translation contributions are welcome)
* Currently only available: English, Portuguese and French. (Translation contributions are welcome)
* Last occurrences view (ChangesBar).
* ChangesBar size on screen.
* Font size.
* Used date format.
* ChangesBar mode.
* Show content filter. <sup>(NEW)</sup>
* Use system of sound warning.
* Show lines between hosts and their parents.
* Time to update hosts status.
* Icons style.
* Which API to use. <sup>(NEW)</sup>
* Which API to use.

## Compatibility

Expand Down Expand Up @@ -80,4 +82,4 @@ Contribution are always **welcome and recommended**! Here is how:

* By using this API Implementation, your are agreeing to be bound by Leaflet, OpenStreetMap and Google's Terms of Use.
* This app uses the OpenStreetMap's tiles. [See here](https://wiki.osmfoundation.org/wiki/Privacy_Policy) the privacy policy.
* This app uses the Google Maps API. [See here](https://cloud.google.com/maps-platform/terms/) Google privacy policy. - [See here](https://developers.google.com/maps/documentation/javascript/usage) Google Maps usage quotas.
* This app uses the Google Maps API. [See here](https://cloud.google.com/maps-platform/terms/) Google privacy policy. - [See here](https://developers.google.com/maps/documentation/javascript/usage) Google Maps usage quotas.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.0
1.6.1
5 changes: 5 additions & 0 deletions config.php.example
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ $nagMapR_ChangesBarSize = 15;
// Font size in pixels used in ChangesBar. (use only numbers)
$nagMapR_FontSize = 15;

//Includes a field at the top of ChanesBar to filter the information displayed regardless of usage mode.
// 1 = YES.
// 0 = NO.
$nagMapR_BarFilter = 1;

// Defines the date format used in the ChangesBar.
// 1 = DD/MM/YYYY
// 2 = MM/DD/YYYY
Expand Down
17 changes: 11 additions & 6 deletions config.php.example_pt-BR
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
####################################################################################################
# CONFIGURAÇÕES GERAIS #
# CONFIGURACOES GERAIS #
####################################################################################################
// Defina essa duas linhas, elas sao extremamente importantes
// No linux execute `updatedb`, `locate nagios.cfg` e `locate status.dat` para encontrar esses arquivos
Expand Down Expand Up @@ -115,10 +115,15 @@ $nagMapR_FontSize = 15;
// 3 = YYYY/MM/DD
$nagMapR_DateFormat = 1;

// Inclui um campo no topo da ChanesBar para filtrar as informacoes exibidas, independente do modo de utilizacao.
// 1 = SIM.
// 0 = NAO.
$nagMapR_BarFilter = 1;

// Tocar um alerta sonoro quando o status de um host mudar para down?
// Para mudar o alerta tocado, basta somente substituir o arquivo 'Beep.mp3' na pasta resources.
// Em alguns browsers é necessário que usuário interaja com a página antes que ela emita algum som,
// sendo assim é necessário uma interação inicial para que o alerta seja tocado.
// Em alguns browsers e necessario que usuario interaja com a pagina antes que ela emita algum som,
// sendo assim e necessario uma interacao inicial para que o alerta seja tocado.
// 1 = SIM.
// 0 = NAO.
$nagMapR_PlaySound = 1;
Expand All @@ -134,7 +139,7 @@ $nagMapR_IconStyle = 1;
// 0 = NAO.
$nagMapR_Lines = 1;

// Tempo em segundos, para atualização do status dos hosts. (use somente numeros)
// Tempo em segundos, para atualizacao do status dos hosts. (use somente numeros)
$nagMapR_TimeUpdate = 10;

// Reportar erros automaticamente?
Expand All @@ -148,9 +153,9 @@ $nagMapR_Reporting = 1;
// Chave de seguranca, protege de requisicoes externas. (use somente numeros e letras)
$nagMapR_key = 'ELsV7OqefspxiVIPvzOqGzYJShz5TxoKYkZGa0ecfMGj4e3pzAmCho6CQqfuJ3qI3i0J0OiWdFyKkJp2aHANUa8BKUdKXmBO';

// Usuário utilizado na autenticação.
// Usuario utilizado na autenticacao.
$nagMapR_User = "ngradmin";

// Senha utilizada na autenticação.
// Senha utilizada na autenticacao.
$nagMapR_UserKey = "ngradmin";
?>
37 changes: 34 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ function initialize() {
}
if ($nagMapR_ChangesBar == 1) {
echo '<div id="map" style="width:100%; height:'.(100-$nagMapR_ChangesBarSize).'%; float: left"></div>';
if($nagMapR_BarFilter == 1)
echo '<div class="form-group"><input style="font-size:'.$nagMapR_FontSize.'px;" type="text" id="searchBar" class="form-control" placeholder="'.$filter.'..."></div>';
echo '<div id="changesbar" style="padding-top:2px; padding-left: 1px; background: black; height:'.$nagMapR_ChangesBarSize.'%; overflow:auto;">';
if($nagMapR_ChangesBarMode == 2){
echo('<div id="downHosts"></div><div id="critHosts"></div><div id="warHosts"></div>');
Expand Down Expand Up @@ -289,6 +291,8 @@ function changeIcon(host, icon, time, zindex){
MARK[host].stopBouncing();
else
MARK[host].bounce(time);
MARK[host].setZIndexOffset(zindex*1000);
\n");
}
?>
Expand Down Expand Up @@ -513,7 +517,7 @@ function updateStatus(host, status){ // Updates the status of the host informed
}
?>

changeIcon(host, iconGrey, 0, 3);
changeIcon(host, iconGrey, 0, 2);

<?php
if($nagMapR_ChangesBar == 1){
Expand Down Expand Up @@ -704,8 +708,15 @@ function removeHost(i, status){
echo('
}
}
');
?>
');
if($nagMapR_ChangesBar == 1 && $nagMapR_BarFilter == 1){
echo ("
if($('#searchBar').val().toLowerCase() != '')
search();
");
}
?>

if(realTimeUp == false){
realTimeUp = true;
toastr["success"]("<?php echo $updateErrorSolved; ?>");
Expand Down Expand Up @@ -862,6 +873,26 @@ function removeHost(i, status){
"hideMethod": "fadeOut"
};

<?php
if($nagMapR_ChangesBar == 1 && $nagMapR_BarFilter == 1)
echo ("
$('#searchBar').keyup(function(){
search();
});
function search(){
var query = \$('#searchBar').val().toLowerCase();
$('#changesbar .changesBarLine').each(function(){
var \$this = \$(this);
if(\$this.text().toLowerCase().indexOf(query) === -1)
\$this.closest('#changesbar .changesBarLine').hide();
else
\$this.closest('#changesbar .changesBarLine').show();
});
};
");
?>

function reportReturn(type){
toastr.options = {
"closeButton": true,
Expand Down
2 changes: 2 additions & 0 deletions langs/en-US.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@

$timeSuffix = (' ago.');

$filter = ("Filter");

//Debug page
$debugTitle = ("Debug Info.");

Expand Down
2 changes: 2 additions & 0 deletions langs/fr-FR.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@

$timeSuffix = ('');

$filter = ("Filtrer");

//Debug page
$debugTitle = ("Informations de débogage");

Expand Down
2 changes: 2 additions & 0 deletions langs/pt-BR.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@

$timeSuffix = ('');

$filter = ("Filtrar");

//Debug page
$debugTitle = ("Info. de depuração");

Expand Down
10 changes: 5 additions & 5 deletions marker.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,19 @@
// display different icons for the host (according to the status in nagios)
// if host is in state OK
if ($h['status'] == 0) {
$javascript .= ("MARK.push(new google.maps.Marker({ position: ".$h["host_name"]."_pos, icon: iconGreen, map: map, zIndex: 2, title: \"".$h["nagios_host_name"]."\"}));"."\n\n");
$javascript .= ("MARK.push(new google.maps.Marker({ position: ".$h["host_name"]."_pos, icon: iconGreen, map: map, zIndex: 2000, title: \"".$h["nagios_host_name"]."\"}));"."\n\n");
// if host is in state UP but in WARNING
} elseif ($h['status'] == 1) {
$javascript .= ("MARK.push(new google.maps.Marker({ position: ".$h["host_name"]."_pos, icon: iconYellow, map: map, zIndex: 3, title: \"".$h["nagios_host_name"]."\"}));"."\n\n");
$javascript .= ("MARK.push(new google.maps.Marker({ position: ".$h["host_name"]."_pos, icon: iconYellow, map: map, zIndex: 3000, title: \"".$h["nagios_host_name"]."\"}));"."\n\n");
// if host is in state UP but CRITICAL
}elseif ($h['status'] == 2) {
$javascript .= ("MARK.push(new google.maps.Marker({ position: ".$h["host_name"]."_pos, icon: iconOrange, map: map, zIndex: 4, title: \"".$h["nagios_host_name"]."\"}));"."\n\n");
$javascript .= ("MARK.push(new google.maps.Marker({ position: ".$h["host_name"]."_pos, icon: iconOrange, map: map, zIndex: 4000, title: \"".$h["nagios_host_name"]."\"}));"."\n\n");
// if host is in state DOWN
} elseif ($h['status'] == 3) {
$javascript .= ("MARK.push(new google.maps.Marker({ position: ".$h["host_name"]."_pos, icon: iconRed, map: map, zIndex: 5, title: \"".$h["nagios_host_name"]."\"}));"."\n\n");
$javascript .= ("MARK.push(new google.maps.Marker({ position: ".$h["host_name"]."_pos, icon: iconRed, map: map, zIndex: 5000, title: \"".$h["nagios_host_name"]."\"}));"."\n\n");
} else {
// if host is in state UNKNOWN
$javascript .= ("window.MARK.push(new google.maps.Marker({ position: ".$h["host_name"]."_pos, icon: iconGrey, map: map, zIndex: 6, title: \"".$h["nagios_host_name"]."\"}));"."\n\n");
$javascript .= ("window.MARK.push(new google.maps.Marker({ position: ".$h["host_name"]."_pos, icon: iconGrey, map: map, zIndex: 2000, title: \"".$h["nagios_host_name"]."\"}));"."\n\n");
};
//generate google maps info bubble
if (!isset($h["parents"])) { $h["parents"] = Array(); };
Expand Down
8 changes: 8 additions & 0 deletions resources/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ a:hover {
font-weight: bold;
}

.form-group input{
width: 100%;
color: #fff;
border: 2px solid #4f5b63;
padding: 2px 0px 2px 5px;
background: #2c313b;
}

.news {
transition: opacity 500ms linear, max-height 500ms linear;
}
Expand Down
3 changes: 3 additions & 0 deletions validateAndVerify.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
if(!is_int($nagMapR_ChangesBar))
$fails .= "<br><b>\$nagMapR_ChangesBar</b> $var_cfg_error ($nagMapR_ChangesBar)";

if(!is_int($nagMapR_BarFilter))
$fails .= "<br><b>\$nagMapR_BarFilter</b> $var_cfg_error ($nagMapR_BarFilter)";

if(($nagMapR_ChangesBarMode < 1) || ($nagMapR_ChangesBarMode > 2))
$fails .= "<br><b>\$nagMapR_ChangesBarMode</b> $var_cfg_error ($nagMapR_ChangesBarMode)";

Expand Down

0 comments on commit d5e09ef

Please sign in to comment.