Skip to content

Instantly share code, notes, and snippets.

@GaryRogers
GaryRogers / RSyslogSetup.md
Last active October 5, 2023 22:51
RSyslog Forwarding Setup

RSyslog Forwarding Setup

Overview

I'm looking to centralize logging for our dev team into Elasticsearch via Logstash. The wrinkle is that we aren't a Java shop, so installing java on our hosts just to ship logs back to a central Logstash indexer is something we'd like to avoid. So, I'm approaching things as a chance to understand RSyslog and its capabilities as a log shipper.

Procedure

Set up TCP listening on the log index host

Uncomment the following lines in /etc/rsyslog.conf. This will enable the rsyslog daemon to listen for incoming requests on TCP port 514. We're using TCP here so that we can have some confidence that the messages from the agent hosts reach the indexer. (More on this below)

@GaryRogers
GaryRogers / ComposerPHPUnit.md
Last active May 15, 2023 16:01
Getting Composer and PHPUnit to autoload namespaces

Getting Composer and PHPUnit to autoload namespaces.

Overview

Details

Project Structure

ProjectRoot
 src
@GaryRogers
GaryRogers / MacOSXPublicKeySSH.md
Last active October 22, 2022 04:10
Set up public key ssh on Mac OS X

Setting up SSH Key Auth on a Mac

Overview

Setting up public key auth allows you to ssh and scp to remote hosts without using your password. It uses encryption keys instead. Typically when you set up a private key it is best practice to set a password on the private key, which would result in a need to enter the private key password every time you want to login to a remote host. Apple has a feature of the MacOS X Keychain that allows you to add this password to your keychain, basically making the unlocking of the private key transparent. You can also change the protection level on this password in Keychain Access to require the keychain password every time it's used.

The gist of what we'll be doing is creating a private key, and then sending the associated public key to the remote host to establish trust between the local system and the remote system.

Procedure

Copy the following code blocks into a terminal window, one after the other. Several will prompt you for passwords, either for your public ke

@GaryRogers
GaryRogers / logstash.conf
Created May 16, 2014 22:02
Monolog Logstash Config example
input {
stdin { codec => "plain" }
}
filter {
# Pulls out fields from monolog text log. (Note, we don't send extra to our monolog)
grok {
match => [ "message", "%{MONOLOG} %{GREEDYDATA:mymessage}"]
}
@GaryRogers
GaryRogers / sysinfo.js
Created February 25, 2016 20:21
sysinfo.js, get system information in json format.
/**
* Get System Information in json format. Gets Run Queue, Memory and Swap Info.
*/
var os = require('os');
var fs = require('fs');
var sysinfo = {};
sysinfo.hostname = os.hostname();
@GaryRogers
GaryRogers / createPhar.php
Last active March 28, 2020 23:54
Create a Phar archive for PHP
<?php
# Create an executable phar
# Name of our archive.
$phar = new Phar("myscript.phar");
# Have to do buffering to make things executable.
# See http://stackoverflow.com/questions/11082337/how-to-make-an-executable-phar
$phar->startBuffering();
@GaryRogers
GaryRogers / VagrantCentOS.md
Last active February 8, 2020 20:32
Provisioning Vagrant CentOS hosts
import dpath.util
def dpath_null(data: dict, path: str, default_return = None):
'''function to trap any KeyErrors for dpath and return an acceptable 'null' value when dpath can't find a path
Example 1
---------
# Will return None if /some/path/to/an/attribute can not be found
var = dpath_null(my_dictionary, '/some/path/to/an/attribute')

Replaying logs to logstash

  • Copy comprssed log files to a work area.
  • Uncompress them, remove date part of file name.
  • Copy /etc/logstash/conf.d/*.conf to a work location.
  • Modify conf files to change output to stdout { codev => "rubydebug" }
  • You want to do this to make sure things are working before you push logs into ElasticSearch.
  • Modify conf files to change path in the input/file section
@GaryRogers
GaryRogers / tc_jenkins_integration_notes.md
Last active April 29, 2019 17:43
TestComplete Jenkins Integration Notes

TestComplete Jenkins Integration Notes

Agent Node Setup

  • Triple check your GPOs.
  • Run Resultant Set of GPOs to make sure some up-stream GPO isn't doing something you don't expect.
  • Shadow the RDP session to see what TestExecute is doing.
    • If you don't see TestExecute start in a session, double check your username variable in the pipeline.
  • Run Agent Node as a windows service.
  • Let service interact with the desktop.