Skip to content

Instantly share code, notes, and snippets.

View stevenwilliamson's full-sized avatar

Steven Williamson stevenwilliamson

  • FreeAgent
  • Sheffield
View GitHub Profile
# 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
@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
#!/usr/bin/ruby
#
# Quick and dirty process license information from pkg_src summary files
# Package categories to skip
SKIP_CATEGORIES = [
"games",
"emulators",
"japanese",
"chinese",
#!/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/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;
}
> 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)
#!/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})
openssl s_client -showcerts -CApath /opt/local/etc/openssl/certs/ -connect ftp.netbsd.org:443
CONNECTED(00000004)
depth=0 OU = GT34707538, OU = See www.rapidssl.com/resources/cps (c)15, OU = Domain Control Validated - RapidSSL(R), CN = *.netbsd.org
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 OU = GT34707538, OU = See www.rapidssl.com/resources/cps (c)15, OU = Domain Control Validated - RapidSSL(R), CN = *.netbsd.org
verify error:num=27:certificate not trusted
verify return:1
depth=0 OU = GT34707538, OU = See www.rapidssl.com/resources/cps (c)15, OU = Domain Control Validated - RapidSSL(R), CN = *.netbsd.org
verify error:num=21:unable to verify the first certificate
marking py26-expat-2.6.9 as non auto-removable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 108k 100 108k 0 0 68001 0 0:00:01 0:00:01 --:--:-- 83944
No valid signature found for dmake-20130927.
Do you want to proceed with the installation [y/n]?
y
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 82282 100 82282 0 0 59192 0 0:00:01 0:00:01 --:--:-- 59280
#!/usr/sbin/dtrace -s
syscall::read*:entry /fds[arg0].fi_fs == "zfs"/
{
self->start = timestamp;
}
syscall::read*:return / self->start /
{
@data["latency_aggregation"] = llquantize(timestamp - self->start, 10, 0, 6, 20);