Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# checks for the number of AWS snapshots and allows alerts when threshold is met
# example usage:
# ./check_aws_snapshots.sh -w <integer> -c <integer>
###
### USES ANSIBLE to put AWS KEYs as VARS
### USES ANSIBLE to define NAGIOS REGION
###
### REQUIRES AWS CLI : https://aws.amazon.com/cli/
#!/bin/bash
#
# checks for the number of AWS AMIs and allows alerts when threshold is met
# example usage:
# ./check_aws_amis.sh -w <integer> -c <integer>
###
### USES ANSIBLE to put AWS KEYs as VARS
### USES ANSIBLE to define NAGIOS REGION
###
### REQUIRES AWS CLI : https://aws.amazon.com/cli/
{{!--
# these are comments .. they will not be displayed
# i often put what the object looks like in here so i don't forget
{
line1: ...,
arr1: [...],
obj1: {
obj: ...
// Commands:
// hubot handlebar me - example of how to use handlebars
const logger = require("winston");
const handlebars = require("handlebars");
const fs = require("fs");
module.exports = function(robot) {
// this is the controller
robot.respond(/handlebar me/i, function(message) {
// Commands:
// hubot hello - replies with "world"!
const logger = require("winston");
module.exports = function(robot) {
robot.respond(/hello$/i, { id: "hello" }, function(message) {
message.send("world!");
logger.log("info", "i like to log stuff!", { yourObject: "some random data" });
});
---
# my custom variable file that defines where my roles and playbooks are
# both directories are siblings of the inventories file
# inventory_dir is a VAR provided to us by Ansible
# .... http://docs.ansible.com/ansible/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts
roles_dir: "{{ inventory_dir | regex_replace('inventories$', 'roles') }}"
playbooks_dir: "{{ inventory_dir | regex_replace('inventories$', 'playbooks') }}"
---
# just a simple example of me using my bootstrap.yml file and re-using an action role
# this is nice because: 1) i can put my roles where i want to, and 2) it allows me to be as DRY as i want to be
- hosts: localhost
connection: local
gather_facts: False
become: False
vars_files:
# status link = <a href=\"https://{{ inventory_hostname }}/nagios/cgi-bin/extinfo.cgi?type=2&host=$HOSTNAME$&service=$$(echo $SERVICEDESC$ | sed -e 's/ /%20/g')\">Status Link</a>
# ack link = <a href=\"https://{{ inventory_hostname }}/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=$HOSTNAME$&service=$$(echo $SERVICEDESC$ | sed -e 's/ /%20/g')\">Acknowledgement Link</a>
# appended to the "$SERVICEOUTPUT$"
# see below
define command {
command_name notify-service-by-hipchat
command_line hipsaint --token={{ hipchat_token }} --room={{ hipchat_redrum_id }} --type=service --inputs="$SERVICEDESC$|$HOSTALIAS$|$LONGDATETIME$|$NOTIFICATIONTYPE$|$HOSTADDRESS$|$SERVICESTATE$|$SERVICEOUTPUT$<br><br><a href=\"https://{{ inventory_hostname }}/nagios/cgi-bin/extinfo.cgi?type=2&host=$HOSTNAME$&service=$$(echo $SERVICEDESC$ | sed -e 's/ /%20/g')\">Status Link</a><br><a href=\"https://{{ inventory_hostname }}/nagios/cgi-bin/cmd.cgi?cmd_typ=34&host=$HOSTNAME$&service=$$(echo $SERVICEDESC$ | sed -e 's/ /%20/g')\">Acknowledgemen
# MULTILINE NOTES for NAGIOS SERVICE !!
# no more run on sentences .. this annoyed me so much
# check aem6 service is running
define service {
service_description AEM6
hostgroup_name aem
check_command check_check_aem6
use default-service
---
# ansible-playbook -i inventories/ec2.py adhoc/aem_thread_dump.yml --limit aem-author.example.com
# tag_role_aem is what our AWS EC2 AEM nodes are tagged with .. tag:role=aem
# the --limit <node name> is the name of the node you want to run the thread dump helper on
- hosts: tag_role_aem
max_fail_percentage: 1
vars:
email_to: