Skip to content

Instantly share code, notes, and snippets.

View stevenwilliamson's full-sized avatar

Steven Williamson stevenwilliamson

  • FreeAgent
  • Sheffield
View GitHub Profile
#!/bin/bash
# Space stats
ZONES_ZVOLS=$(zfs list -r -H -p -o volsize zones | grep -v - | awk '{ SUM += $1 } END { print int ( SUM / 1024 / 1024 / 1024 ) }')
ZONES_QUOTAS=$(zfs list -r -Hp -o quota zones | grep -v - | awk '{ SUM += $1 } END { print int ( SUM / 1024 / 1024 / 1024 ) }')
VM_QUOTAS=$(vmadm list -H -p -o quota | awk '{ SUM += $1 } END { print SUM }')
ZONES_POOL_SIZE=$(zpool list -p -H zones | awk '{ print int ( $2 / 1024 / 1024 / 1024 ) }')
VM_TOTAL=$(expr ${VM_QUOTAS} + ${ZONES_ZVOLS} )
OVER_PROV_GB=$(expr ${ZONES_POOL_SIZE} - ${VM_TOTAL})
FREE_TO_PROV=$(expr ${ZONES_POOL_SIZE} - ${VM_TOTAL})
> fffff0cd8933a7e0::findstack -v
stack pointer for thread fffff0cd8933a7e0: fffff001ed4a28b0
fffff001ed4a2920 param_preset()
fffff001ed4a29b0 die+0xdf(e, fffff001ed4a2ad0, 40, 1d)
fffff001ed4a2ac0 trap+0xe18(fffff001ed4a2ad0, 40, 1d)
fffff001ed4a2ad0 0xfffffffffb8001d6()
fffff001ed4a2c20 udp_do_open+0x68(fffff043a8545e28, 0, 0, fffff001ed4a2ccc)
fffff001ed4a2c90 udp_create+0x69(2, 1, 0, fffff0431c47bbc8, fffff0431c47ba84, fffff001ed4a2ccc, ffffffff00000000, fffff043a8545e28)
fffff001ed4a2d10 socket_init_common+0x1c0(fffff0431c47ba50, 0, 0, fffff043a8545e28)
fffff001ed4a2d40 so_init+0x25(fffff0431c47ba50, 0, fffff043a8545e28, 0)
#!/usr/sbin/dtrace -s
syscall::write:entry /fds[arg0].fi_fs == "zfs" && fds[arg0].fi_mount == "/dataset/mounted/here"/
{
printf("%s touched %s", pid, fds[arg0].fi_pathname;
}
#!/usr/sbin/dtrace -Cs
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses from name server */
};
#!/usr/bin/ruby
#
# Quick and dirty process license information from pkg_src summary files
# Package categories to skip
SKIP_CATEGORIES = [
"games",
"emulators",
"japanese",
"chinese",
@stevenwilliamson
stevenwilliamson / Triton profile bash prompt.sh
Created February 8, 2017 16:13
Triton Profile bash helpers
# functions for easing working with multiple profiles in the shell
alias tp='triton profiles'
function get_triton_profile() {
[ -n $TRITON_PROFILE ] && echo $TRITON_PROFILE
}
function set_profile() {
export TRITON_PROFILE=$1
# Sets the cpu_cap fact to the cpu_cap setting for the zone.
# We use kstat to retrive the value because it is not availble via mdata-get
# If no cap can be found it will be set to 0
Facter.add('cpu_cap') do
confine :operatingsystem => "SmartOS"
setcode do
cpu_cap_value = 0
if Facter::Util::Resolution.which('kstat')
cpu_cap_string = Facter::Util::Resolution.exec('kstat -n /cpucaps/ -c zone_caps -s value -C')
cpu_cap_value = cpu_cap_string.split(":").last unless cpu_cap_string == nil

Triton Disaster Recovery

Useful context

According to the docs and from investigation Triton stores all important persistent state in the manatee cluster, which is a cluster of postgresql instances.

The manatee cluster itself depends upon the binder service operating which provides zookeeper and DNS services that manatee makes use of.

Most services store the state in manatee via Moray. Moray provides a key value store API that is backed by manatee. Restoring binder, manatee and moray is the main part of a restore. All other services depend on these services and are almost completely stateless.

Depending on how images are configured in the event a complete headnode loss images will not be restored as they are only stored locally.

Tested on image "e74a9cd0-f2d0-11e6-8b69-b3acf2ef87f7"
# Create /etc/X11/xorg.conf
```
Section "Monitor"
Identifier "Monitor0"
EndSection
#!/bin/bash
set -uo pipefail
ZONE_NAME=2016Q4-builder
IMAGE=0d649af0-e6ed-11e6-8689-7fb3356bad96
PACKAGE=r4-d30-c4
ZONE_EXIST=false
ZONE_IP=$(triton instance ip $ZONE_NAME 2>/dev/null)