Created
December 8, 2009 23:42
-
-
Save NaPs/252107 to your computer and use it in GitHub Desktop.
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/env python | |
# coding=utf8 | |
import subprocess | |
from graphit.client import GraphItAgent | |
# Parameters : | |
mountpoint = '/mnt/data' | |
agent = GraphItAgent('http://frog:1337', login='graphit', passwd='pw') | |
# Data collecting : | |
df_pipe = subprocess.Popen('/bin/df | grep %s' % mountpoint, | |
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
df_out, df_err = df_pipe.communicate() | |
device, total, used, free, percent, mountpoint = df_out.split() | |
agent.add_value('burger_df', 'data', float(used)/(float(used)+float(free))*100, unit='%') |
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/env python | |
# coding=utf8 | |
import subprocess | |
from graphit.client import GraphItAgent | |
# Parameters : | |
agent = GraphItAgent('http://frog:1337', login='graphit', passwd='pw') | |
# Data collecting : | |
meminfo = open('/proc/meminfo', 'r') | |
memmap = dict() | |
for memitem in meminfo: | |
memitem = memitem.strip().split() | |
memmap[memitem[0][:-1]] = int(memitem[1]) | |
agent.add_value('burger_mem', 'used', (memmap['MemTotal'] - memmap['MemFree'] - memmap['Buffers'] - memmap['Cached'])/1024.0, unit='Mb') |
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/env python | |
# coding=utf8 | |
import subprocess | |
from graphit.client import GraphItAgent | |
# Parameters : | |
disks = ['/dev/sda', '/dev/sdb', '/dev/sdc', '/dev/sdd', '/dev/sde', '/dev/sdf', '/dev/sdg'] | |
agent = GraphItAgent('http://frog:1337', login='graphit', passwd='pw') | |
# Data collecting : | |
temps = [] | |
for disk in disks: | |
hddtemp_pipe = subprocess.Popen('/usr/sbin/hddtemp -n -w %s' % disk, | |
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
temp, err = hddtemp_pipe.communicate() | |
temp = temp.strip() | |
if not temp.isdigit(): | |
temp = '-1' | |
agent.add_value('burger_hddtemp', disk.split('/')[-1], int(temp), unit='°C') |
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/env python | |
# coding=utf8 | |
import subprocess | |
from graphit.client import GraphItAgent | |
# Parameters : | |
agent = GraphItAgent('http://frog:1337', login='graphit', passwd='pw') | |
# Data collecting : | |
loadavg = open('/proc/loadavg', 'r').readline() | |
loadavg = loadavg.split() | |
agent.add_value('burger_loadavg', 'system', float(loadavg[0]), unit='load') |
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/env python | |
# coding=utf8 | |
import subprocess | |
from graphit.client import GraphItAgent | |
# Parameters : | |
interface = 'eth0' | |
exec_time = 50 | |
agent = GraphItAgent('http://frog:1337', login='graphit', passwd='pw') | |
# Data collecting : | |
vnstat_pipe = subprocess.Popen('vnstat -i %s -tr %s' % (interface, exec_time), | |
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
vnstat_out, vnstat_err = vnstat_pipe.communicate() | |
data = vnstat_out.split('\n') | |
rx = float(data[3].split()[1]) | |
rx_pkt = int(data[3].split()[3]) | |
tx = float(data[4].split()[1]) | |
tx_pkt = int(data[4].split()[3]) | |
agent.add_value('burger_vnstat_eth0', 'rx', rx, unit='kB/s') | |
agent.add_value('burger_vnstat_eth0', 'tx', tx, unit='kB/s') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment