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
@@ -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']);
+15
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');
+15 -7
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');
}
}
}