allow the ability to rewrite locations

git-svn-id: http://www.observium.org/svn/observer/trunk@3180 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2012-05-14 12:55:19 +00:00
parent 4e8581c70f
commit aa91161d1a
3 changed files with 28 additions and 0 deletions

View File

@ -269,6 +269,11 @@ $config['nfsen_enable'] = 0;
#$config['nfsen_rrds'] = "/var/nfsen/profiles-stat/live/"; #$config['nfsen_rrds'] = "/var/nfsen/profiles-stat/live/";
#$config['nfsen_suffix'] = "_yourdomain_com"; #$config['nfsen_suffix'] = "_yourdomain_com";
### Location Mapping
### Use this feature to map ugly locations to pretty locations
#config['location_map']['Under the Sink'] = "Under The Sink, The Office, London, UK";
### Ignores & Allows ### Ignores & Allows
# Has to be lowercase # Has to be lowercase

View File

@ -82,6 +82,13 @@
} }
$poll_device['sysLocation'] = str_replace("\"","", $poll_device['sysLocation']); $poll_device['sysLocation'] = str_replace("\"","", $poll_device['sysLocation']);
/// Rewrite sysLocation if there is a mapping array (database too?)
if(!empty($poll_device['sysLocation']) && is_array($config['location_map']))
{
$poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']);
}
$poll_device['sysContact'] = str_replace("\"","", $poll_device['sysContact']); $poll_device['sysContact'] = str_replace("\"","", $poll_device['sysContact']);
if ($poll_device['sysLocation'] == "not set") if ($poll_device['sysLocation'] == "not set")

View File

@ -1,5 +1,21 @@
<?php <?php
function rewrite_location($location){
// FIXME -- also check the database for rewrites?
global $config;
global $debug;
if(isset($config['location_map'][$location]))
{
$location = $config['location_map'][$location];
}
return $location;
}
function formatMac($mac) function formatMac($mac)
{ {
$mac = preg_replace("/(..)(..)(..)(..)(..)(..)/", "\\1:\\2:\\3:\\4:\\5:\\6", $mac); $mac = preg_replace("/(..)(..)(..)(..)(..)(..)/", "\\1:\\2:\\3:\\4:\\5:\\6", $mac);