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 / zone_count.prom
Last active Mar 17, 2020
CMON plugin to get gz zone count metrics
View zone_count.prom
#!/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 https://mozilla.org/MPL/2.0/.
# Copyright 2020 Joyent, Inc.
printf '# HELP plugin_zone_count Zone count by state\n'
printf '# TYPE plugin_zone_count gauge\n'
@bahamat
bahamat / sdc-ssh
Created Mar 9, 2020
sdc-ssh: SSH to CN by hostname or uuid for Triton headnode
View sdc-ssh
#!/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 2020 Joyent, Inc.
if [[ -n "$TRACE" ]]; then
export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
@bahamat
bahamat / anycast
Last active Mar 2, 2020
Anycast Example using Quagga on SmartOS
View anycast
#!/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 https://mozilla.org/MPL/2.0/.
# This is the SMF start method for anycast.
# Put it in /opt/custom/smf/anycast
set -o xtrace
@bahamat
bahamat / code.diff
Created Feb 20, 2020
illumos 12271 test case
View code.diff
--- try1.c Thu Feb 20 17:38:37 2020
+++ try2.c Thu Feb 20 17:39:02 2020
@@ -1,19 +1,19 @@
#include <stdio.h>
struct option {
const char *name;
};
-static char *
@bahamat
bahamat / mph-example.sh
Created Feb 17, 2020
Manta MPU multi-part upload example
View mph-example.sh
#!/bin/bash
# MPU parts need to be minimum 5MB, except the last part.
split -b 5m file part.
# Create MPU transaction
mpu_id=$(mmpu create ~~/stor/file)
# Upload each part
part0=$(mmpu upload -f part.aa "$mpu_id" 0)
part1=$(mmpu upload -f part.ab "$mpu_id" 1)
@bahamat
bahamat / chroot_example.sh
Last active Mar 19, 2020
chroot in lx brand zone
View chroot_example.sh
#!/bin/bash
# MIT License.
# This isn't meant to be run as a script exactly, but github has better syntax hilighting if I pretend.
chr=${PWD}/testroot
mkdir -p $chr/{bin,lib,lib64,native,var}
cd $chr
cp -v /bin/{bash,touch,ls,rm} $chr/bin
@bahamat
bahamat / docker-debug
Created Jan 22, 2020
Raw docker test utility
View docker-debug
#!/bin/bash -x
set -o pipefail
api_v="1.21"
call_docker() {
local uuid=$(uuid)
/opt/pkg/bin/curl -k -si \
--cert ${DOCKER_CERT_PATH}/cert.pem \
@bahamat
bahamat / nginx-adminui.conf
Created Jan 22, 2020
nginx reverse proxy for adminui
View nginx-adminui.conf
# include this file from nginx.conf inside the http stanza.
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name adminui.example.com;
access_log /var/log/nginx/adminui.access.log bunyan;
error_log /var/log/nginx/adminui.error.log;
View 0001-illumos-11894-zonecfg-export-should-quote-strings.patch
From 3cf036c03c6a9885353ad0d35edd5b6be7f6dcd2 Mon Sep 17 00:00:00 2001
From: Brian Bennett <brian.bennett@joyent.com>
Date: Tue, 29 Oct 2019 17:16:05 -0700
Subject: [PATCH] illumos#11894 zonecfg export should quote strings
---
usr/src/cmd/zonecfg/zonecfg.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/usr/src/cmd/zonecfg/zonecfg.c b/usr/src/cmd/zonecfg/zonecfg.c
@bahamat
bahamat / from_node-triton_cli.md
Created Oct 11, 2019
Example for setting up CLOUDAPI_SERVICES sapi metadata
View from_node-triton_cli.md
> triton -p west1 services
NAME    ENDPOINT
cmon    https://cmon.us-west-1.triton.zone:9163
docker  tcp://us-west-1.docker.joyent.com:2376
> triton -p west1 services -j
{"docker":"tcp://us-west-1.docker.joyent.com:2376","cmon":"https://cmon.us-west-1.triton.zone:9163"}
> triton -p west1 services -j | json
{
  "docker": "tcp://us-west-1.docker.joyent.com:2376",
You can’t perform that action at this time.