Skip to content

Instantly share code, notes, and snippets.

View eliphaslevy's full-sized avatar

Eliphas Levy Theodoro eliphaslevy

View GitHub Profile
#!/bin/bash
# gist.github.com/eliphaslevy
# License: public domain
# Purpose: monitor interface for traffic spikes, capture some of it, and alert via email
# Run with environment DEBUG=1 set to see its output to terminal,
# otherwise will use 'logger' to write to syslog.
# I have put it on /etc/cron.d/cron.hourly to ensure it keeps running.
MYNAME=$(basename $0)
#!/usr/bin/env python3
#coding:utf8
# vim:et:ts=4:sw=4:sts=4:ai:si:foldmethod=indent
# shamelessly copied from perl 20_convert_geolite2
# https://github.com/sander1/GeoLite2xtables
# (no perl modules in my server)
import os, sys, ipaddress
@eliphaslevy
eliphaslevy / rip_multicast_leave.patch
Created July 7, 2021 21:44
ripd multicast leave even when interface is down - for FRR6 - fixes igmp membership leak
Fix for:
RIP: can't setsockopt IP_ADD_MEMBERSHIP No buffer space available
RIP: multicast join failed, interface FOO not running
Based on the patch for quagga from Michal Ruzicka
https://lists.quagga.net/pipermail/quagga-dev/2006-August/020891.html
Which was based on the one for zebra from Sergey Vlasov
https://bugzilla.altlinux.org/show_bug.cgi?id=3915
--- frr-6.0.3.orig/ripd/ripd.h 2021-07-07 14:02:30.054026597 -0300
+++ frr-6.0.3/ripd/ripd.h 2021-07-07 14:09:50.546026022 -0300
@@ -249,6 +249,9 @@
@eliphaslevy
eliphaslevy / Zabbix-LLD-MultiItemChart.py
Last active July 28, 2020 20:55
Create chart with multiple items from LLD
#!/usr/bin/env python2
# coding:utf-8
# vim:ts=8:sw=8:si:ci:ai
"""
Automatically create zabbix host graphs based on LLD items.
Recursively gets all hosts that have the template(s) and adds/updates
one or more charts on each host.
Add the ID of the template to masterTemplates dict, and add graph filters
that will match the items on the host to graphItems.
Unlike the perl script linked below, this script was built to generate one
@eliphaslevy
eliphaslevy / MktTimeToSeconds.c
Created June 12, 2018 16:49
Mikrotik Time to Seconds
:global timeToSeconds do={
:local iSeconds 0; :local upTxt $1; :local daypos 0;
:for pos from=0 to=([:len $upTxt] - 8) do={
:if ([:pick $upTxt $pos] = "w") do={
:set iSeconds ( [:pick $upTxt 0 ($pos)] * 7 * 24 * 60 * 60 );
:set daypos ($pos+1);
}
:if ([:pick $upTxt $pos] = "d") do={
:set iSeconds ( $iSeconds + ([:pick $upTxt ($daypos) ($pos)] * 24 * 60 * 60) );
}