Skip to content

Instantly share code, notes, and snippets.

@jazzl0ver
jazzl0ver / cfgmaker.patch
Last active April 7, 2016 14:06
Adds VLAN information to MRTG title for Cisco switches
--- cfgmaker.ORG 2012-11-12 06:44:43.000000000 -0500
+++ cfgmaker 2016-03-24 12:29:08.318018921 -0400
@@ -691,7 +691,9 @@
"$$i{Descr} $$i{ifAlias} $$i{CiscolocIfDescr}";
last};
/^name$/ && do {$if_title_desc = "#".$$i{Name} if $$i{Name}; last};
- /^catname$/ && do {$if_title_desc = "$if_port_name"; last};
+ /^catname$/ && do {$if_title_desc = "$if_port_name"." (".$$i{Name}.
+ ($$i{vmVlan} ? " - VLAN ".$$i{vmVlan} : " - dot1q")
+ .")"; last};
#!/usr/bin/perl -w
#
#This polls multiple haproxy servers via their admin stats urls and sums up statistics.
#Scenario for usage is when you have multiple HaProxy boxes behind a load balancer and want to view the
# "sum total" of some key statistics like Bytes In/Out, Sessions etc across all HAProxy servers.
#Usage: Assuming you want to sum up stats across ha proxies lb1,2 and 3 which are have stats available via http://lbname:8080/statspath.
# /etc/nagios3/scripts/check_haproxy_all.pl -u lb1.domain.com,lb2.domain.com,lb3.domain.com -U admin -a '/statspath' -P 'PASSWORD'
# See http://www.onepwr.org/haproxy-consolidated-stats for detailed info.
use strict; # always! :)
@jazzl0ver
jazzl0ver / ipcad_cp_tolog.sh
Last active April 14, 2016 17:51
pfsense ipcad data to squid's access log transfer for lightsquid stats generation, using captive portal db to resolve IP addresses into user names (based on https://dl.dropboxusercontent.com/u/16308481/tolog.sh from http://ru.doc.pfsense.org/index.php/%D0%9F%D0%BE%D0%B4%D1%81%D1%87%D0%B5%D1%82_%D1%82%D1%80%D0%B0%D1%84%D0%B8%D0%BA%D0%B0_%D1%81_%D…
#!/bin/sh
#
# IPCAD data transfer for LightSquid on pfSense
#
ttime=`/usr/bin/rsh 127.0.0.1 show ip accounting | grep 'Accounting data saved' | awk '{print ($4)}'`
/usr/bin/rsh 127.0.0.1 clear ip accounting
/usr/bin/rsh 127.0.0.1 show ip accounting checkpoint | \
@jazzl0ver
jazzl0ver / check_ip.php
Last active April 14, 2016 17:44
pfsense squid3 captive portal authentication script (bug fixed version)
#!/usr/local/bin/php -q
<?php
/*
check_ip.php
part of pfSense (https://www.pfSense.org/)
Copyright (C) 2013-2015 Marcello Coutinho
Copyright (C) 2015 ESF, LLC
All rights reserved.
Redistribution and use in source and binary forms, with or without
@jazzl0ver
jazzl0ver / Ftp2Netbox.lua
Created May 23, 2016 14:34
Conversion script from FarFTP to NetBox for FAR 3.0.4545 x86 (offsite - http://forum.farmanager.com/viewtopic.php?p=108838#p108838)
local function hex1(hc)
if hc >= 0x30 and hc <= 0x39 then return hc-0x30 end -- 0..9
if hc >= 0x61 and hc <= 0x66 then return hc-0x61+10 end -- a..f
if hc >= 0x41 and hc <= 0x46 then return hc-0x41+10 end -- A..F
return 0;
end
local function hex2(hstr, pos)
return 16*hex1(string.byte(hstr,pos)) + hex1(string.byte(hstr,pos+1))
end
@jazzl0ver
jazzl0ver / check_md3000i_perf.pl
Last active May 25, 2016 16:23
Check array I/O performance on Dell MD3000i/MD3200i/etc iSCSI-SAN
#!/usr/bin/perl -w
#
# Check array performance on Dells MD3000i iSCSI-SAN
# You need SMcli installed to use this check. It's part of
# Dells MDSM package.
# Also Sys::Alone Perl library is required
#
# Performance counters description: http://en.community.dell.com/techcenter/storage/w/wiki/md3000i-performance-monitoring
#
@jazzl0ver
jazzl0ver / haconfig.sh
Created July 12, 2016 14:57 — forked from jlazic/haconfig.sh
Split monolithic HAProxy configuration
#!/bin/bash
#Requirements: etckeeper, diffcolor
#This script concatenates multiple files of haproxy configuration into
#one file, and than checks if monolithic config contains errors. If everything is
#OK with new config script will write new config to $CURRENTCFG and reload haproxy
#Also, script will commit changes to etckeeper, if you don't use etckeeper you
#should start using it.
#Script assumes following directory structure:
#/etc/haproxy/conf.d/
@jazzl0ver
jazzl0ver / notify-mysql-deadlock.sh
Last active March 7, 2021 18:20
Detect mysql deadlocks and notify developers by email. Notification sent on new deadlocks only
#!/bin/bash
#
# Detects mysql deadlocks and notify developers by email
# Notification sent on new deadlocks only
# monuser must have "PROCESS" permission in mysql server
# Set EXCLUDE_PTRN to avoid alerting if the pattern was found
#
host=$1
user=monuser
#!/bin/bash
#
# Iterates over all available RDS instances in all regions and creates snapshots of them along with dumping (if necessary). Dump
# is encrypted if the database itself is encrypted at rest. Only dumping MySQL instances is implemented at the moment
#
# Usage:
# $ aws configure - configure AWS access and secret keys
# $ vi .rds_backup - setup environment variables required for the script (see below)
# $ source .rds_backup - export the environment variables
# $ ./rds_backup.sh [(makedump|anyotherword) [db-instance]]
@jazzl0ver
jazzl0ver / kcompat.h.patch
Last active April 6, 2017 14:59
Fix kcompat.h in ixgbevf-2.16.4 to be able to compile under CentOS 6.8 2.6.32-642.15.1.el6.x86_64 kernel
--- src/kcompat.h.org 2015-09-21 23:09:52.000000000 +0000
+++ src/kcompat.h 2017-04-03 10:31:09.000000000 +0000
@@ -3347,7 +3347,7 @@
#ifndef vlan_get_protocol
static inline __be16 __kc_vlan_get_protocol(const struct sk_buff *skb)
{
- if (vlan_tx_tag_present(skb) ||
+ if (skb_vlan_tag_get(skb) ||
skb->protocol != cpu_to_be16(ETH_P_8021Q))
return skb->protocol;