Skip to content

Instantly share code, notes, and snippets.


Jeremiah Roth rothwerx

View GitHub Profile
# Source this file
# Your Zenoss server settings.
# Generic call to make Zenoss JSON API calls easier on the shell.
rothwerx / gist:5470311
Created Apr 26, 2013
Perl: MongoDB update
View gist:5470311
sub update_mongodb {
if (!Opts::option_is_set('noupdate')) {
my $client = MongoDB::MongoClient->new(host => $mongohost, port => $mongoport);
my $database = $client->get_database( $mongodatabase );
my $db = $database->get_collection( $mongocollection );
my $mongohash = \%hosthash;
my $mongoresult = $db->update({ "hostname" => $hosthash{'hostname'} }, $mongohash, { "upsert" => 1} );
print $mongoresult;
rothwerx / gist:5595947
Created May 16, 2013
Bash: Keep or Delete?
View gist:5595947
#keep or delete?
function kod()
ls -l $@
echo "Keep (k) or Delete (d)?"
read answer
if [ $answer == "k" ]; then
echo "Keeping. As you wish."
elif [ $answer == "d" ]; then
echo "DELETING $@"
rothwerx /
Last active Oct 16, 2020
Bash: Graphite for Raspbian
# A lighter graphite for raspberry pi/raspbian wheezy.
# For when you don't need memcache/rabbitmq/full uWSGI server/etc
# Not fully tested on a clean install. This is just what it *should* take.
# Installing supervisor because upstart conflicts with sysvinit
aptitude update && aptitude install gcc python-dev python-pip python-cairo python-pysqlite2 supervisor libffi-dev
pip install django==1.4.3
rothwerx / gist:5681392
Created May 30, 2013
Brocade: Disabling stack to set IP on FLS 648-STK switch
View gist:5681392
config t
stack disable
ip route
vlan 42
router-interface ve 42
int ve 42
ip address
wr mem
rothwerx / gist:5809932
Created Jun 18, 2013
Python: Query given WMI class on Windows host from Linux and output to easy-to-read JSON
View gist:5809932
#!/usr/bin/env python
from optparse import OptionParser
from subprocess import Popen, PIPE
# Requires wmic from Samba project, or here:
wmic = '/vagrant/wmic'
parser = OptionParser()
rothwerx / gist:5960677
Last active Dec 19, 2015
Python: Use hpilo to query iLO ambient temperature sensor, i.e. use HP sensors for ghetto datacenter temperature monitoring
View gist:5960677
import hpilo
tempkey = {
2 : 'Temp 1',
3 : 'Temp 1',
4 : '01-Inlet Ambient'
def get_ambient_temp(host, username, password, ilo_version):
rothwerx / gist:6067761
Last active Dec 20, 2015
Bash: My typical bashrc configuration for virtualenvwrapper
View gist:6067761
# ~/.bashrc
export PROJECT_HOME=$HOME/Sandbox/venvs
export WORKON_HOME=$HOME/.venvs
source /usr/local/bin/
rothwerx / gist:6068063
Created Jul 24, 2013
Bash: Color prompt for OS X
View gist:6068063
# ~/.bash_profile on OS X (though could be .bashrc on other OS's)
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
rothwerx / gist:6068070
Created Jul 24, 2013
Vim: Set syntax highlighting on OS X
View gist:6068070
# Just basic syntax highlighting for vim
set nocompatible
syntax on
colo peachpuff