Skip to content

Instantly share code, notes, and snippets.

CREATE TABLE snmp.ifDescr (
device_id BIGINT NOT NULL REFERENCES devices,
ifIndex BIGINT NOT NULL,
ifDescr TEXT,
valid TSTZRANGE NOT NULL DEFAULT tstzrange(now(), 'infinity', '[)'),
EXCLUDE USING GIST (device_id WITH =, ifIndex WITH =, valid WITH &&),
EXCLUDE USING GIST (device_id WITH =, ifDescr WITH =, valid WITH &&)
);
CREATE OR REPLACE FUNCTION set_ifdescr(xdevice_id bigint, xifIndex bigint, xifDescr text)
mod parallel {
use std::{sync, thread};
use std::sync::atomic::Ordering::Relaxed;
pub fn run<F, I, O>(jobs: Vec<I>, num_workers: usize, f: F) -> Vec<O>
where F: Fn(usize, &I) -> O,
F: Send + Sync + 'static,
I: Send + Sync + 'static,
O: Send + Sync + 'static
{
@hroi
hroi / playground.rs
Created February 15, 2016 00:56 — forked from anonymous/playground.rs
Shared via Rust Playground
#![allow(dead_code)]
use std::result;
use std::net::Ipv4Addr;
use std::fmt;
const BGP_MARKER: [u8; 16] = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,];
#[derive(Debug)]
struct AutNum(u32);
> cargo bench --features full-bgp-tests -- full_bgp_tests::lookup
Running target/release/treebitmap-09703315f73df9cc
running 10 tests
test full_bgp_tests::lookup4_random_id_check ... ignored
test full_bgp_tests::lookup4_apple ... bench: 46 ns/iter (+/- 16)
test full_bgp_tests::lookup4_googledns ... bench: 67 ns/iter (+/- 16)
test full_bgp_tests::lookup4_localhost ... bench: 14 ns/iter (+/- 3)
test full_bgp_tests::lookup4_netgroup ... bench: 54 ns/iter (+/- 28)
test full_bgp_tests::lookup4_random_every ... bench: 96 ns/iter (+/- 17)
@hroi
hroi / failoverstates.txt
Last active January 6, 2017 10:00
ASA failover modes
Primary active unit:
SNMP table: CISCO-FIREWALL-MIB::cfwHardwareStatusTable
index cfwHardwareInformation cfwHardwareStatusValue cfwHardwareStatusDetail
netInterface Failover LAN Interface up failover Management0/0.1
primaryUnit Primary unit (this device) active Active unit
secondaryUnit Secondary unit standby Standby unit
Secondary standby unit:
@hroi
hroi / discovery-sensor-cisco-firewall-mib.patch
Created August 14, 2015 09:25
Add support for monitoring Cisco ASA failover cluster member status
Index: includes/definitions/status.inc.php
===================================================================
--- includes/definitions/status.inc.php (revision 6856)
+++ includes/definitions/status.inc.php (working copy)
@@ -53,6 +53,22 @@
$config['status_states']['cisco-stackwise-redundant-state'][1] = array('name' => 'true', 'event' => 'ok');
$config['status_states']['cisco-stackwise-redundant-state'][2] = array('name' => 'false', 'event' => 'warning');
+// CISCO-FIREWALL-MIB
+$config['status_states']['cisco-firewall-hardware-primary-state'][1] = array('name' => 'other', 'event' => 'warn');
@hroi
hroi / zsh
Created August 10, 2015 13:42
export PROMPT="%B%F{white}%(4~|⋯|)%3~%F{yellow} %(?.😑 .😫 [%?]) %b%f%k"
@hroi
hroi / list-esx-nets.rb
Created November 15, 2012 17:07
util to help switchport configuration in a vmware environment
#!/usr/bin/env jruby
require 'java'
require 'dom4j-1.6.1.jar'
require 'vijava51b20120923.jar'
(server, username, password, clustername) = ARGV
url = "https://#{server}/sdk"
@hroi
hroi / login-config.xml
Created August 7, 2011 17:02
torquebox.yml
<application-policy name="circuitude-authentication-ldap">
<authentication>
<login-module code="org.jboss.security.auth.spi.LdapExtLoginModule" flag="required" >
<module-option name="java.naming.provider.url">ldap://REDACTED:389/</module-option>
<module-option name="java.naming.security.authentication">simple</module-option>
<module-option name="bindDN">cn=Twiddle_LDAP_Resource,REDACTED</module-option>
<module-option name="bindCredential">REDACTED</module-option>
<module-option name="baseCtxDN">ou=REDACTED</module-option>
<module-option name="baseFilter">(samaccountname={0})</module-option>
<module-option name="rolesCtxDN">REDACTED</module-option>
@hroi
hroi / dsk.txt
Created July 20, 2011 21:40
macbook disk
Name : ST9500420ASG Media
Type : Disk
Partition Map Scheme : GUID Partition Table
Disk Identifier : disk0
Media Name : ST9500420ASG Media
Media Type : Generic
Connection Bus : SATA
Device Tree : IODeviceTree:/PCI0@0/SATA@1F,2/PRT0@0/PMP@0
Writable : Yes