Skip to content

Instantly share code, notes, and snippets.

View salekseev's full-sized avatar

Stas Alekseev salekseev

View GitHub Profile
{
"algo": "cryptonight",
"av": 0,
"background": false,
"colors": true,
"cpu-affinity": null,
"cpu-priority": 3,
"donate-level": 0,
"log-file": null,
"max-cpu-usage": 100,

Keybase proof

I hereby claim:

  • I am salekseev on github.
  • I am salekseev (https://keybase.io/salekseev) on keybase.
  • I have a public key ASCERHqJ9yH5cLmY6ZkKqNxmwsUw2-r1rxj_bmXFMPllJAo

To claim this, I am signing this object:

require 'diplomat'
service = 'mongodb'
puts Diplomat::Health.service(service, passing: true).map { |service| service['Service']['Address'] + ':' + service['Service']['Port'].to_s }
#!/bin/bash
elasticsearch_url="https://elasticsearchlog.athenahealth.com:9200"
month=$(date +%Y.%m)
indices=$(curl -s "${elasticsearch_url}/_cat/indices?bytes=b" | sort -rnk8)
echo "Statistics for the month of $month"
echo -n "Events stored month-to-date: "
0xFa445C624412187A0292E8b2Fb5C73466699D015
#!/bin/sh
stack=devops-graylog
puppet_environment=development
stack_nodes=$(bundle exec sfn inspect --nodes $stack | egrep '^\s+"10.*' | cut -d'"' -f2)
for node in $stack_nodes
do
ssh $node "sudo bash -c '/opt/puppetlabs/bin/puppet agent -t --environment $puppet_environment' "
done
@salekseev
salekseev / check-elasticsearch-underreplicated.sh
Created July 28, 2017 19:21
Script to check Elasticsearch clusters for under-replicated indices
#!/bin/sh
#
# script accepts URLs of Elasticsearch clusters as arguments
# exit code table:
# 0 - no underreplicated indices
# 1 - found underreplicated indices
# 2 - unable to connect to one of those URLs could not be connected to
# 3 - timed out getting list of indices
#
for var in "$@"
exec { 'restore_golden_mongodump':
path => '/usr/bin:/usr/sbin:/bin',
onlyif => [
'which mongorestore',
'echo "db.access_tokens.find()" | mongo --quiet graylog | grep prometheus',
]
}
#!/bin/sh
while true
do
all=""
for interface in $(dmesg | grep ^eth | grep 802.11 | cut -s -d: -f1)
do
# for each interface, get mac addresses of connected stations/clients
maclist=$(wl -i $interface assoclist | cut -s -d" " -f2 | xargs -n 1 wl -i $interface sta_info | grep STA | cut -s -d" " -f3 | sed 's/.$//')
# for each mac address in that list...
@salekseev
salekseev / gist:012e5cba3ae13bcbc7428e104b07f6cc
Last active May 9, 2017 13:54
problem: storing mac address (6 bytes) in rdbms efficiently
problem: storing mac address (6 bytes) in rdbms efficiently
options:
char(6) | long/bigint (8 bytes) | char(12)
byte array | decimal representation | hex characters in ascii
---------------------------------------------------------------------
efficiency: n | efficiency: n+2 | efficiency: n+6
terminal safe: n | terminal safe: y | terminal safe: y
human readable: ? | human readable: y | human readable: y
range find: custom | range find: builtin | range find: custom