Difference between revisions of "Zenoss RRD to CSV"

From Zenoss Wiki
Jump to: navigation, search
(Zenoss RRD to CSV Python Script)
(Zenoss RRD to CSV Python Script)
(No difference)

Latest revision as of 05:51, 10 December 2014

We always have these requirements from management asking lot of custom reports about performance data. People who uses Zenoss find it hard to meet the requirements due to the complex nature of reporting structure in Zenoss. To make things easy for all such Zenoss users , below is the python script which converts rrd values into csv format . In order to get to CSV , use rrdtool dump to convert rrd into xml.

RRD to XMl :

rrdtool dump rrdfilename.rrd xmlfilename.xml

The script uses python library Beautifulsoup .

To install above python package :

'On Zenoss master server : Get into user zenoss : su - zenoss

Install pip if not installed :

easy_install pip

Install BeautifulSoup Package :

pip install beautifulsoup4

Create a python script :

:vi rrd2csv.py

Paste the following code :

##Rrd2Csv by PaVan G Jakati - www.pavangjakati.org

from bs4 import BeautifulSoup
from datetime import datetime
import sys
inputfile= sys.argv[1]
for rra in soup.findAll('rra'):
    for row in rows:
        print("Time= %s Value=%f" % (event_time.strftime("%Y-%m-%d %H:%M:%S"),value))

To run the script :

python rrd.py rrd.xml &> rrd.txt

Example Output :

Event @ 2014-12-06 07:30:00 Value=3.956127

Event @ 2014-12-06 07:35:00 Value=5.339776

Event @ 2014-12-06 07:40:00 Value=7.210193

Event @ 2014-12-06 07:45:00 Value=5.150266

Event @ 2014-12-06 07:50:00 Value=5.073002

Event @ 2014-12-06 07:55:00 Value=5.073002

Event @ 2014-12-06 08:00:00 Value=5.378373