[rrd-users] Re: Python and RRDtool

Rodolphe Pineau pineau at rti-zone.org
Tue Apr 26 19:55:27 MEST 2005


On Apr 26, 2005, at 9:17 AM, Corey Goldberg wrote:

>> From what I can find, it seems most people who use RRDtool from  
>> Python are using the py-rrdtool (aka python-rrd) bindings.  Does  
>> anyone know where to find any sort of documentation for it?  I've  
>> searched pretty much everywhere and I'm coming up empty.
>
> Also, if anyone is using py-rrdtool, do you have any samples you could  
> post?  Even something trivial would be helpful.
>
> thanks in advance.
>
> -Corey Goldberg
>

here you go :

====== SCRIPT =====
#!/usr/bin/env python

import sys
import getopt
import os

import yapsnmp
import rrdtool


if(len(sys.argv)<6):
	print """
	usage : sys.py host community nb_cpu rrd_file graph_path
	"""
	sys.exit()
	
(snmp_host,snmp_community,nbcpu,rrd_file,rrd_graph_path) = sys.argv[1:]

Session = yapsnmp.Session(peername=snmp_host, version=2,  
community=snmp_community)
user=Session.get('ssCpuRawUser.0')
system=Session.get('ssCpuRawSystem.0')
idle=Session.get('ssCpuRawIdle.0')
kernel=Session.get('ssCpuRawKernel.0')
nice=Session.get('ssCpuRawNice.0')

print user
print system
print idle


rrdtool.update(rrd_file,'N:'+user+':'+system+':'+idle+':'+kernel+':'+nic 
e+':2')

rrdtool.graph ( rrd_graph_path+"/sys_day.gif",
				"--title=Dayly system use",
				"--start=-84600",
				"-u 100",
				"-r",
				"-M",
				"DEF:User="+rrd_file+":user:AVERAGE",
				"DEF:System="+rrd_file+":system:AVERAGE",
				"DEF:Idle="+rrd_file+":idle:AVERAGE",
				"DEF:Kernel="+rrd_file+":kernel:AVERAGE",
				"DEF:Nice="+rrd_file+":nice:AVERAGE",
				"DEF:Cpu="+rrd_file+":cpu:AVERAGE",
				"CDEF:pUser=User,Cpu,/",
				"CDEF:pSystem=System,Cpu,/",
				"CDEF:pIdle=Idle,Cpu,/",
				"CDEF:pKernel=Kernel,Cpu,/",
				"CDEF:pNice=Nice,Cpu,/",
				"AREA:pUser#00FF00:\"user\"",
				"LINE1:pSystem#FF0000:\"system\"",
				"LINE1:pIdle#0000FF:\"idle\"",
				"LINE1:pKernel#000000:\"kernel\"",
				"LINE1:pNice#008080:\"nice\"")

sys.exit()

====== END SCRIPT =====
Rodolphe

--

|        Rodolphe Pineau    RTI-Zone        |
|         http://www.rti-zone.org/          |
|   Robotics / Unix / Mac OS X / Astronomy  |

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the rrd-users mailing list