Skip to content

Instantly share code, notes, and snippets.

@weirdbricks
weirdbricks / ec2_group_set
Created October 14, 2017 00:08 — forked from viesti/ec2_group_set
Alter security groups on EC2 nodes
#!/usr/bin/python
from boto.ec2 import connect_to_region
from boto.ec2.group import Group
from pprint import pprint
def main():
module = AnsibleModule(
argument_spec = dict(
ec2_id = dict(required=True),
@weirdbricks
weirdbricks / check_permissions.sh
Created March 13, 2017 02:33
Nagios script that checks permissions for a file
#!/bin/bash
################################
# Lampros Chaidas #
# 03/12/2017 #
################################
stat=/usr/bin/stat
help="Usage: $0 filename_to_check user group octal_permissions\nExample: $0 /usr/bin/stat root root 755"
@weirdbricks
weirdbricks / ruby-yaml-validate.sh
Created January 27, 2017 01:11 — forked from xiii/ruby-yaml-validate.sh
Validate YAML in ruby - useful for hiera
#!/bin/bash
#
# Efstathios Xagoraris <sxagoraris@gmail.com>
# Validate YAML files using ruby
#
ruby=/usr/share/logstash/vendor/jruby/bin/jruby
if [ $# -eq 0 ]
@weirdbricks
weirdbricks / check_docker_container.sh
Created January 20, 2017 02:35 — forked from ekristen/check_docker_container.sh
Bash Script for Nagios to Check Status of Docker Container
#!/bin/bash
# Author: Erik Kristensen
# Email: erik@erikkristensen.com
# License: MIT
# Nagios Usage: check_nrpe!check_docker_container!_container_id_
# Usage: ./check_docker_container.sh _container_id_
#
# The script checks if a container is running.
# OK - running
@weirdbricks
weirdbricks / create_files.rb
Last active November 21, 2016 23:27
create millions of files for testing purposes
#!/bin/env ruby
require 'thread/pool'
require 'ruby-progressbar'
require 'securerandom'
require 'etc' # to get the number of cores - http://stackoverflow.com/a/34215193
require 'colorize'
require 'sys/filesystem'
include Sys
@weirdbricks
weirdbricks / script.rb
Last active August 29, 2015 14:12
atlantic.net describe instances in Ruby
## Lampros Chaidas
## 01/01/2015
## Sample code to list instances from Atlantic.net using Ruby
# tested with Ruby 1.9.3
require 'rest_client'
require 'digest'
require 'uuidtools'
# replace with your access key
@weirdbricks
weirdbricks / python_install.txt
Created October 11, 2014 22:21
Install Python on FreeBSD via Ansible
ansible all -m raw -a 'env ASSUME_ALWAYS_YES=YES pkg install python'
freebsd-3 | success | rc=0 >>
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100% 944 B 0.9k/s 00:01
Fetching digests.txz: 100% 2 MB 2.1M/s 00:01
Fetching packagesite.txz: 100% 5 MB 2.7M/s 00:02
Processing new repository entries: 100%
FreeBSD repository update completed. 23551 packages processed:
0 updated, 0 removed and 23551 added.
Updating database digests format: 100%
@weirdbricks
weirdbricks / cat.rb
Created September 16, 2014 23:00
cat replacement in ruby
#!/usr/bin/ruby
#by Lampros Chaidas
#cat replacement in ruby - if the -n switch is provided the lines start with a number
#check if the -n option is given to prepend each line with a line number
if ARGV.include? "-n"
@lines=true
ARGV.delete("-n")
end
@weirdbricks
weirdbricks / wc.rb
Created September 16, 2014 22:57
wc replacement in ruby
#!/usr/bin/ruby
#By Lampros Chaidas
#wc replacement in ruby
input = $stdin.read
words = input.split(" ").count
newlines = input.lines.count
characters = input.length
@weirdbricks
weirdbricks / memory-cloudwatch.yaml
Created June 15, 2014 22:22
ansible playbook to add memory metrics for cloudwatch - RedHat family only
- hosts: all
vars:
ec2_access_key: "AKIA-----------A"
ec2_secret_key: "i-------------/--------A"
remote_user: ec2-user
sudo: yes
tasks:
- name: "make sure package perl-switch is installed for the monitoring scripts"
yum: name=perl-Switch state=present
when: ansible_os_family == "RedHat"