Skip to content

Instantly share code, notes, and snippets.

View laf's full-sized avatar

Neil Lathwood laf

View GitHub Profile
<?php
$url="http://localhost/api/v0/devices";
$graph_api_token = '';
function hit_api($Url) {
global $graph_api_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Auth-Token: $graph_api_token"));
CREATE TABLE `pollers` (`id` int(11) NOT NULL AUTO_INCREMENT, `poller_name` varchar(255) NOT NULL, `last_polled` datetime NOT NULL, `devices` int(11) NOT NULL, `time_taken` double NOT NULL, KEY `id` (`id`)) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;
html/includes/print-menubar.php
+ <a href="#"><img src="images/16/clock.png" alt="Performance" width="16" height="16" /> Performance</a>
+ <ul class="dropdown-menu scrollable-menu">
+ <li><a href="/performance/tab=pollers/"><img src="images/16/clock_link.png" alt="Pollers" width="16" height="16" /> Pollers</a></li>
+ </ul>
+ </li>
+ <li role="presentation" class="divider"></li>
+ <li class="dropdown-submenu">
diff --git a/poller-wrapper.py b/poller-wrapper.py
index 35579cc..9200e42 100755
--- a/poller-wrapper.py
+++ b/poller-wrapper.py
@@ -74,66 +74,9 @@ db_password = config['db_pass']
db_server = config['db_host']
db_dbname = config['db_name']
-# (c) 2015, GPLv3, Daniel Preussker <f0o@devilcode.org> <<<EOC1
-if 'distributed_poller_group' in config:
diff --git a/poller.php b/poller.php
index 4bee7f6..2a1f348 100755
--- a/poller.php
+++ b/poller.php
@@ -118,7 +118,7 @@ $poller_end = utime(); $poller_run = $poller_end - $poller_start; $poller_time =
if ($polled_devices)
{
- dbInsert(array('type' => 'poll', 'doing' => $doing, 'start' => $poller_start, 'duration' => $poller_time, 'devices' => $polled_devices, 'poller' => $config['distributed_poller_name'] ), 'perf_times');
+ dbInsert(array('type' => 'poll', 'doing' => $doing, 'start' => $poller_start, 'duration' => $poller_time, 'devices' => $polled_devices ), 'perf_times');
@laf
laf / print-map.inc.php
Created March 28, 2015 16:38
Fix for maps
<?php
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
@laf
laf / gist:66fdb796514e46170bfe
Created March 31, 2015 18:32
callback code
<?php
$queries = array(
'alert_rules'=>'SELECT COUNT(`severity`) AS `total`,`severity` FROM `alert_rules` WHERE `disabled`=0 GROUP BY `severity`',
'alert_templates'=>'SELECT COUNT(`id`) AS `total` FROM `alert_templates`',
'api_tokens'=>'SELECT COUNT(`id`) AS `total` FROM `api_tokens` WHERE `disabled`=0',
'applications'=>'SELECT COUNT(`app_type`) AS `total`,`app_type` FROM `applications` GROUP BY `app_type`',
'bgppeer_state'=>'SELECT COUNT(`bgpPeerState`) AS `total`,`bgpPeerState` FROM `bgpPeers` GROUP BY `bgpPeerState`',
'bgppeer_status'=>'SELECT COUNT(`bgpPeerAdminStatus`) AS `total`,`bgpPeerAdminStatus` FROM `bgpPeers` GROUP BY `bgpPeerAdminStatus`',
'bills'=>'SELECT COUNT(`bill_type`) AS `total`,`bill_type` FROM `bills` GROUP BY `bill_type`',
@laf
laf / gist:98061bb3159499addd1a
Created April 3, 2015 23:17
map fix for devices not added
diff --git a/html/includes/print-map.inc.php b/html/includes/print-map.inc.php
index d096a5c..198c96a 100644
--- a/html/includes/print-map.inc.php
+++ b/html/includes/print-map.inc.php
@@ -20,35 +20,41 @@ if (!empty($device['hostname'])) {
$sql = ' WHERE 1';
}
-$sql .= ' AND `local_device_id` != 0 AND `remote_device_id` != 0';
+$sql .= ' AND `local_device_id` != 0';
@laf
laf / gist:ec54ba68da6fdc4be0c0
Created April 7, 2015 17:13
Processors delete fix
diff --git a/includes/discovery/processors.inc.php b/includes/discovery/processors.inc.php
index bb23e62..f93cbff 100755
--- a/includes/discovery/processors.inc.php
+++ b/includes/discovery/processors.inc.php
@@ -25,7 +25,7 @@ foreach (dbFetchRows($sql) as $test_processor)
if (!$valid['processor'][$processor_type][$processor_index])
{
echo("-");
- dbDelete('Processors', '`processor_id` = ?', array($test_processor['processor_id']));
+ dbDelete('processors', '`processor_id` = ?', array($test_processor['processor_id']));
@laf
laf / gist:26ac954a18c48fa8cf69
Created April 18, 2015 19:03
php to call api for image
function hit_api($Url) {
global $graph_api_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Auth-Token: $graph_api_token"));
curl_setopt($ch, CURLOPT_USERAGENT, "Noc/1.0");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = curl_exec($ch);