Skip to content

Instantly share code, notes, and snippets.

@micw
micw / check_http_json
Created June 1, 2016 18:52
Simple nagios check that reads a json via http and converts it's output to a nagios check result
#!/usr/bin/python
#
'''
This script reads a JSON from an URL and converts it to nagios-plugin output.
The JSON must be in the following format (See https://nagios-plugins.org/doc/guidelines.html#AEN78
for Details about min/max/warn/crit values and units:
{
status: 'OK'|'WARNING'|'CRITICAL',
message: 'any text not containing single quote',
metrics: [ // optional
Menüpunkte vor Kunden verbergen (global)
[ ] E-Mail
[ ] Domains
[ ] FTP
[ ] Extras
[ ] Verzeichnisschutz
[ ] Pfadoptionen
[ ] System-Log
[ ] Traffic
@micw
micw / reverse-dns.txt
Created September 1, 2016 09:17
Reverse DNS Lookup of certain ip ranges to find spammer's hosts
This file has been truncated, but you can view the full file.
Ranges:
62.141.43.192-62.141.46.255
78.31.64.0-78.31.71.255
85.114.140.0-85.114.143.255
89.163.128.0-89.163.255.255
89.163.224.0-89.163.225.255
[*] Reverse Look-up of a Range
[*] Performing Reverse Lookup from 62.141.43.192 to 62.141.46.255
[*] PTR b086.blue.fastwebserver.de 62.141.43.208
# Generated by iptables-save v1.4.21 on Fri Sep 2 12:05:36 2016
*mangle
:PREROUTING ACCEPT [236900:348900702]
:INPUT ACCEPT [106994:147750890]
:FORWARD ACCEPT [129870:201086992]
:OUTPUT ACCEPT [105923:143036699]
:POSTROUTING ACCEPT [235793:344123691]
[0:0] -A INPUT -p esp -j MARK --set-xmark 0x1/0x1
[0:0] -A INPUT -p udp -m udp --dport 4500 -j MARK --set-xmark 0x1/0x1
COMMIT
#!/usr/bin/expect
set timeout 20
spawn telnet 192.168.1.250
expect "Login:"
send "!!Huawei\n"
expect "Password:"
send "@HuaweiHgw\n"
@micw
micw / update_mail_usage.sql
Last active September 15, 2016 09:18
SQL statement to update customer's email usage after manual changes
update panel_customers set
email_accounts_used=(select count(*) from mail_users where mail_users.customerid=panel_customers.customerid),
emails_used=(select count(*) from mail_virtual where mail_virtual.customerid=panel_customers.customerid),
email_quota_used=(select sum(quota) from mail_users where mail_users.customerid=panel_customers.customerid),
email_forwarders_used=(select sum(CHAR_LENGTH(replace(destination,email_full,''))-CHAR_LENGTH(replace(replace(destination,email_full,''),'@',''))) from mail_virtual where mail_virtual.customerid=panel_customers.customerid);
@micw
micw / LockingTest
Created December 1, 2016 08:25
Example how to synchronize task by an indentifier
package locking;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class LockingTest
{
@micw
micw / DNS-Server.md
Created February 8, 2017 19:32
Ideenskizze verteilter DNS-Server mit Github als Backend
  • Ablegen aller Zonefiles auf Github
  • Installation von 2-3 voneinander unabhängigen DNS-Server-Instanzen
  • Instanzen pullen zyklisch die Zonefiles -> Synchronisation zwischen Instanzen entfällt
  • Bringt alle Vorteile vom GIT-Workflow (Historie, Änderungswünsche per Pull-Request)
  • DNS-Server-Instanzen könnten mit minimalem Ansible-Script automatisch ausgerollt werden
@micw
micw / homeassistant.rc
Last active May 8, 2017 20:23
Homeassitant rc script
#!/sbin/openrc-run
CONFIG_DIR=/etc/homeassistant
USER=hass
GROUP=daemon
PIDFILE=/var/run/homeassistant/homeassistant.pid
CMD="/usr/bin/hass"
ARGS="-c ${CONFIG_DIR} --pid-file ${PIDFILE}"
@micw
micw / dnsbl.txt
Last active November 17, 2017 12:30
My private collection of spam-suspected ip ranges, used in my own DNSBL
# Watchlist - ip ranges where i got recently spam from - multiple occurences will be added to the dnsbl list below
# 2016-08
# mta861.chtah.net [63.236.31.147] CHEETAHMAIL
# portal03.datingdevelopment.website [63.141.227.108] DataShack, LC
# mtaout-36058-ewr.dynect.net [162.88.36.58] Dynamic Network Services
# a.mx.hnsc.org.br [177.54.61.124] "Kredit 2%"
# smtp.chinaemail.cn [211.152.62.117]
# s1.eleminate.co.ua [78.31.66.242] (vps66242.vs.webtropia.com)
# s1.eleminate.co.ua [78.31.66.242] (again - abuse reported to abuse@myloc.de)
# s1.dinnerie.biz.ua [62.141.44.57] (abuse reported to abuse@myloc.de)