Skip to content

Instantly share code, notes, and snippets.

View j-white's full-sized avatar

Jesse White j-white

View GitHub Profile
@j-white
j-white / ParseSNMPv3PduFromBytes.java
Created April 4, 2016 22:31
Parsing an SNMPv3 PDU from a hex string
package org.opennms.netmgt.snmp;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.opennms.netmgt.snmp.snmp4j.Snmp4JAgentConfig;
import org.snmp4j.MessageDispatcherImpl;
import org.snmp4j.TransportMapping;
import org.snmp4j.mp.MPv3;
import org.snmp4j.security.USM;
curl -H "Content-Type: application/json" --data @query.json http://0.0.0.0:8080/measuements/localhost:chassis:temps
where query.json contains:
{
"interval": "300s",
"datasources": [
{
"label" : "temperature",
"source" : "temperature",
"function" : "AVERAGE",
@j-white
j-white / factory.java
Created June 9, 2016 20:22
DetectorFactory
public interface DetectorFactory<T extends Detector> {
T createDetector();
}
@j-white
j-white / prometheus.yml
Created February 13, 2017 01:33
Prometheus configuration for OpenDaylight
global:
external_labels:
monitor: 'odl-monitor'
scrape_configs:
# Scrape Prometheus itself.
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
@j-white
j-white / build-opennms-docker.sh
Created February 15, 2017 20:32
Building Docker images for OpenNMS smoke tests
#!/bin/sh -e
export OPENNMS_RPM_ROOT=/tmp/docker_bamboo
mkdir -p $OPENNMS_RPM_ROOT
pushd $OPENNMS_RPM_ROOT
PLAN_KEY="OPENNMS-ONMS1240"
BUILD_ID="2"
RPM_VERSION="19.0.0-0.20170114.onms1240.features.strict.attribute.types.2"
rm -f *.rpm
{
"interval": "300s",
"datasources": [
{
"label": "ds1",
"source": "inlet",
"function": "AVERAGE",
"heartbeat": "600s"
}
],
#!/usr/bin/env python
import sys
import re
m = re.search('-XOutFile (.*?) ', ' '.join(sys.argv))
open(m.group(1), "w").close()
@j-white
j-white / ipc.properties
Last active September 7, 2017 17:52
Minion tweaks
# Increase the default JMS timeout to 2 minute
org.opennms.jms.timeout = 120000
# Increase the number of RPC threads (unlimited)
org.opennms.ipc.rpc.threads=1
org.opennms.ipc.rpc.queue.max=-1
org.opennms.ipc.rpc.threads.max=65536
@j-white
j-white / gist:93e48ccd48780e50c0e22e7b683c3e0c
Created September 8, 2017 16:45
OpenNMS Grafana JEXL Sum
for (ts : table.rowKeySet()) { sum = 0; for (column : table.columnKeySet()) { if (column != "timestamp" ) { sum = table.get(ts, column) + sum;} }; table.put(ts, "SUM", sum); }
@j-white
j-white / gist:2d41794ba86f2e45c8b19812848c95ca
Created September 25, 2017 13:43
OpenNMS Drool DAO Example
# cat /opt/opennms/etc/drools-engine.d/sample/drools-engine.xml
<?xml version="1.0" encoding="UTF-8"?>
<engine-configuration
xmlns="http://xmlns.opennms.org/xsd/drools-engine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.opennms.org/xsd/drools-engine /opt/opennms/share/xsds/drools-engine.xsd ">
<rule-set name="sampleRules">
<rule-file>sampleRules.drl</rule-file>
<event>uei.opennms.org/nodes/nodeDown</event>
<app-context>sample-context.xml</app-context>