Skip to content

Instantly share code, notes, and snippets.

@pcn
pcn / gist:5609586
Created May 19, 2013 23:41
An example of playing with fork+exec in python. Basically, when there's a non-zero exit, we can format the output nicely. Otherwise, the parent and child exist in the same process group, tty, etc. so the user is just interacting with the child
#!/usr/bin/env python
# Just a quick demonstration of using fork+exec and watching the exit
# status of the sub-command to demonstrate that this will work with kcs
import sys
import os
import select
import signal
@pcn
pcn / gist:5666038
Created May 28, 2013 20:52
State of cassandrakankoku when the ring is weird
In [53]: [i for i in ii if 'Superman-CassandraKankoku' in i['appId']]
Out[53]:
[{u'appId': u'Superman-CassandraKankoku',
u'availabilityZone': u'us-east-1a',
u'elasticIP': u'54.225.8.34',
u'hostname': u'ec2-54-225-8-34.compute-1.amazonaws.com',
u'id': u'1808575606',
u'instanceId': u'i-0022196e',
u'location': u'us-east-1',
u'token': u'85070591730234615865843651859750628460',
@pcn
pcn / after
Created May 29, 2013 17:33
More priam formation issues
In [56]: [i for i in ii if 'Superman-CassandraHaag' in i['appId']]
Out[56]:
[{u'appId': u'Superman-CassandraHaag-dead',
u'availabilityZone': u'us-east-1a',
u'elasticIP': u'50.16.177.79',
u'hostname': u'ec2-50-16-177-79.compute-1.amazonaws.com',
u'id': u'1808575600',
u'instanceId': u'i-c40c97a8',
u'location': u'us-east-1',
u'token': u'1808575600',
@pcn
pcn / apt run
Created May 31, 2013 17:21
s3 apt archives for ubuntu are broken again
ubuntu@ip-10-141-165-152:~$ sudo apt-get -q -y install snmpd=5.4.3~dfsg-2ubuntu1.1
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
libganglia1 libconfuse0
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
snmpd
0 upgraded, 1 newly installed, 0 to remove and 83 not upgraded.
@pcn
pcn / gist:5686894
Created May 31, 2013 18:21
How to watch your carbon-relay. Make the below json into a dashboard in your graphite web ui
[
{
"target": [
"carbon.relays.*.metricsReceived"
]
},
{
"target": [
"carbon.relays.*.destinations.*.batchesSent"
]
@pcn
pcn / client.py
Last active December 18, 2015 05:09
Relay sending code that logs timestamps
def _sendDatapoints(self, datapoints):
# XXX: Make this a logging option
# log to the oldest and newest datapoint in the pickle
# looks like ('Platform2.Wonderwoman.RecommendationService.i-8ecebae0.internal.actors.total-dirty-keys-since-restart.InstructionAtomicKankoku.gauge.value', (137061\
9773.0, 58297.0))
def datapoint_timestamp(point):
return point[1][0]
now = time()
my_max = max(datapoints, key=datapoint_timestamp)
my_min = min(datapoints, key=datapoint_timestamp)
@pcn
pcn / Further notes
Last active December 18, 2015 10:19
Proposal on #cassandra for changing up the relay
The "relay" is actually a chameleon - it can be either a straight rules-based relay
(send A -> B, send B->z, etc. based on a regular expression match on the stat name),
it can be a consistent hashing relay which spreads load across a ring, or it can be
an aggregated consistent hashing relay, which I really don't know anything about but
will learn more about.
The only thing I'm really thinking about right now is the rules-based relay, but the
same approach could be used for the others if that's needed.
It also leads to a very simple hack to deliver to e.g. an alternative backend. E.g.
@pcn
pcn / theory_vs_reality
Last active December 18, 2015 11:59
The strange case of ohai showing the wrong number of ephemeral disks
ubuntu@ip-10-30-151-113:~$ ls -laF /dev | grep xvd
brw-rw---- 1 root disk 202, 1 Jun 14 02:55 xvda1
brw-rw---- 1 root disk 202, 16 Jun 14 02:55 xvdb
ubuntu@ip-10-30-151-113:~$ ohai | grep ephemeral
"block_device_mapping_ephemeral0": "sdb",
"block_device_mapping_ephemeral1": "sdc",
@pcn
pcn / after_running_stress
Last active December 19, 2015 02:08
multiregion cassandra 6-node cassandra cluster
```
Every 2.0s: nodetool -h0 ring Thu Jun 27 21:44:36 2013
Address DC Rack Status State Load Owns Token
113427455640312821154458202479223443377
54.225.85.126 us-east 1a Up Normal 15.21 MB 33.33% 1808575600
54.245.99.207 us-west-2 2a Up Normal 21.69 MB 0.00% 1967372893
54.225.86.23 us-east 1d Up Normal 59.79 MB 33.33% 56713727820156410577229101240436610842
54.245.102.34 us-west-2 2c Up Normal 16.88 MB 0.00% 56713727820156410577229101240595408135
54.225.86.137 us-east 1e Up Normal 71.84 KB 33.33% 113427455640312821154458202479064646084
"servers" : [ {
"port" : "7199",
"host" : "10.77.63.40",
"alias" : "jmxtrans",
"queries" :
[ {
"obj" : "org.apache.cassandra.db:type=Caches,*",
"resultAlias": "Caches",
"attr" : [ "Hits", "Requests" ],
"outputWriters" : [ {