PracticeDev/study_python/rrdtool/first.py

34 lines
815 B
Python
Raw Normal View History

2022-12-20 17:31:11 +08:00
#!/usr/bin/python
#coding=utf8
"""
# Author: songtianlun
# Created Time : 2022-06-07 10:50:09
# File Name: first.py
# Description:
"""
# import sys
# sys.path.append('/path/to/rrdtool/lib/python2.6/site-packages/')
import rrdtool, tempfile
DAY = 86400
YEAR = 365 * DAY
fd,path = tempfile.mkstemp('.png')
rrdtool.graph(path,
'--imgformat', 'PNG',
'--width', '540',
'--height', '100',
'--start', "-%i" % YEAR,
'--end', "-1",
'--vertical-label', 'Downloads/Day',
'--title', 'Annual downloads',
'--lower-limit', '0',
'DEF:downloads=downloads.rrd:downloads:AVERAGE',
'AREA:downloads#990033:Downloads')
info = rrdtool.info('downloads.rrd')
print (info['last_update'])
print (info['ds[downloads].minimal_heartbeat'])