Skip to content

Show Current PostgreSQL Activity

15-May-12
SELECT datname,procpid,current_query FROM pg_stat_activity

Reference: Viewing current PostgreSQL queries

vmadm by example

29-Apr-12

Update a VM’s alias:

vmadm update c2875232-d7f6-434b-8d0c-909924ee2f05 alias=precise-template

Set a VM to not autoboot:

vmadm update c2875232-d7f6-434b-8d0c-909924ee2f05 autoboot=false

Deploying a Zone on SmartOS

29-Apr-12

Assuming a fresh install:

# dsadm update
updating local images database...
Get https://datasets.joyent.com/datasets...
done
# dsadm avail
UUID                                 OS      PUBLISHED  URN
b2845b76-80c5-11e1-9d72-5b4ca4191e12 smartos 2012-04-07 sdc:sdc:smartosplus64:3.2.0
c36a3d28-80c2-11e1-9ec6-df5bd8b43f76 smartos 2012-04-07 sdc:sdc:smartosplus:3.2.0
ce610cc2-80ac-11e1-8626-d788d6268d5b smartos 2012-04-07 sdc:sdc:smartos64:1.6.2
a93fda38-80aa-11e1-b8c1-8b1f33cd9007 smartos 2012-04-07 sdc:sdc:smartos:1.6.2
e4cd7b9e-4330-11e1-81cf-3bb50a972bda linux   2012-04-04 sdc:jpc:centos-6:1.0.1
f4c23828-7981-11e1-912f-8b6d67c68076 smartos 2012-03-29 sdc:sdc:smartos64:1.6.1
2b4466d8-7981-11e1-9be2-3b0d0e114740 smartos 2012-03-29 sdc:sdc:smartos:1.6.1
d239389c-7535-11e1-b60a-6f75edc139df smartos 2012-03-23 sdc:sdc:mongodb:1.2.4
98f38e14-6f83-11e1-bc32-2b9d0a8b6759 smartos 2012-03-16 sdc:sdc:mongodb:1.1.1
[...]
# dsadm list
# dsadm import ce610cc2-80ac-11e1-8626-d788d6268d5b
ce610cc2-80ac-11e1-8626-d788d6268d5b doesnt exist. continuing with install
ce610cc2-80ac-11e1-8626-d788d6268d5b successfully installed
dataset ce610cc2-80ac-11e1-8626-d788d6268d5b successfully imported
# dsadm list
UUID                                 OS      PUBLISHED  URN
ce610cc2-80ac-11e1-8626-d788d6268d5b smartos 2012-04-07 sdc:sdc:smartos64:1.6.2
[create zone definition file at /tmp/zonedef]
# cat /tmp/zonedef
{
      "brand": "joyent",
      "dataset_uuid": "ce610cc2-80ac-11e1-8626-d788d6268d5b",
      "nics": [
        {
          "nic_tag": "admin",
          "ip": "172.31.252.101",
          "netmask": "255.255.255.0",
          "gateway": "172.31.252.1"
        }
      ]
    }
# vmadm create -f /tmp/zonedef
Successfully created 323a0dd6-4b3c-47b4-987b-3876e554986e
# zlogin 323a0dd6-4b3c-47b4-987b-3876e554986e
[Connected to zone '323a0dd6-4b3c-47b4-987b-3876e554986e' pts/3]
[root@323a0dd6-4b3c-47b4-987b-3876e554986e ~]#

References:
How to create a zone ( OS virtualized machine ) in SmartOS

Burning a CD using wodim on Ubuntu

29-Apr-12

“wodim – write data to optical disk media… This application is derived from “cdrecord” as included in the cdrtools package created by Joerg Schilling, who deserves most of the credit for its success.”

> wodim --devices
wodim: Overview of accessible drives (1 found) :
-------------------------------------------------------------------------
 0  dev='/dev/scd0'	rwrw-- : 'SONY' 'CD-RW  CRX320E'
-------------------------------------------------------------------------
> wodim dev=/dev/scd0 -v -data smartos-20120422T024501Z.iso
[...]

Logging Outbound SMTP Traffic Using iptables

17-Mar-12
iptables -I OUTPUT -p tcp --dport 25 -o eth0 -j LOG --log-level info --log-prefix 'iptables smtp: '

If this is a defensive setting – monitoring for a host being used as a spam bot, for example – you may want to consider rate-limiting outbound SMTP traffic first, to prevent your log partition from being filled (and limit the damage done by a compromised host in the first place):

iptables -I OUTPUT -p tcp --dport 25 -o eth0 -m state --state NEW -m limit --limit 1/minute --limit-burst 2 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 25 -o eth0 -m state --state NEW -j DROP

The Agile Acid Test

09-Jan-12

Agile teams produce a continuous stream of value, at a sustainable pace, while adapting to the changing needs of the business.

More here.

rsync with a non-default ssh port

28-Dec-11

The rsync man page notes that the “-e” or “–rsh” flag lets you “specify the remote shell to use”. This can be used to specify transfer over a non-standard SSH port using the “-p” flag to the ssh binary:

SSH_PORT=...
rsync [OPTION...] -e "ssh -p $SSH_PORT" [USER@]HOST:SRC... [DEST]

Use a non-default port with ssh-copy-id

26-Dec-11

Quote a “-p” flag specifying the port with the “user@machine” portion of the arguments; e.g. for port 2234:

ssh-copy-id -i ~/.ssh/id_rsa.pub '-p 2234 user@machine'

Hat tip to Mike Gerwitz for getting me looking in the right direction, although the solution described on his blog does not work with the version of ssh-copy-id I have. (Edit: Looks like the same solution that I arrived at was pointed out in the comments on the above blog post.)

Generate an SSH Public Key from a Private Key

07-Dec-11

Use ssh-keygen:

ssh-keygen -y -f key.pem > key.pub

SGE Queue States

30-Sep-11

Reference: Monitoring and Controlling Queues

a – Load threshold alarm
o – Orphaned
A – Suspend threshold alarm
C – Suspended by calendar
D – Disabled by calendar
S – Suspended by subordination to another queue
c – Configuration ambiguous
d – Disabled
s – Suspended
u – Unknown
E – Error