Skip to content

Instantly share code, notes, and snippets.

Brian Bennett bahamat

Block or report user

Report or block bahamat

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
@bahamat
bahamat / manta-pipasswd
Last active Jun 14, 2018
Get the default root password for platform images installed in Triton (manta-pipasswd, triton-pipasswd, pipasswd)
View manta-pipasswd
#!/bin/bash
# This will retrieve the default root password for platform images stored in Joyent's Manta service.
# Run this from your workstation.
# This only makes sense in the context of Joyent's cloud, because that's where the
# build artifacts are.
export MANTA_URL=https://us-east.manta.joyent.com/
if [[ -n "$TRACE" ]]; then
@bahamat
bahamat / pkgsrc-brew.md
Created May 22, 2017
Packages I get from brew instead of pkgsrc, and why
View pkgsrc-brew.md
pkg why
dnstracer not available
fortune not available
ghc not available on mac
hping out of date (pkgsrc==hping2, brew==hping3)
nagios-plugins does not compile on mac. Maybe brew patch(es) can be used?
shunit2 not available
tcpflow out of date (pkgrsc==0.21, brew==1.4); depends on dfxml which does not compile on smartos due to missing MAP_FILE ([tcpflow#91)[https://github.com/simsong/tcpflow/issues/91])
@bahamat
bahamat / cmon.sh
Last active Oct 11, 2019
Shell script to pull CMON metrics from Joyent Triton (https://www.joyent.com/triton)
View cmon.sh
#!/bin/bash
if [[ -n "$TRACE" ]]; then
export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -o xtrace
fi
call() {
curl "$insecure" "${header:--i}" -s --cert "$cert" --key "$key" "https://${1}/${2}"
exit $?
@bahamat
bahamat / shell_config.md
Last active Oct 23, 2019
How are various shells configured, and in which order?
View shell_config.md

bash

login interactive files
N N $BASH_ENV
N Y ~/.bashrc
Y N /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile
Y Y /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile
View triton-update-all
#!/bin/bash
set -o errexit
set -o xtrace
imgadm vacuum -f
sdcadm update --all --just-images -y
sdcadm self-update --allow-major-update --latest
sdcadm dc-maint start && printf "DC maintenance has started at %s\n" "$(date)"
@bahamat
bahamat / no_compute_resources_available.md
Last active Nov 1, 2019
Diagnosing "No Compute Resources Available" messages in Triton.
View no_compute_resources_available.md

No Compute Resources Available

This error is somewhat ambiguious because there is seemingly no indication which resource is exhausted.

Triton chooses compute nodes with a subcomponent called sdc-designation (also refered to as , DAPI). The full DAPI log for a provision job is embedded in the CNAPI log file and can be extracted with the workflow job uuid and the following script.

#!/bin/bash

if [[ -n "$TRACE" ]]; then                                                      
@bahamat
bahamat / nginx_log_format_bunyan.conf
Last active Sep 14, 2016
nginx log_format bunyan
View nginx_log_format_bunyan.conf
log_format bunyan '{'
'"name": "nginx/$nginx_version",'
'"hostname": "$hostname",'
'"pid": "$pid",'
'"level": 30,'
'"time": "$time_iso8601",'
'"v": 0,'
'"msg": "access",'
'"remoteAddress": "$remote_addr",'
@bahamat
bahamat / 00-illumos_SMF_manifests_for_CFengine.md
Last active Nov 11, 2015
illumos SMF manifests for Cfengine.
View 00-illumos_SMF_manifests_for_CFengine.md

Download each file using the Raw link, or clone this gist then run the following commands:

svccfg import cf-serverd.xml
svccfg import cf-monitord.xml
svcdfg import cf-execd.xml

In your policy, cfe_internal/update/update_processes.cf should be updated accordingly to enable the SMF services instead of executing commands directly.

View openvpnScraper.sh
#!/bin/bash
# This little hack-job will grab credentials from a running openvpn process in Linux
# Keep in mind this won't work if the user used the --auth-nocache flag
grep rw-p /proc/$1/maps | sed -n 's/^\([0-9a-f]*\)-\([0-9a-f]*\) .*$/\1 \2/p' | while read start stop; do gdb --batch-silent --silent --pid $1 -ex "dump memory $1-$start-$stop.dump 0x$start 0x$stop"; done
echo "Your credentials should be listed below as username/password"
strings *.dump | grep -B2 KnOQ | grep -v KnOQ
rm *.dump --force
View sdc-cn-comments
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2015, Brian Bennett <bahamat@digitalelf.net>
cn=$1; shift
action=$1; shift
You can’t perform that action at this time.