Skip to content

Instantly share code, notes, and snippets.

Russell Endicott rendicott

Block or report user

Report or block rendicott

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rendicott
rendicott / gatsfa.py
Created Sep 29, 2015
Quick example of how to pull a report from Salesforce in CSV format via the API using Python-Requests. Then take the CSV data and parse it into an object model for sifting sorting and timedelta.
View gatsfa.py
'''
GATSFA - Gateway to Salesforce API
The CSV report this is pulling down is querying the Salesforce event log.
Each line in the CSV is a Salesforce event log entry that has the prefix
of the name of our API application. So the report is a log of the
activity between the gateway API and the Salesforce API
'''
@rendicott
rendicott / octoDeployRest.ps1
Created Dec 30, 2015
Uses Powershell to interact with the Octopus REST API to create a deployment to a specific machine / release / environment combination.
View octoDeployRest.ps1
param(
[string]$machineName,
[string]$desiredVersion,
[string]$environmentString,
[string]$project
)
Import-Module Octopus-Cmdlets
#$machineName = 'DOGEN09'
@rendicott
rendicott / whisper-resizer.sh
Created Jan 5, 2016
Shell script to refactor Graphite whisper files with updated retention data
View whisper-resizer.sh
cd /var/lib/graphite/whisper/teamcity
for f in $(find $1 -iname "*.wsp")
do
if [ -a $f ]
then
# the retention policy should match what's in your /etc/carbon/storage-schemas.conf
/root/source/graphite-project/bin/whisper-resize.py $f 1m:7d 5m:28d 15m:1y
fi
done
chown -R _graphite:_graphite /var/lib/graphite/whisper
@rendicott
rendicott / crontab-entry
Last active Nov 23, 2018
quick backup script to tar and gzip the jenkins home directory and upload it to Artifactory for backup
View crontab-entry
5 18 * * * /root/jenkins-backup-to-artifactory.sh >/var/log/jenkinsbackup/jenkinsbackup.`date +\%Y\%m\%d\%H\%M\%S`.log 2>&1
@rendicott
rendicott / pid-mem-getter.sh
Created Jan 3, 2017
bash one-liner to search for ps aux pid by name and get memory usage
View pid-mem-getter.sh
pid=$(ps aux | grep [s]nmpd | awk -F' ' '{print $2}') && pmap -x $pid | grep total
@rendicott
rendicott / check-ps.sh
Last active Jan 4, 2017
quick dirty bash script to see if there's a running process of the given name with Nagios style return codes
View check-ps.sh
#!/bin/bash
# Thanks to androidyue on stackoverflow http://stackoverflow.com/questions/2903354/bash-script-to-check-running-process
ps_out=`ps -ef | grep $1 | grep -v 'grep' | grep -v $0`
result=$(echo $ps_out | grep "$1")
if [[ "$result" != "" ]];then
echo "$1 Running"
exit 0
else
echo "$1 Not Running"
exit 2
@rendicott
rendicott / check_df_usage.py
Created Jan 6, 2017
nagios plugin to check filesystem usage based on df output
View check_df_usage.py
#!/usr/bin/env python
"""
This script checks the output of the local
'df -P' command and reports the disk usage
for the given mount with perfdata.
Usage:
python check_df_usage.py
OK /dev/mapper/centos-root filesystem mounted on / usage percentage is 17 ; | 'used_percentage'=17;90;95;; 'size'=14530560KB;;;; 'used'=2360596KB;;;; 'available'=12169964KB;;;;
@rendicott
rendicott / red2graph.py
Created Jan 11, 2017
Ships metrics from Redis to graphite
View red2graph.py
import graphitesend
import redis
import os
import time
import sys
pattern = '%Y-%m-%d %H:%M:%S'
g = graphitesend.init(prefix='devops.dotshipper',graphite_server='dograph2.docl.nic')
@rendicott
rendicott / nix-cmd-cheats.md
Last active Dec 4, 2018
quick commands I use frequently in linux but always forget the syntax
View nix-cmd-cheats.md

Quick Reference Linux Commands

Find string in files in directory

find . | xargs grep 'string' -sl
sudo find / | xargs grep 'http://127.0.0.1:4567' -sl

Find case insensitive

find / -iname 'wOrDs'

@rendicott
rendicott / check_port.py
Last active Mar 30, 2017
quick script to use to check whether or not a port is open using python standard library, good for when telnet is unavailable and it's too much trouble to install it
View check_port.py
#!/usr/bin/env python
'''
quick script to use to check whether or not a port is open using python standard library,
good for when telnet is unavailable and it's too much trouble to install it
Usage: ./check_port.py 127.0.0.1 5601
Thanks to mrjandro on SO
http://stackoverflow.com/questions/19196105/python-how-to-check-if-a-network-port-is-open-on-linux
sample output:
{"exit_code": 1, "results": "Port not open", "port": 5672, "host_ip": "['11.22.111.200']", "address": "internal-lb-1912362693.us-east-1.elb.amazonaws.com"}
You can’t perform that action at this time.