Skip to content

Instantly share code, notes, and snippets.

View BlackMaria's full-sized avatar
💭
hating social media and public status indicators

Hroðgar Skjöldung BlackMaria

💭
hating social media and public status indicators
  • 3rd planet left of the yellow one
View GitHub Profile
@BlackMaria
BlackMaria / xmmp_logstash_example.cf
Last active November 25, 2021 17:38
An example of using the jabber/xmpp output of Logstash. 1) Here I send messages that are trapped by grep and tagged "warn_me" to the the sorry sod that is on call. 2) If I get an alert from my monitoring system, I dump a list of all urls/systems that have gone from good to !good in the last 15 minutes. ( limit 20 and order by importance ). This …
output {
# <SNIP> other outputs <SNIP>
#
# Ping me if anything is about to explode, or if any important massage pass by
#
xmpp {
tags => 'warn_me'
host => "ejabberd.example.io"
message => "time='%{@timestamp}', host='%{@source_host}', tags='%{@tags}',path='%{@source_path}', type='%{@type}', field='%{@fields}' message='%{@message}',"
@BlackMaria
BlackMaria / logstash2sql.sh
Last active December 17, 2015 01:59
The following is an example of how one could send logs to mysql. If you have specific logs that you want to save in an SQL for some odd reason ( eg: you work for an old company that goes about things in archaic ways ).
-- NB '%{@type}' must be the same as table_name
-- create database logstash;
CREATE TABLE table_name (
table_name_id int(8) unsigned NOT NULL AUTO_INCREMENT,
logtime datetime DEFAULT NULL,
tags varchar(255) DEFAULT NULL,
message varchar(255) DEFAULT NULL,
PRIMARY KEY (table_name_id)
);
@BlackMaria
BlackMaria / logstash_debug_input.cf
Created May 7, 2013 14:07
Beast practice :) Since it takes so long for the monolithic logstash jar to start, I have started to add a back door in to all of my log stash configs. The following example shows me using a file in temp as a backdoor. If tcp 6501 seems off, I can dump data into the temp file to prove that the processing is still working, then we can diagnose th…
input{
file {
type => "custom_logger"
format => plain
path => "/tmp/debug_ls_input"
tags => [ "debug","no_alert" ]
}
tcp {
type => "custom_logger"
format => "plain"
@BlackMaria
BlackMaria / Makefile.sh
Created May 7, 2013 15:16
This is an example of the Makefile that I am using. I have git bits, auto dl of logstash if required version. AND this can build packages too. But you need a spec file
##########################################
# DEFAULTS FOR TESTING
##########################################
#
# First we set our defaults for our config tests
# We have been testing with logstash monolithic 1.1.9
# When testing the default is "-v" but you can try "make indexer LSFLAGS=--v" etc...
# We are using monolithic, unless we can work with the flatjar then use "make indexer LSTYPE=flatjar "
#
LSVERS=1.1.9
@BlackMaria
BlackMaria / AutoFS_example.sh
Last active December 17, 2015 02:59
Here is a quick script to get you started using AutoFS, with some minor explanation.
#!/bin/sh
#
#
# The following will Install autofs and create an AutoFS config that
# will mount SERVER:/EXPORT on MOUNT_POINT/$MOUNTNAME
#
# OPTION:
# You can also add all subdirs of a mount by adding a trailing "&"
# The following will mount each dir under /nfs/disks/ discreetly
# disks -rw server:/nfs/disks/&
@BlackMaria
BlackMaria / remote_wireshark.sh
Created May 8, 2013 13:04
How to use look at traffic form a remote system, piping a remote tcpdump to a local wireshark session.
#!/bin/sh
REMOTE_SYSTEM=$1
# You want to filter out your ssh pipe from tcpdump.
# So we need to know what our IP is that is connecting to the system
# IF behind a firewall you will want to fix this
#
# There are more elegant ways than this, I just can remember them :}
# LOCAL_IP=$(ifconfig |grep 192 | cut -d: -f2 | cut -d\ -f1)
#
@BlackMaria
BlackMaria / tarpm.sh
Last active December 17, 2015 03:08
Just another silly hack. I needed some files from a package, but the package was removed from the mirror! POW!
#!/bin/sh
#
# Some times you jsut want the files from an installed package...
#
for package in $( rpm -qa |egrep $1 )
do
rpm -ql $package | xargs tar -czvf $package.tgz
done
@BlackMaria
BlackMaria / mk_statelss_xcat_node.sh
Created May 24, 2013 19:39
This is an example of how I start to create a new stateless image
#!/bin/sh
# CREATE XCAT STATLESS IMAGE
# -- note you can not make a statless image for a distro other than the one this script is running on
# -- That is various tools will fail if you try to build fedora on centos, or centos6.1 on centos6.4
#
# Setup DISTRO Variables
DIST=`lsb_release -i | cut -d: -f2 | sed 's/\s//g' `
REL=`lsb_release -r | cut -d: -f2 | sed 's/\s//g' `
MAJ=`echo $REL | cut -d. -f1 | sed 's/\s//g' `
release=rh$MAJ
@BlackMaria
BlackMaria / mk_xcat_esx_node.sh
Last active March 23, 2021 23:05
The following is the quick and dirty template example of what I do when creating vmware nodes in xcat. If you are not using pxe nor vmware just exclude that line ( but it wont break anything if you keep it )
#!/bin/sh
# define vaiables
# In my real set up this is a lot more complex but if you are new to xcat
# this should be useful enought to get started
HOST_NAME=nodename
mac=00:50:56:b0:d0:00
ip=192.168.13.16
XCAT=192.168.13.100
OS=centos6
@BlackMaria
BlackMaria / get_centos_iso4xcat.sh
Created May 24, 2013 20:00
Getting new CentOS ISO's for a fresh install on xcat. NB I use a monthly rsync for all mirrors
DISTRO=centos6
DISTRO_VERS=6.4
ISO_ARCH=x86_64
ISO_DISTRO=CentOS-${DISTRO_VERS}
RPM_MIRRIR=http://centos.mirror.iweb.ca
getisos(){
for i in 1 2
do
# http://centos.mirror.iweb.ca/6.4/isos/x86_64/CentOS-6.4-x86_64-bin-DVD1.iso
wget ${RPM_MIRRIR}/${DISTRO_VERS}/isos/${ISO_ARCH}/${ISO_DISTRO}-${ISO_ARCH}-bin-DVD${i}.iso