Skip to content

Instantly share code, notes, and snippets.

@jeffbryner
jeffbryner / esNodeStatus.py
Created April 12, 2014 22:38
elastic search node status
#!/usr/bin/env python
import json
import requests
r=requests.get(url="http://servername:9200/_nodes/stats?pretty=true")
if r.status_code == 200:
nodestats=r.json()
for node in nodestats['nodes']:
@jeffbryner
jeffbryner / gist:8918508
Created February 10, 2014 16:03
dump the veris framework to a item.item.value structure
#!/usr/bin/env python
import json
vDict=json.loads(open('verisc-enum.json').read())
def dict_walker(inCollection, pre=None):
pre = pre[:] if pre else []
#print(pre)
if isinstance(inCollection, dict):
@jeffbryner
jeffbryner / cmdTimeout.py
Created January 25, 2014 02:15
python code to run an external command with a timeout and return the output
import fcntl
import subprocess
import sys
import shlex
from threading import Timer
import time
import os
'''
python3 code to allow one to run an external command and return the output
'''
@jeffbryner
jeffbryner / gist:8412843
Last active January 3, 2016 04:59
UTC date from anything
from datetime import datetime
from dateutil.parser import parse
import pytz
def toUTC(suspectedDate,localTimeZone="US/Pacific"):
'''make a UTC date out of almost anything'''
utc=pytz.UTC
objDate=None
if type(suspectedDate)==str: