Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for host and service groups #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* FIX: Fixed keeping unlisted values of dropdowns (object names, backend_id)
* FIX: Cleaning up host/service attributes when changing the backend_id

Geomap:
* Added support for host and service group objects

1.9b7
Fronted:
* FIX: Fixed "function sidebarUpdatePosition is not defined" when header not shown
Expand Down
1 change: 1 addition & 0 deletions share/server/core/defines/matches.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
define('MATCH_ROLE_NAME', '/^[0-9A-Za-z_\-.@\s]+$/');
define('MATCH_DYN_GROUP_TYPES', '/^(?:host|service)$/');
define('MATCH_DYN_OBJECT_TYPES', '/^(?:host|service|hostgroup|servicegroup)$/');
define('MATCH_GEO_OBJECT_TYPES', '/^(?:host|hostgroup|servicegroup)$/');
define('MATCH_LIVESTATUS_FILTER', '/^(?:Filter: .*\\\n)+$/i');
define('MATCH_ZOOM_FACTOR', '/^(?:[0-9]+|fill)$/');

Expand Down
48 changes: 35 additions & 13 deletions share/server/core/sources/geomap.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ function list_geomap_source_files() {
return $CORE->getAvailableGeomapSourceFiles();
}

function list_geomap_object_types() {
return Array(
'host' => l('Hosts'),
'hostgroup' => l('Hostgroup'),
'servicegroup' => l('Servicegroup'),
);
}

// Register this source as being selectable by the user
global $selectable;
$selectable = true;
Expand All @@ -165,6 +173,7 @@ function list_geomap_source_files() {
'geomap' => array(
'backend_id',
'geomap_type',
'geomap_object_types',
'geomap_zoom',
'geomap_border',
'source_type',
Expand Down Expand Up @@ -213,18 +222,26 @@ function list_geomap_source_files() {
'default' => 0.25,
'match' => MATCH_FLOAT,
),
'geomap_object_types' => Array(
'must' => false,
'default' => 'host',
'field_type' => 'dropdown',
'match' => MATCH_GEO_OBJECT_TYPES,
'list' => 'list_geomap_object_types',
),
);

// Assign config variables to specific object types
global $configVarMap;
$configVarMap = array(
'global' => array(
'geomap' => array(
'geomap_type' => null,
'geomap_zoom' => null,
'source_type' => null,
'source_file' => null,
'geomap_border' => null,
'geomap_type' => null,
'geomap_zoom' => null,
'source_type' => null,
'source_file' => null,
'geomap_border' => null,
'geomap_object_types' => null,
),
),
);
Expand Down Expand Up @@ -264,6 +281,7 @@ function geomap_files($params) {
function process_geomap($MAPCFG, $map_name, &$map_config) {
$params = $MAPCFG->getSourceParams();
list($image_name, $image_path, $data_path) = geomap_files($params);
$type = $params['geomap_object_types'];

// Load the list of locations
$locations = geomap_get_locations($params);
Expand All @@ -285,15 +303,19 @@ function process_geomap($MAPCFG, $map_name, &$map_config) {

// Now add the objects to the map
foreach($locations AS $loc) {
$object_id = $MAPCFG->genObjId($loc['name']);
if (isset($loc['backend_id'])) {
$object_id = $MAPCFG->genObjId($loc['backend_id'].'~~'.$loc['name']);
} else {
$object_id = $MAPCFG->genObjId($loc['name']);
}
$map_config[$object_id] = array(
'type' => 'host',
'host_name' => $loc['name'],
'iconset' => $iconset,
'object_id' => $object_id,
'alias' => $loc['alias'],
'lat' => $loc['lat'],
'long' => $loc['long'],
'type' => $type,
$type.'_name' => $loc['name'],
'iconset' => $iconset,
'object_id' => $object_id,
'alias' => $loc['alias'],
'lat' => $loc['lat'],
'long' => $loc['long'],
);

if (isset($loc['backend_id'])) {
Expand Down