Skip to content

Instantly share code, notes, and snippets.

View Kami's full-sized avatar
:octocat:
🐕‍🦺 🦮 🇸🇮 🇺🇦 🇹🇼

Tomaz Muraus Kami

:octocat:
🐕‍🦺 🦮 🇸🇮 🇺🇦 🇹🇼
View GitHub Profile
#!/usr/bin/env python
import re
totals = {'packets': 0, 'traffic': 0}
with open('traffic.log', 'r') as fp:
content = fp.read()
lines = content.split('\n')
{"version":"2.0","host":"api0","timestamp":1354831900.538,"short_message":"1.1.1.1:9160 error during connect.","full_message":"Error: This socket is closed.\n at Socket._write (net.js:518:19)\n at Socket.write (net.js:510:15)\n at Connection.write (/tmp/foo-bundle-63399cb1058ef40ecbe2a99c63963bd0d5a6e785/node_modules/cassandra-client/node_modules/thrift/lib/thrift/connection.js:106:19)\n at Object.onFlush (/tmp/foo-bundle-63399cb1058ef40ecbe2a99c63963bd0d5a6e785/node_modules/cassandra-client/node_modules/thrift/lib/thrift/connection.js:123:16)\n at Object.TFramedTransport.flush (/tmp/foo-bundle-63399cb1058ef40ecbe2a99c63963bd0d5a6e785/node_modules/cassandra-client/node_modules/thrift/lib/thrift/transport.js:128:12)\n at Object.CassandraClient.send_execute_cql_query (/tmp/foo-bundle-63399cb1058ef40ecbe2a99c63963bd0d5a6e785/node_modules/cassandra-client/lib/gen-nodejs/Cassandra.js:7097:22)\n at Object.CassandraClient.execute_cql_query (/tmp/foo-bundle-63399cb1058ef40ecbe2a99c63963bd0d5a6e78
@Kami
Kami / cassandra_cfstats_histogram.py
Last active October 13, 2015 04:58
Turns output of Cassandra nodetool cfhistograms into pretty graphs (histograms)
#!/usr/bin/env python
# Licensed to Tomaz Muraus under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# Tomaz muraus licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# -------- begin 39934792 request ----------
curl -i -X GET -H 'Host: dns.api.rackspacecloud.com' -H 'X-LC-Request-ID: 39934792' -H 'Accept-Encoding: gzip,deflate' -H 'X-Auth-Token: abcdef' -H 'Content-Length: 0' -H 'Accept: application/json' -H 'User-Agent: libcloud/0.12.0-dev (Rackspace DNS (US))' --compress 'https://dns.api.rackspacecloud.com:443/v1.0/546514/domains?cache-busting=4e1a1b74b95976fa'
# -------- begin 39934792:40416536 response ----------
HTTP/1.1 200 OK
Date: Fri, 19 Oct 2012 05:45:55 GMT
X-Api-Version: 1.0.19
Content-Length: 1316
Content-Type: application/json
Server: Jetty(8.0.y.z-SNAPSHOT)
<?xml version='1.0' encoding='utf-8'?>
<chapter version="5.0" xml:id="Service API Operations" xmlns="http://docbook.org/ns/docbook" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Service API Operations</title>
<section xml:id="account">
<title>Account</title>
<section xml:id="summary">
<title>Summary</title>
<para>An account contains attributes describing a customer's account. This description contains mostly read only data; however, a few properties can be modified with the API.&#xA;&#xA;</para>
</section>
<section xml:id="get-account">
kami ~/ $ sudo apt-get install maven2
[sudo] password for kami:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
ant ant-optional bsh bsh-gcj fop gcj-4.6-base gcj-4.6-jre-lib java-wrappers junit junit4 libapache-pom-java
libasm3-java libavalon-framework-java libbackport-util-concurrent-java libbatik-java libbsf-java
libclassworlds-java libcommons-beanutils-java libcommons-cli-java libcommons-codec-java
libcommons-collections3-java libcommons-configuration-java libcommons-digester-java libcommons-httpclient-java
*destroy*, *delete* -> DELETE
*get*, *list*, *describe* -> GET
*create* -> POST
*edit*, *set*, *change* -> PUT
#!/bin/bash
basedir=`readlink -f $0`
basedir=`dirname $basedir`
versions=( "0.2.0" "0.3.0" "0.3.1" "0.4.0" "0.4.1" "0.4.2" "0.5.2" "0.6.0-beta1" "0.6.1" "0.6.2" "0.7.1" "0.8.0" "0.9.1" )
for version in ${versions[@]}
do
echo "Processing: $version"
@Kami
Kami / gist:3029308
Created July 1, 2012 19:21
Example responses for supported method and arguments discovery endpoints
GET /<api version>/compute/providers/<provider>
{
"name": "Rackspace",
"website": "http://www.rackspacecloud.com",
"supported_methods": {
"list_nodes": {
"name": "list_nodes",
"description": "Return a list of available nodes",
"arguments": []
@Kami
Kami / gist:2935291
Created June 15, 2012 07:57
raxmon alarm criteria example
if (metric['code'] == '500') {
return CRITICAL, 'Internal server error'
}
if (metric['body_match'] == '') {
return WARNING, 'Copyright not found, returning WARNING.'
}
return OK