This won’t work for everyone, but if you have a way to identify the location in the hostname of the device (Datacenter code name, such as server1.dc2.some.com) then you can have the poller automatically set the physical location based on that by adding some simple code to includes/polling/system.inc.php. This is what I’ve done and it makes adding hosts to Observium with the “correct” location automatic (TBH, I don’t even touch Observium when adding or removing hosts from it since I’ve automated that process and it’s opt-in, not automatic discovery). If you have a CM that manages snmpd.conf for your hosts then sure, you could use that to set the location with similar logic, but what if there’s no CM (Chef or other) or you don’t have access to change this setting (Switches managed by another team, for example)?
I correct/fix what I can at the host level, but sometimes it’s just easier to implement a change in the tool itself.
In system.inc.php, after this line (Should be line 102):
$poll_device['sysLocation'] = str_replace(array('"', '"'), "", $poll_device['sysLocation']);
You could just add some if statements containing preg_match…
if (preg_match(“/.dc2./i", $device['hostname'])) { $poll_device['sysLocation'] = “DataCenter City, CA"; }
During the next poll the location would be automatically set based on hostname. In my case, snmpd.conf isn’t managed and is part of the OS image so my choice was to either manage/update the snmpd config on the devices or make a quick change in Observium. I went with the latter choice due to the number and type of systems involved. Since every device we have has the datacenter location in the hostname, boom, automatically set for any device added to Observium.
Maybe this will help someone, thought I’d toss it out there.
-Hogan
On Aug 18, 2014, at 11:05 PM, Peter.Hine@familycourt.gov.au wrote:
here's an example of what I use cause i don't have control over the all servers (specially windoze) and routers.
$config['location_map']['Adelaide'] = "Adelaide, AU";
thanks
Peter Hine
The information contained in this e-mail (including any attachments) is for the exclusive use of the addressee. If you are not the intended recipient please notify the sender immediately and delete this e-mail. It is noted that legal privilege is not waived because you have read this e-mail.
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium