Skip to content

Instantly share code, notes, and snippets.

Mauricio Roman MauricioRoman

Block or report user

Report or block MauricioRoman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:a1a17791a0423e1f3a5a
def get_load_avg():
load_avg = list (os.getloadavg())
return {#"1m": load_avg[0],
"5m": load_avg[1],
"15m":load_avg[2],
}
def get_disk_usage():
disk_usage = {}
View gist:d4f0ba7d424148246e61
def send_to_skyline(series, metric_set):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Datapoints are {metric:[ [timestamp,value],[timestamp,value]...]}
for record in series:
metric = "%s.%s" % (metric_set, record['metric'])
datapoint = [record['timestamp'],record['value']]
packet = msgpack.packb((metric, datapoint))
sock.sendto(packet, (socket.gethostname(), SKYLINE_UDP_PORT))
@MauricioRoman
MauricioRoman / gist:dc305d0cbaab929b86bd
Created Oct 24, 2015
regex to parse empty nginx logs
View gist:dc305d0cbaab929b86bd
regex = "(?P<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(.+)(?P<dateandtime>\d{2}\/[a-zA-Z]{3}\/\d{4}:\d{2}:\d{2}:\d{2})(.+)(?P<statuscode>\d{3})"
View gist:954135b02e0d0869e2d4
#!/usr/bin/python
import requests, urllib2, simplejson, datetime, time
# Constants
MAX_RETRIES = 15 #Max number of retries when requesting data
TIMEOUT_RETURN = 100 #Timeout in calling API to retrieve results
DELAY = 0.5 #Delay per retry in seconds (increases * no_retries)
MAX_FIELDS = 300 #Max fields to retrieve from field request via API
You can’t perform that action at this time.