Updated parse_location function

This commit is contained in:
laf
2015-11-18 22:12:27 +00:00
21 changed files with 285 additions and 15 deletions

View File

@@ -802,7 +802,7 @@ function ceph_rrd($gtype) {
* @return array Containing the lat and lng coords
**/
function parse_location($location) {
preg_match('/(\[)([0-9\. ]+), ([0-9\. ]+)(\])/', $location, $tmp_loc);
preg_match('/(\[)([0-9\. ]+),[ ]*([0-9\. ]+)(\])/', $location, $tmp_loc);
if (!empty($tmp_loc[2]) && !empty($tmp_loc[3])) {
return array('lat' => $tmp_loc[2], 'lng' => $tmp_loc[3]);
}

View File

@@ -107,6 +107,17 @@ $config['os'][$os]['over'][1]['text'] = 'Processor Usage';
$config['os'][$os]['over'][2]['graph'] = 'device_ucd_memory';
$config['os'][$os]['over'][2]['text'] = 'Memory Usage';
$os = 'infinity';
$config['os'][$os]['text'] = 'LigoWave Infinity';
$config['os'][$os]['type'] = 'wireless';
$config['os'][$os]['nobulk'] = 1;
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Device Traffic';
$config['os'][$os]['over'][1]['graph'] = 'device_processor';
$config['os'][$os]['over'][1]['text'] = 'Processor Usage';
$config['os'][$os]['over'][2]['graph'] = 'device_mempool';
$config['os'][$os]['over'][2]['text'] = 'Memory Usage';
// Ubiquiti
$os = 'unifi';
$config['os'][$os]['text'] = 'Ubiquiti UniFi';

View File

@@ -0,0 +1,22 @@
<?php
/*
* LibreNMS LigoWave Inifinity memory information module
*
* Copyright (c) 2015 Mike Rostermund <mike@kollegienet.dk>
* 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
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if ($device['os'] == 'infinity') {
echo 'INFINITY-MEMORY-POOL: ';
$total = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.1.0', '-OvQ');
$free = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.2.0', '-OvQ');
if (is_numeric($total) && is_numeric($free)) {
discover_mempool($valid_mempool, $device, 0, 'infinity', 'Memory', '1', null, null);
}
}

View File

@@ -0,0 +1,17 @@
<?php
/*
* LibreNMS LigoWave os detection module
*
* Copyright (c) 2015 Mike Rostermund <mike@kollegienet.dk>
* 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
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if (!$os) {
if (preg_match('/^NFT 2N/', $sysDescr)) {
$os = 'infinity';
}
}

View File

@@ -0,0 +1,24 @@
<?php
/*
* LibreNMS LigoWave Infinity CPU information module
*
* Copyright (c) 2015 Mike Rostermund <mike@kollegienet.dk>
* 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
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if ($device['os'] == 'infinity') {
echo 'LigoWave Infinity: ';
$descr = 'CPU';
$usage = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.4.2.1.3.2', '-Ovqn');
if (is_numeric($usage)) {
discover_processor($valid['processor'], $device, '.1.3.6.1.4.1.10002.1.1.1.4.2.1.3.2', '0', 'infinity', $descr, '1', $usage, null, null);
}
}
unset($processors_array);

View File

@@ -0,0 +1,17 @@
<?php
/*
* LibreNMS LigoWave Infinity memory information module
*
* Copyright (c) 2015 Mike Rostermund <mike@kollegienet.dk>
* 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
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
$total = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.1.0', '-OvQ');
$free = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.2.0', '-OvQ');
$mempool['total'] = $total * 1024;
$mempool['free'] = $free * 1024;
$mempool['used'] = ($mempool['total'] - $mempool['free']);

View File

@@ -0,0 +1,15 @@
<?php
/*
* LibreNMS LigoWave Infinity OS information module
*
* Copyright (c) 2015 Mike Rostermund <mike@kollegienet.dk>
* 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
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
$version = snmp_get($device, 'SNMPv2-MIB::sysDescr.0', '-Ovq');
$version = explode(' ', $version)[2];
$hardware = snmp_get($device, 'IEEE802dot11-MIB::dot11manufacturerProductName.5', '-Ovq');

View File

@@ -3,14 +3,22 @@
if ($device['os_group'] == 'unix') {
echo $config['project_name'].' UNIX Agent: ';
// FIXME - this should be in config and overridable in database
$agent_port = '6556';
$agent_port = get_dev_attrib($device,'override_Unixagent_port');
if (empty($agent_port)) {
$agent_port = $config['unix-agent']['port'];
}
if (empty($config['unix-agent']['connection-timeout'])) {
$config['unix-agent']['connection-timeout'] = $config['unix-agent-connection-time-out'];
}
if (empty($config['unix-agent']['read-timeout'])) {
$config['unix-agent']['read-timeout'] = $config['unix-agent-read-time-out'];
}
$agent_start = utime();
$agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent-connection-time-out']);
$agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent']['connection-timeout']);
// Set stream timeout (for timeouts during agent fetch
stream_set_timeout($agent, $config['unix-agent-read-time-out']);
stream_set_timeout($agent, $config['unix-agent']['read-timeout']);
$agentinfo = stream_get_meta_data($agent);
if (!$agent) {
@@ -108,7 +116,7 @@ if ($device['os_group'] == 'unix') {
if (in_array($key, array('apache', 'mysql', 'nginx', 'proxmox', 'ceph'))) {
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $key)) == '0') {
echo "Found new application '$key'\n";
dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key), 'applications');
dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key, 'app_status' => '', 'app_instance' => ''), 'applications');
}
}
}
@@ -120,7 +128,7 @@ if ($device['os_group'] == 'unix') {
foreach ($agent_data['app']['memcached'] as $memcached_host => $memcached_data) {
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'memcached', $memcached_host)) == '0') {
echo "Found new application 'Memcached' $memcached_host\n";
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_instance' => $memcached_host), 'applications');
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_status' => '', 'app_instance' => $memcached_host), 'applications');
}
}
}
@@ -134,7 +142,7 @@ if ($device['os_group'] == 'unix') {
$agent_data['app']['drbd'][$drbd_dev] = $drbd_data;
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'drbd', $drbd_dev)) == '0') {
echo "Found new application 'DRBd' $drbd_dev\n";
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_instance' => $drbd_dev), 'applications');
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_status' => '', 'app_instance' => $drbd_dev), 'applications');
}
}
}