Skip to content

Instantly share code, notes, and snippets.

View rothwerx's full-sized avatar

Jeremiah Roth rothwerx

View GitHub Profile
@rothwerx
rothwerx / zenoss_curl_examples.sh
Last active December 16, 2015 17:09 — forked from cluther/zenoss-shell-functions
Bash: CuRL Zenoss
#!/bin/sh
# Source this file
# Your Zenoss server settings.
ZENOSS_URL="http://localhost:8080"
ZENOSS_USERNAME="admin"
ZENOSS_PASSWORD="zenoss"
# Generic call to make Zenoss JSON API calls easier on the shell.
@rothwerx
rothwerx / gist:5470311
Created April 26, 2013 20:44
Perl: MongoDB update
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
rothwerx / gist:5595947
Created May 16, 2013 23:31
Bash: Keep or Delete?
#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
rothwerx / lighter-graphite-rpi.sh
Last active October 16, 2020 07:54
Bash: Graphite for Raspbian
#!/bin/bash
# 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
rothwerx / gist:5681392
Created May 30, 2013 21:28
Brocade: Disabling stack to set IP on FLS 648-STK switch
config t
stack disable
ip route 0.0.0.0 0.0.0.0 10.50.42.1
vlan 42
router-interface ve 42
int ve 42
ip address 10.50.42.xxx 255.255.255.0
end
wr mem
@rothwerx
rothwerx / gist:5809932
Created June 18, 2013 22:11
Python: Query given WMI class on Windows host from Linux and output to easy-to-read JSON
#!/usr/bin/env python
from optparse import OptionParser
from subprocess import Popen, PIPE
# Requires wmic from Samba project, or here:
# http://dev.zenoss.org/trac/browser/tags/zenoss-3.2.1/inst/externallibs
wmic = '/vagrant/wmic'
parser = OptionParser()
@rothwerx
rothwerx / gist:5960677
Last active December 19, 2015 13:18
Python: Use hpilo to query iLO ambient temperature sensor, i.e. use HP sensors for ghetto datacenter temperature monitoring
import hpilo
tempkey = {
2 : 'Temp 1',
3 : 'Temp 1',
4 : '01-Inlet Ambient'
}
def get_ambient_temp(host, username, password, ilo_version):
try:
@rothwerx
rothwerx / gist:6067761
Last active December 20, 2015 03:59
Bash: My typical bashrc configuration for virtualenvwrapper
# ~/.bashrc
export PROJECT_HOME=$HOME/Sandbox/venvs
export WORKON_HOME=$HOME/.venvs
source /usr/local/bin/virtualenvwrapper.sh
@rothwerx
rothwerx / gist:6068063
Created July 24, 2013 04:26
Bash: Color prompt for OS X
# ~/.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
rothwerx / gist:6068070
Created July 24, 2013 04:27
Vim: Set syntax highlighting on OS X
# Just basic syntax highlighting for vim
set nocompatible
syntax on
colo peachpuff