-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrrd_graph.py
More file actions
36 lines (32 loc) · 791 Bytes
/
rrd_graph.py
File metadata and controls
36 lines (32 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/home/kgorman/python/bin/python
#
# rrd grapher functions
#
import sys, os
import settings
sys.path.append(settings.rrdpython_path)
import rrdtool
def create_rrd(n,f,t):
dstr=[]
for i,d in enumerate(n):
d=str(d)
dstr.append("DS:"+d+":"+t+":960000:U:U")
fstr=[f,'--step','120','--start','1165708833']
rrstr=["RRA:MAX:0.5:1:960000"]
fstr=fstr+dstr+rrstr
print fstr
rrdtool.create( *fstr )
def update_rrd(n,v,f,t):
dstr=''
for i,d in enumerate(v):
dstr=dstr+str(int(d))+":"
dstr=dstr.rstrip(':')
try:
if os.path.isfile(f):
print dstr
rrdtool.update(f,"N:"+dstr)
else:
create_rrd(n,f,t)
except Exception, e:
print "Error processing file %s" % f
print e