This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# awk to extract the IPs of the clients connecting to a host who's IP is 10.0.0.1 | |
# from the result of a: | |
# tcpdump -n -l 'port 1234' > mytcpdump.dump | |
awk '$5 ~ /10\.0\.0\.1/ {split($3, a, "."); ip=sprintf("%d.%d.%d.%d",a[1],a[2],a[3],a[4]); array[ip]=ip } | |
END {for(i in array) {print array[i]}}' mytcpdump.dump | sort |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Gathering full statistics at 100% on all tables in Vertica. | |
# The tables with no row will always appear to have null statistics but that's ok. | |
# When a statistics ends it checks if the script has been running for more than | |
# 2 hours. If it's the case it stops. | |
# | |
# Prerequisites: | |
# a credentials file that looks like this: | |
# | |
# VERTICA_USER=MyUser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Little script that creates volumes, tag them and attach the volumes to several instances | |
for i in {1..4} ; do | |
for srv in db0$i db0$i ; do | |
srvid=$(aws ec2 describe-instances --filters "Name=tag:hostname,Values=${srv}" 'Name=vpc-id,Values=vpc-123456' --output text --query 'Reservations[].Instances[].InstanceId') | |
for dev in f g ; do | |
volid=$(aws ec2 create-volume --size 1024 --availability-zone us-east-1d --volume-type standard --output json | jq '.VolumeId' | tr -d '"') | |
aws ec2 create-tags --resources ${volid} --tags Key=hostname,Value=${srv} Key=vpc-id,Value=vpc-123456 Key=device,Value=/dev/sd${dev} | |
while true ; do | |
status=$(aws ec2 describe-volumes --volume-id ${volid} --query 'Volumes[].State' --output text) | |
if [ "${status}" = "available" ] ; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.hazelcast.client.config.ClientConfig; | |
import com.hazelcast.client.HazelcastClient; | |
import com.hazelcast.core.HazelcastInstance; | |
import com.hazelcast.core.IMap; | |
import com.hazelcast.monitor.LocalMapStats; | |
import com.hazelcast.monitor.NearCacheStats; | |
import com.hazelcast.core.IQueue; | |
import com.hazelcast.monitor.LocalQueueStats; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import os, os.path | |
# This scripts issues a "show stats" command (the '\n' at the end is mandatory to make it work) | |
# in a local haproxy socket file and prints the returned data. | |
sock_path="/var/run/haproxy-4.sock" | |
sock_cmd='show stat\n' | |
def getDataFromSocket(socket_path, cmd): | |
""" | |
Connects to a socket using the the local file given in socket_path, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# By status | |
netstat -an | awk '$6 ~ /^[A-Z_]+[1-2]*$/{a[$6]++} END {for (i in a) print a[i], "\t", i}' | sort -n | |
# By source IP:port | |
netstat -an | awk '$4 ~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+$/{a[$4]++} END {for (i in a) print a[i], "\t", i}' | sort -n | |
# By destination IP:port | |
netstat -an | awk '$5 ~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+$/{a[$5]++} END {for (i in a) print a[i], "\t", i}' | sort -n | |
# Just by destination IP | |
netstat -an | awk '$5 ~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+$/{a[gensub(/^(.+):.+$/, "\\1", "g", $5)]++} END {for (i in a) print a[i], "\t", i}' | sort -n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
This script tests if one or multiple templates can be rendered using Jinja2. | |
It also can check the expected output difference. | |
It populates the variables in for the jinja templates using yaml files. | |
Arguments: | |
-r, --root-dir: | |
Root directory to scan for *.tmpl files. Ignored with -t option. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import urllib2 | |
import base64 | |
import json | |
try: | |
url = 'https://localhost:15671/api/overview' | |
username = 'rabbitmquser' | |
password = 'rabbitmqpwd' | |
request = urllib2.Request(url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import base64 | |
import urllib2 | |
import json | |
import collectd | |
''' | |
Plugin config example: | |
---------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk 'match($0, /^([0-9]*-[0-9]*-[0-9]*) [0-9:, ]* \[ERROR\] \[[a-z\-0-9]+\] ([^ ]*) - (.*)$/, arr) {k=sprintf("%s %s - %s",arr[1], arr[2], arr[3]) ; if(k in counter){counter[k]++}else{counter[k]=1}} END {for(i in counter){printf "%d \t %s\n",counter[i],i}}' my_java_app.log | sort -k 1 -n | tail -20 | |
# Apache access log | |
awk 'match($0, /^([0-9\.\:]*) [^ ]* [^ ]* \[([0-9/a-zA-Z]*):.*/, arr) {k=sprintf("%s - %s\n", arr[1], arr[2]); if(k in counter){counter[k]++}else{counter[k]=1}} END {for(i in counter){printf "%d \t %s\n",counter[i],i}}' access.log| sort -k 1 -n | tail -20 |