Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

179 lines
6.2 KiB
PHP
Raw Permalink Normal View History

2018-02-05 07:39:13 -06:00
<?php
/**
* Sgos.php
*
* -Description-
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2021-02-09 00:29:04 +01:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2018-02-05 07:39:13 -06:00
*
2021-02-09 00:29:04 +01:00
* @link https://www.librenms.org
2021-09-10 20:09:53 +02:00
*
2018-02-05 07:39:13 -06:00
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\OS;
use LibreNMS\Device\Processor;
2023-10-04 10:32:59 -05:00
use LibreNMS\Interfaces\Data\DataStorageInterface;
2018-02-05 07:39:13 -06:00
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
2021-11-14 14:58:13 -06:00
use LibreNMS\Interfaces\Polling\OSPolling;
2018-02-05 07:39:13 -06:00
use LibreNMS\OS;
2021-11-14 14:58:13 -06:00
use LibreNMS\RRD\RrdDefinition;
2018-02-05 07:39:13 -06:00
2021-11-14 14:58:13 -06:00
class Sgos extends OS implements ProcessorDiscovery, OSPolling
2018-02-05 07:39:13 -06:00
{
2023-10-04 10:32:59 -05:00
public function pollOS(DataStorageInterface $datastore): void
2021-11-14 14:58:13 -06:00
{
$oid_list = [
'sgProxyHttpClientRequestRate.0',
'sgProxyHttpClientConnections.0',
'sgProxyHttpClientConnectionsActive.0',
'sgProxyHttpClientConnectionsIdle.0',
'sgProxyHttpServerConnections.0',
'sgProxyHttpServerConnectionsActive.0',
'sgProxyHttpServerConnectionsIdle.0',
];
$sgos = snmp_get_multi($this->getDeviceArray(), $oid_list, '-OUQs', 'BLUECOAT-SG-PROXY-MIB');
if (is_numeric($sgos[0]['sgProxyHttpClientRequestRate'] ?? null)) {
$tags = [
'rrd_def' => RrdDefinition::make()->addDataset('requests', 'GAUGE', 0),
];
$fields = [
'requests' => $sgos[0]['sgProxyHttpClientRequestRate'],
];
2023-10-04 10:32:59 -05:00
$datastore->put($this->getDeviceArray(), 'sgos_average_requests', $tags, $fields);
2021-11-14 14:58:13 -06:00
$this->enableGraph('sgos_average_requests');
echo ' HTTP Req Rate';
}
if (is_numeric($sgos[0]['sgProxyHttpClientConnections'] ?? null)) {
$tags = [
'rrd_def' => RrdDefinition::make()->addDataset('client_conn', 'GAUGE', 0),
];
$fields = [
'client_conn' => $sgos[0]['sgProxyHttpClientConnections'],
];
2023-10-04 10:32:59 -05:00
$datastore->put($this->getDeviceArray(), 'sgos_client_connections', $tags, $fields);
2021-11-14 14:58:13 -06:00
$this->enableGraph('sgos_client_connections');
echo ' Client Conn';
}
if (is_numeric($sgos[0]['sgProxyHttpServerConnections'] ?? null)) {
$tags = [
'rrd_def' => RrdDefinition::make()->addDataset('server_conn', 'GAUGE', 0),
];
$fields = [
'server_conn' => $sgos[0]['sgProxyHttpServerConnections'],
];
2023-10-04 10:32:59 -05:00
$datastore->put($this->getDeviceArray(), 'sgos_server_connections', $tags, $fields);
2021-11-14 14:58:13 -06:00
$this->enableGraph('sgos_server_connections');
echo ' Server Conn';
}
if (is_numeric($sgos[0]['sgProxyHttpClientConnectionsActive'] ?? null)) {
$tags = [
'rrd_def' => RrdDefinition::make()->addDataset('client_conn_active', 'GAUGE', 0),
];
$fields = [
'client_conn_active' => $sgos[0]['sgProxyHttpClientConnectionsActive'],
];
2023-10-04 10:32:59 -05:00
$datastore->put($this->getDeviceArray(), 'sgos_client_connections_active', $tags, $fields);
2021-11-14 14:58:13 -06:00
$this->enableGraph('sgos_client_connections_active');
echo ' Client Conn Active';
}
if (is_numeric($sgos[0]['sgProxyHttpServerConnectionsActive'] ?? null)) {
$tags = [
'rrd_def' => RrdDefinition::make()->addDataset('server_conn_active', 'GAUGE', 0),
];
$fields = [
'server_conn_active' => $sgos[0]['sgProxyHttpServerConnectionsActive'],
];
2023-10-04 10:32:59 -05:00
$datastore->put($this->getDeviceArray(), 'sgos_server_connections_active', $tags, $fields);
2021-11-14 14:58:13 -06:00
$this->enableGraph('sgos_server_connections_active');
echo ' Server Conn Active';
}
if (is_numeric($sgos[0]['sgProxyHttpClientConnectionsIdle'] ?? null)) {
$tags = [
'rrd_def' => RrdDefinition::make()->addDataset('client_idle', 'GAUGE', 0),
];
$fields = [
'client_idle' => $sgos[0]['sgProxyHttpClientConnectionsIdle'],
];
2023-10-04 10:32:59 -05:00
$datastore->put($this->getDeviceArray(), 'sgos_client_connections_idle', $tags, $fields);
2021-11-14 14:58:13 -06:00
$this->enableGraph('sgos_client_connections_idle');
echo ' Client Conne Idle';
}
if (is_numeric($sgos[0]['sgProxyHttpServerConnectionsIdle'] ?? null)) {
$tags = [
'rrd_def' => RrdDefinition::make()->addDataset('server_idle', 'GAUGE', 0),
];
$fields = [
'server_idle' => $sgos[0]['sgProxyHttpServerConnectionsIdle'],
];
2023-10-04 10:32:59 -05:00
$datastore->put($this->getDeviceArray(), 'sgos_server_connections_idle', $tags, $fields);
2021-11-14 14:58:13 -06:00
$this->enableGraph('sgos_server_connections_idle');
echo ' Server Conn Idle';
}
}
2018-02-05 07:39:13 -06:00
/**
* Discover processors.
* Returns an array of LibreNMS\Device\Processor objects that have been discovered
*
* @return array Processors
*/
public function discoverProcessors()
{
2020-09-18 08:12:07 -05:00
$data = snmpwalk_group($this->getDeviceArray(), 'sgProxyCpuCoreBusyPerCent', 'BLUECOAT-SG-PROXY-MIB');
2018-02-05 07:39:13 -06:00
$processors = [];
$count = 1;
foreach ($data as $index => $entry) {
$processors[] = Processor::discover(
$this->getName(),
$this->getDeviceId(),
".1.3.6.1.4.1.3417.2.11.2.4.1.8.$index",
zeropad($index),
"Processor $count",
1,
$entry['s5ChasUtilCPUUsageLast10Minutes']
);
$count++;
}
return $processors;
}
}