Files

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

102 lines
4.2 KiB
PHP
Raw Permalink Normal View History

2020-09-18 08:12:07 -05:00
<?php
/*
* Openbsd.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/>.
2020-09-18 08:12:07 -05:00
*
* @package LibreNMS
2021-02-09 00:29:04 +01:00
* @link https://www.librenms.org
2020-09-18 08:12:07 -05:00
* @copyright 2020 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace LibreNMS\OS;
use LibreNMS\Interfaces\Polling\OSPolling;
use LibreNMS\OS\Shared\Unix;
use LibreNMS\RRD\RrdDefinition;
class Openbsd extends Unix implements OSPolling
{
2021-11-14 14:58:13 -06:00
public function pollOS(): void
2020-09-18 08:12:07 -05:00
{
2022-06-06 21:49:42 -07:00
$oids = \SnmpQuery::get([
'OPENBSD-PF-MIB::pfStateCount.0',
'OPENBSD-PF-MIB::pfStateSearches.0',
'OPENBSD-PF-MIB::pfStateInserts.0',
'OPENBSD-PF-MIB::pfStateRemovals.0',
'OPENBSD-PF-MIB::pfCntMatch.0',
'OPENBSD-PF-MIB::pfCntBadOffset.0',
'OPENBSD-PF-MIB::pfCntFragment.0',
'OPENBSD-PF-MIB::pfCntShort.0',
'OPENBSD-PF-MIB::pfCntNormalize.0',
'OPENBSD-PF-MIB::pfCntMemory.0',
'OPENBSD-PF-MIB::pfCntTimestamp.0',
'OPENBSD-PF-MIB::pfCntCongestion.0',
'OPENBSD-PF-MIB::pfCntIpOption.0',
'OPENBSD-PF-MIB::pfCntProtoCksum.0',
'OPENBSD-PF-MIB::pfCntStateMismatch.0',
'OPENBSD-PF-MIB::pfCntStateInsert.0',
'OPENBSD-PF-MIB::pfCntStateLimit.0',
'OPENBSD-PF-MIB::pfCntSrcLimit.0',
'OPENBSD-PF-MIB::pfCntSynproxy.0',
'OPENBSD-PF-MIB::pfCntTranslate.0',
'OPENBSD-PF-MIB::pfCntNoRoute.0',
])->values();
$this->graphOID('states', ['states' => $oids['OPENBSD-PF-MIB::pfStateCount.0']], 'GAUGE');
$this->graphOID('searches', ['searches' => $oids['OPENBSD-PF-MIB::pfStateSearches.0']]);
$this->graphOID('inserts', ['inserts' => $oids['OPENBSD-PF-MIB::pfStateInserts.0']]);
$this->graphOID('removals', ['removals' => $oids['OPENBSD-PF-MIB::pfStateRemovals.0']]);
$this->graphOID('matches', ['matches' => $oids['OPENBSD-PF-MIB::pfCntMatch.0']]);
$this->graphOID('drops', [
'badoffset' => $oids['OPENBSD-PF-MIB::pfCntBadOffset.0'],
'fragmented' => $oids['OPENBSD-PF-MIB::pfCntFragment.0'],
'short' => $oids['OPENBSD-PF-MIB::pfCntShort.0'],
'normalized' => $oids['OPENBSD-PF-MIB::pfCntNormalize.0'],
'memory' => $oids['OPENBSD-PF-MIB::pfCntMemory.0'],
'timestamp' => $oids['OPENBSD-PF-MIB::pfCntTimestamp.0'],
'congestion' => $oids['OPENBSD-PF-MIB::pfCntCongestion.0'],
'ipoption' => $oids['OPENBSD-PF-MIB::pfCntIpOption.0'],
'protocksum' => $oids['OPENBSD-PF-MIB::pfCntProtoCksum.0'],
'statemismatch' => $oids['OPENBSD-PF-MIB::pfCntStateMismatch.0'],
'stateinsert' => $oids['OPENBSD-PF-MIB::pfCntStateInsert.0'],
'statelimit' => $oids['OPENBSD-PF-MIB::pfCntStateLimit.0'],
'srclimit' => $oids['OPENBSD-PF-MIB::pfCntSrcLimit.0'],
'synproxy' => $oids['OPENBSD-PF-MIB::pfCntSynproxy.0'],
'translate' => $oids['OPENBSD-PF-MIB::pfCntTranslate.0'],
'noroute' => $oids['OPENBSD-PF-MIB::pfCntNoRoute.0'],
]);
}
2020-09-18 08:12:07 -05:00
2022-06-06 21:49:42 -07:00
private function graphOID(string $graphName, array $oids, string $type = 'COUNTER'): void
{
$rrd_def = RrdDefinition::make();
$fields = [];
foreach ($oids as $field => $oid) {
if (is_numeric($oid ?? null)) {
$rrd_def->addDataset($field, $type, 0);
$fields[$field] = $oid;
}
2020-09-18 08:12:07 -05:00
}
2022-06-06 21:49:42 -07:00
$tags = compact('rrd_def');
data_update($this->getDeviceArray(), "pf_$graphName", $tags, $fields);
2020-09-18 08:12:07 -05:00
2022-06-06 21:49:42 -07:00
$this->enableGraph("pf_$graphName");
2020-09-18 08:12:07 -05:00
}
}