Skip to content

Instantly share code, notes, and snippets.

@jkapusi
jkapusi / Openfaas annotations.md
Created January 7, 2022 19:59
OpenFaaS annotations
@jkapusi
jkapusi / gist:ee4afedc9e78c538bdd183b4109b2f20
Created September 20, 2017 19:13
Mass migration of softlayer vms to new hosts
#!/bin/bash
TYPE=${1:-server}
while :; do
VSID=`slcli virtual list --columns id,hostname,pendingMigrationFlag | grep "$TYPE" | grep True | head -1 | cut -d ' ' -f1`;
if [[ -n "$VSID" ]]; then
echo "Next item to migrate: $VSID"
slcli vs detail "$VSID"
slcli call-api Virtual_Guest migrate "--id=$VSID"
@jkapusi
jkapusi / gist:bef4f56387c15d085ad8d529ff6b4538
Last active September 20, 2017 18:00
quick and dirty solution to bind vnc to localhost on a qemu host
#!/bin/bash
apt-get install jq -y
ps axu | grep -oe "unix:[a-z0-9\.:\/\-]*.qmp" | while read QMP; do
echo $QMP;
LISTEN=$(echo -e '{"execute":"qmp_capabilities"}\n{"execute": "query-vnc"}' | socat - ${QMP} | tail -n1 | jq -r .return.host);
echo $LISTEN
if [ "$LISTEN" != "127.0.0.1" ]; then
PORT=$[$(echo -e '{"execute":"qmp_capabilities"}\n{"execute": "query-vnc"}' | socat - ${QMP} | tail -n1 | jq -r .return.service)-5900]
echo -e '{"execute":"qmp_capabilities"}\n{"execute": "change", "arguments": { "device": "vnc", "target": "127.0.0.1:'$PORT'" } }' | socat - ${QMP};
@jkapusi
jkapusi / gist:96a725c784030d6340dad0cf75015edf
Created November 6, 2016 21:33
Softlayer VM Location based pricing calculator
#!/bin/bash
for DC in "wdc04" "tok02" "ams03"; do
echo $DC
PARAMS="{
'hostname': 'test',
'domain': 'example.com',
'datacenter': { 'name': '$DC' },
'startCpus': 16,
'maxMemory': 16384,
@jkapusi
jkapusi / graphite_report_free_space.sh
Created December 22, 2014 13:09
MogileFS rebalance workaround and MogileFS graphite reporter
#!/bin/bash
while :; do
mogadm check | cut -d] -f2- | awk '/writeable/{print "mogilefs."$1".free "$4" "systime()}' | nc -q0 graphite 2003
mogadm check | cut -d] -f2- | awk '/writeable/{print "mogilefs."$1".free_percent "int($5)" "systime()}' | nc -q0 graphite 2003
sleep `date "+60-%s%%60" | bc`
done