Skip to content

Instantly share code, notes, and snippets.

# Microsoft IIS logging....Use NXLOG for client side logging
filter {
if [type] == "iis" {
if [message] =~ "^#" {
drop {}
}
grok {
match => [
"message", "%{TIMESTAMP_ISO8601:logtime} %{IPORHOST:hostname} %{URIPROTO:cs_method} %{URIPATH:cs_stem} (?:%{NOTSPACE:cs_query}|-) %{NUMBER:src_port} %{NOTSPACE:cs_username} %{IP:clientip} %{NOTSPACE:cs_useragent} %{NUMBER:sc_status} %{NUMBER:sc_subresponse} %{NUMBER:sc_win32_status} %{NUMBER:timetaken}",
"message", "%{TIMESTAMP_ISO8601:logtime} %{IPORHOST:hostname} %{URIPROTO:cs_method} %{URIPATH:cs_stem} (?:%{NOTSPACE:cs_query}|-) %{NUMBER:src_port} %{NOTSPACE:cs_username} %{IP:clientip} %{NOTSPACE:cs_useragent} %{NOTSPACE:cs_referrer} %{NUMBER:sc_status} %{NUMBER:sc_subresponse} %{NUMBER:sc_win32_status} %{NUMBER:timetaken}"
{
"template" : "logstash-*",
"settings" : {
"index.refresh_interval" : "5s"
},
"mappings" : {
"_default_" : {
"_all" : {"enabled" : true},
"dynamic_templates" : [ {
"string_fields" : {
@rterbush
rterbush / iptables
Created January 19, 2016 17:36 — forked from UtahDave/iptables
An example of using the Salt peer interface to query web server IP addresses and add them to an iptables config.
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# -*- coding: utf-8 -*-
'''
Return salt data via slack
.. versionadded:: 2015.5.0
The following fields can be set in the minion conf file::
slack.channel (required)
slack.api_key (required)
{% set target = 'saltwebtest22' %}
rename_system:
salt.state:
- tgt: {{ target }}
- sls: wintools.rename
reboot1:
salt.function:
- name: system.reboot
@rterbush
rterbush / web.sls
Created November 15, 2015 18:33 — forked from toastedpenguin/web.sls
{% set target = 'saltwebtest20' %}
rename_system:
salt.state:
- tgt: {{ target }}
- sls: wintools.rename
reboot1:
salt.function:
- name: system.reboot
@rterbush
rterbush / windows-bootstrap.ps1
Created November 4, 2015 20:30
AWS user-data script for bootstraping Salt minions
<powershell>
# route53 IP assignment requires an assigned IAM profile/role to the calling
# EC2 instance that includes the following policy
# {
# "Version": "2012-10-17",
# "Statement": [
# {
# "Effect": "Allow",
# "Action": [
# "route53:ChangeResourceRecordSets",
@rterbush
rterbush / ExportSchema.ps1
Created October 25, 2015 22:40 — forked from cheynewallace/ExportSchema.ps1
Export MSSQL schema with PowerShell. This script will export your schema definitions for tables, stored procs, triggers, functions and views to .sql files
# Usage: powershell ExportSchema.ps1 "SERVERNAME" "DATABASE" "C:\<YourOutputPath>"
# Start Script
Set-ExecutionPolicy RemoteSigned
# Set-ExecutionPolicy -ExecutionPolicy:Unrestricted -Scope:LocalMachine
function GenerateDBScript([string]$serverName, [string]$dbname, [string]$scriptpath)
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
@rterbush
rterbush / linux-salt-bootstrap.sh
Last active January 11, 2020 22:54
Create Route53 A records using IAM profile with route53 access
#!/bin/sh
# bootstrap script that runs on every system boot called via AWS instance user-data
# via 'curl -s http://169.254.169.254/latest/user-data | /bin/sh 2>&1'
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@rterbush
rterbush / manage_ec2.py
Created September 28, 2015 22:45 — forked from rfairburn/manage_ec2.py
Generate a list of EC2 instances and prompt to SSH into one
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
This script will list all hosts in an ec2 region and prompt you to connect
to them.
It expects the file .boto to exist in your home directory with contents
as follows: