Skip to content

Instantly share code, notes, and snippets.

@n-st
n-st / snmp-tunnel.sh
Last active December 3, 2022 18:07
Forward SNMP requests over a SSH connection (e.g. for use with Observium or other monitoring tools).
#!/bin/bash
# This script will make a local SNMP server accessible on a remote system by
# forwarding its UDP traffic over an SSH connection.
# To do this, the following port forwardings are applied (in this order):
# - local TCP port 42061 (arbitrary) to local UDP port 161 (SNMP)
# - remote TCP port 42061 to local TCP port 42061 (via SSH connection)
# - remote UDP port 42061 to remote TCP port 42061
@n-st
n-st / post-receive
Last active January 3, 2016 07:29
Git post-receive hook to rebase dev branch onto master (if no changes have been made to the working copy)
#!/bin/bash
cd ..
GIT_DIR='.git'
while read oldrev newrev ref
do
if [ "$ref" != "refs/heads/dev" ]
then
echo -e "\e[33mPushed branch isn't 'dev'. Skipping rebase dev->master.\e[0m"
@n-st
n-st / ds18b20
Last active December 28, 2015 15:19
Munin plugin that reads any number of DS18B20 temperature sensors using the w1-gpio and w1_therm kernel modules.
#!/usr/bin/env python
import sys
import os
import re
from syslog import syslog
temperatureRegex = r't=(-?\d+)'
sensorNames = {