Skip to content

Instantly share code, notes, and snippets.

View rpetre's full-sized avatar

Petru Rațiu rpetre

  • RLUG
  • București, România
View GitHub Profile
@rpetre
rpetre / gist:83f3bad5184629c81a3e
Created May 1, 2015 13:40
Logstash debug environment
metrics:/etc/logstash # cat ls-debug
#!/bin/bash
echo "Wait for logstash to start, then paste test lines as needed"
echo "To finish, press ctrl-C , ctrl-D"
/opt/logstash/bin/logstash -f /etc/logstash/debug-conf.d/ -l /var/log/logstash/logstash-debug.log
metrics:/etc/logstash # ls debug-conf.d/
00_stdin_input.conf 31_nginx.conf 51_useragent.conf 52_querystring.conf 99_stdout_output.conf
metrics:/etc/logstash # cat debug-conf.d/00_stdin_input.conf
@rpetre
rpetre / gist:29a77df40a3b844c38ae
Created August 6, 2014 21:58
Example ES filter search. If I remove the "raw" part, no results are found.
{
"facets": {
"map": {
"terms": {
"field": "geoip.country_code2.raw",
"size": 100,
"exclude": []
},
"facet_filter": {
"fquery": {
##
## Put me in ~/.irssi/scripts, and then execute the following in irssi:
##
## /load perl
## /script load notify
##
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
@rpetre
rpetre / gist:5936033
Last active December 19, 2015 09:49
body common control
{
bundlesequence => { "suicide", "glados" };
}
body agent control
{
abortclasses => { "diediedie" };
}
@rpetre
rpetre / gist:5467994
Created April 26, 2013 15:08
Weird snmptable output. Client is Debian stable (5.4.3), server is centos 5.9 (5.3.2.2). Debian-to-Debian and centos-to-centos look ok, so does ifTable.
root@monitor:/etc/nagios3# snmptable -v2c -c COMMUNITY server.example.com dskTable
SNMP table: UCD-SNMP-MIB::dskTable
dskIndex dskPath dskDevice dskMinimum dskMinPercent dskTotal dskAvail dskUsed dskPercent dskPercentNode dskErrorFlag dskErrorMsg
1 / /dev/vdb -1 10 101573920 81299792 15031252 16 1 noError
2 /proc proc -1 10 0 0 0 0 100 noError
3 /sys sysfs -1 10 0 0 0 0 100 noError
4 /dev/pts devpts -1 10 0 0 0 0 100 noError
5 /boot /dev/vda1 -1 10 1019208 919724 46876 5 0 noError
6
vars:
"dir" string => "/etc/apache2/modules-enabled";
"index" slist => getindices("array");
"cindex[$(index)]" string => canonify("$(index)");
"files" slist => lsdir("$(dir)", ".*", "false");
classes:
"should_exist_$(cindex[$(index)])" expression => "any";
files:
"/$(dir)/$(index)"
create => "true";
@rpetre
rpetre / gist:4001370
Created November 2, 2012 13:28 — forked from nickanderson/gist:4001312
duplicate selection of variable
infra:~ # cf-agent -KI
!! Duplicate selection of value for variable "missing" in scope dead_hosts
!! Rule from /var/cfengine/inputs/actions/update.cf at/before line 38
!! Duplicate selection of value for variable "missing" in scope dead_hosts
!! Rule from /var/cfengine/inputs/actions/update.cf at/before line 38
-------------------
bundle agent dead_hosts {
vars:
"delay" int => "24";
@rpetre
rpetre / gist:4000674
Created November 2, 2012 12:01
duplicate selection of variable
infra:~ # cf-agent -KI
!! Duplicate selection of value for variable "missing" in scope dead_hosts
!! Rule from /var/cfengine/inputs/actions/update.cf at/before line 38
!! Duplicate selection of value for variable "missing" in scope dead_hosts
!! Rule from /var/cfengine/inputs/actions/update.cf at/before line 38
-------------------
bundle agent dead_hosts {
vars:
"delay" int => "24";
@rpetre
rpetre / gist:3930697
Created October 22, 2012 09:52
post-receive hook for cfengine deployment
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "prod" == "$branch" ]; then
git --work-tree=/var/cfengine/masterfiles checkout -f $branch
echo 'Changes pushed live.'
fi
@rpetre
rpetre / gist:3746346
Created September 18, 2012 22:24
Debian AMI building howto
For starters, you need an AWS account (not really getting into detail here, you only need a valid credit card for that with at least a couple of bucks on it). Make sure you sign on for EC2 and IAM at least.
In the IAM console I added a 'debuild' user, with permissions for everything ec2, made a key and cert for it (TODO: figure out finer-grained permissions, if possible).
Start some Linux instance in the region you want (I operate on eu-west-1, for now). Get root on it. mkdir /root/ec2 , go there.
wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip and http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip, unzip both of them.
Download https://github.com/andsens/ec2debian-build-ami/tarball/master, untar it. get the environment script at the end of README.md in a file and edit it. For the private cert and key, get the ones made for the debuild IAM user. AWS_USER_ID is actually the username (for a IAM user).