librenms-librenms/includes/polling/os/sonicwall.inc.php
Tony Murray fad0bffc43 Escape SNMP & IPMI shell commands (#9537)
hopefully doesn't break anything
Mostly issues with snmp oids and options containing spaces.  Try to remove all of those.

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
After you are done testing, you can remove the changes with `./scripts/github-remove`.  If there are schema changes, you can ask on discord how to revert.
2018-12-16 13:42:50 +00:00

34 lines
1.6 KiB
PHP

<?php
// SNMPv2-SMI::enterprises.8741.2.1.1.1.0 = STRING: "NSA 2400"
// SNMPv2-SMI::enterprises.8741.2.1.1.2.0 = STRING: "0017C599BD08"
// SNMPv2-SMI::enterprises.8741.2.1.1.3.0 = STRING: "SonicOS Enhanced 5.8.1.7-4o"
// SNMPv2-SMI::enterprises.8741.2.1.1.4.0 = STRING: "5.0.3.3"
// SNMPv2-SMI::enterprises.8741.2.1.1.1.0 = STRING: "TZ 210"
// SNMPv2-SMI::enterprises.8741.2.1.1.2.0 = STRING: "0017C568903C"
// SNMPv2-SMI::enterprises.8741.2.1.1.3.0 = STRING: "SonicOS Enhanced 5.6.0.11-61o"
// SNMPv2-SMI::enterprises.8741.2.1.1.4.0 = STRING: "5.0.2.11"
use LibreNMS\RRD\RrdDefinition;
$hardware = trim(snmp_get($device, '.1.3.6.1.4.1.8741.2.1.1.1.0', '-OQv', '', ''), '" ');
$serial = trim(snmp_get($device, '.1.3.6.1.4.1.8741.2.1.1.2.0', '-OQv', '', ''), '" ');
$fwversion = trim(snmp_get($device, '.1.3.6.1.4.1.8741.2.1.1.3.0', '-OQv', '', ''), '" ');
$romversion = trim(snmp_get($device, '.1.3.6.1.4.1.8741.2.1.1.4.0', '-OQv', '', ''), '" ');
$version = "(Firmware $fwversion / ROM $romversion)";
$oids = ['sonicCurrentConnCacheEntries.0', 'sonicMaxConnCacheEntries.0'];
$data = snmp_get_multi($device, $oids, '-OQUs', 'SONICWALL-FIREWALL-IP-STATISTICS-MIB');
if (is_numeric($data)) {
$rrd_def = RrdDefinition::make()
->addDataset('activesessions', 'GAUGE', 0)
->addDataset('maxsessions', 'GAUGE', 0);
$fields = array(
'activesessions' => $data[0]['sonicCurrentConnCacheEntries'],
'maxsessions' => $data[0]['sonicMaxConnCacheEntries'],
);
$tags = compact('rrd_def');
data_update($device, 'sonicwall_sessions', $tags, $fields);
$graphs['sonicwall_sessions'] = true;
}