This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |