// This function might be passed either an OpenLayers.LonLat (so has // lon and lat) or an OpenLayers.Geometry.Point (so has x and y) function fixmystreet_update_pin(lonlat) { lonlat = lonlat.clone().transform( fixmystreet.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326") ); document.getElementById('fixmystreet.latitude').value = lonlat.lat || lonlat.y; document.getElementById('fixmystreet.longitude').value = lonlat.lon || lonlat.x; $.getJSON('/report/new/ajax', { latitude: $('#fixmystreet\\.latitude').val(), longitude: $('#fixmystreet\\.longitude').val() }, function(data) { if (data.error) { if (!$('#side-form-error').length) { $('
').insertAfter($('#side-form')); } $('#side-form-error').html('' + data.error + '
').show(); $('#side-form').hide(); $('body').removeClass('with-notes'); return; } $('#side-form, #site-logo').show(); var old_category = $("select#form_category").val(); $('#councils_text').html(data.councils_text); $('#form_category_row').html(data.category); if ($("select#form_category option[value=\""+old_category+"\"]").length) { $("select#form_category").val(old_category); } if ( data.extra_name_info && !$('#form_fms_extra_title').length ) { // there might be a first name field on some cobrands var lb = $('#form_first_name').prev(); if ( lb.length === 0 ) { lb = $('#form_name').prev(); } lb.before(data.extra_name_info); } // If the category filter appears on the map and the user has selected // something from it, then pre-fill the category field in the report, // if it's a value already present in the drop-down. var category = $("#filter_categories").val(); if (category !== undefined && $("#form_category option[value="+category+"]").length) { $("#form_category").val(category); } var category_select = $("select#form_category"); if (category_select.val() != '-- Pick a category --') { category_select.change(); } }); if (!$('#side-form-error').is(':visible')) { $('#side-form, #site-logo').show(); window.scrollTo(0, 0); } } function fixmystreet_activate_drag() { fixmystreet.drag = new OpenLayers.Control.DragFeature( fixmystreet.markers, { onComplete: function(feature, e) { fixmystreet_update_pin( feature.geometry ); } } ); fixmystreet.map.addControl( fixmystreet.drag ); fixmystreet.drag.activate(); } function fixmystreet_zoomToBounds(bounds) { if (!bounds) { return; } var center = bounds.getCenterLonLat(); var z = fixmystreet.map.getZoomForExtent(bounds); if ( z < 13 && $('html').hasClass('mobile') ) { z = 13; } fixmystreet.map.setCenter(center, z); } function fms_markers_list(pins, transform) { var markers = []; var size = fms_marker_size_for_zoom(fixmystreet.map.getZoom() + fixmystreet.zoomOffset); for (var i=0; i#! /usr/bin/perl
use strict;
use warnings;
use BER;
use DBI;
use POSIX;
use Time::HiRes;
use Net::Ping;
use lib '../include';
use nms;
use threads;
poll_loop();
sub poll_loop {
my $dbh = nms::db_connect();
my $qcores = $dbh->prepare('SELECT DISTINCT coreswitches.sysname, coreswitches.switch, coreswitches.ip, coreswitches.community FROM uplinks JOIN switches AS coreswitches ON (uplinks.coreswitch = coreswitches.switch)');
my $qaps = $dbh->prepare("SELECT switches.sysname, switches.switch, uplinks.blade, uplinks.port FROM uplinks NATURAL JOIN switches WHERE uplinks.coreswitch = ?");
my $qpoll = $dbh->prepare("UPDATE ap_poll SET model=?, last_poll=now() WHERE switch = ?");
while (1) {
$qcores->execute();
my $cores = $qcores->fetchall_hashref("sysname");
foreach my $core (keys %$cores) {
my $ip = $cores->{$core}{'ip'};
my $community = $cores->{$core}{'community'};
printf "Polling %s (%s)\n", $core, $ip;
eval {
my $session = nms::snmp_open_session($ip, $community);
$qaps->execute($cores->{$core}{'switch'});
while (my $aps = $qaps->fetchrow_hashref()) {
my $sysname = $aps->{'sysname'};
my $blade = $aps->{'blade'};
my $port = $aps->{'port'};
my $oid = "1.3.6.1.2.1.105.1.1.1.9.$blade.$port"; # POWER-ETHERNET-MIB...pethPsePortType
my $mode = $session->get($oid);
$qpoll->execute($mode, $aps->{'switch'});
printf "%s (%s:%s/%s): %s\n", $sysname, $core, $blade, $port, $mode;
}
};
if ($@) {
mylog("ERROR: $@ (during poll of $ip)");
$dbh->rollback;
}
}
sleep 2;
}
}
sub mylog {
my $msg = shift;
my $time = POSIX::ctime(time);
$time =~ s/\n.*$//;
printf STDERR "[%s] %s\n", $time, $msg;
}