Skip to content

Instantly share code, notes, and snippets.

public function saveCpeConfig(UbntCpe $cpe): bool
{
$config = $cpe->getConfigString();
try {
$ssh = $this->startSSH($cpe->ip);
} catch (SSHConnectionException $e) {
return false; // failed to connect
}
@murrant
murrant / PhotoAttributeHandler.php
Created June 7, 2021 17:12
Laravel Jetstream + LdapRecord AD Profile pictures
<?php
namespace App\Ldap;
use App\Models\User as DatabaseUser;
use Illuminate\Support\Str;
use LdapRecord\Models\ActiveDirectory\User as LdapUser;
use Storage;
class PhotoAttributeHandler
@murrant
murrant / build_bgp_peers.patch
Last active August 3, 2017 20:27
updated build_bgp_peers()
function build_bgp_peers($device, $data, $peer2)
{
d_echo("Peers : $data\n");
$remove_oid_prefixes = array(
'ARISTA-BGP4V2-MIB::aristaBgp4V2PeerRemoteAs.1.',
'CISCO-BGP4-MIB::cbgpPeer2RemoteAs.',
'BGP4-MIB::bgpPeerRemoteAs.',
'.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.'
);
@murrant
murrant / print_open_fds
Created August 1, 2017 03:27
Python script to list open file descriptors
descriptors = set()
def print_open_fds(print_all=False):
global descriptors
(frame, filename, line_number, function_name, lines, index) = inspect.getouterframes(inspect.currentframe())[1]
fds = set(os.listdir('/proc/self/fd/'))
new_fds = fds - descriptors
closed_fds = descriptors - fds
descriptors = fds
if print_all:
@murrant
murrant / os.yaml
Last active March 3, 2017 15:44
sysObjectId = foo OR sysObjectId = bar AND sysDescr = snafu
discovery:
- sysObjectId: foo
- { sysObjectId: bar, sysDescr: snafu }
# OR
discovery:
-
sysObjectId: foo
-
Scanning "/home/murrant/.snmpsim/variation" directory for variation modules...
Directory "/home/murrant/.snmpsim/variation" does not exist
Scanning "/usr/lib/python-exec/python3.5/../../../snmpsim/variation" directory for variation modules...
A total of 9 modules found in /usr/lib/python-exec/python3.5/../../../snmpsim/variation
Scanning "/usr/lib/python-exec/python3.5/../../../share/snmpsim/variation" directory for variation modules...
Directory "/usr/lib/python-exec/python3.5/../../../share/snmpsim/variation" does not exist
Scanning "/usr/lib64/python3.5/site-packages/snmpsim/variation" directory for variation modules...
Directory "/usr/lib64/python3.5/site-packages/snmpsim/variation" does not exist
Initializing variation modules...
Variation module "redis" load FAILED: Redis connect parameters not specified
@murrant
murrant / SNMP.php
Created December 6, 2016 02:15
Prototype snmp interface
namespace LibreNMS;
class SNMP
{
/**
* @param array $device
* @param string|array $oids single or array of oids to get
* @param string $mib Additional mibs to search, optionally you can specify full oid names
* @param string $mib_dir Additional mib directory, should be rarely needed, see definitions to add per os mib dirs
* @return array array or object of results, format to be determined
json($type) {
$class = 'App\Graphs\' . ucfirst($type);
$data=new $class($variable, $variable);
return $data->json();
}
png($type) {