* [gentoo-user] [OT] rrd to CSV
@ 2009-07-04 15:36 Mick
2009-07-04 16:23 ` Mark Shields
0 siblings, 1 reply; 7+ messages in thread
From: Mick @ 2009-07-04 15:36 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 245 bytes --]
Hi All,
I know that rrdtool dump will export the rrd data into XML, but is there
something to either directly or via rrdtool create a CSV file for me? Will
probably want to run this on a cron job and email/save it.
--
Regards,
Mick
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] [OT] rrd to CSV
2009-07-04 15:36 [gentoo-user] [OT] rrd to CSV Mick
@ 2009-07-04 16:23 ` Mark Shields
2009-07-04 19:20 ` Mick
2009-07-05 22:07 ` Mick
0 siblings, 2 replies; 7+ messages in thread
From: Mark Shields @ 2009-07-04 16:23 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 688 bytes --]
On Sat, Jul 4, 2009 at 11:36 AM, Mick <michaelkintzios@gmail.com> wrote:
> Hi All,
>
> I know that rrdtool dump will export the rrd data into XML, but is there
> something to either directly or via rrdtool create a CSV file for me? Will
> probably want to run this on a cron job and email/save it.
> --
> Regards,
> Mick
>
Judging from a few cursory google searches, it won't output to CSV, but you
can easily convert it. Try piping the file/output to these commands (yanked
from Cacti forums):
| grep -v NaN | grep '<row>' | tr e ' ' \
| awk {'print "Q"$2"qcq"$3"qcq"$9"Q"'} \
| tr Q '"' | tr c ',' | tr q '"'"
Haven't tested it, but looks like it should work.
--
- Mark Shields
[-- Attachment #2: Type: text/html, Size: 1221 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] [OT] rrd to CSV
2009-07-04 16:23 ` Mark Shields
@ 2009-07-04 19:20 ` Mick
2009-07-05 22:07 ` Mick
1 sibling, 0 replies; 7+ messages in thread
From: Mick @ 2009-07-04 19:20 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 844 bytes --]
On Saturday 04 July 2009, Mark Shields wrote:
> On Sat, Jul 4, 2009 at 11:36 AM, Mick <michaelkintzios@gmail.com> wrote:
> > Hi All,
> >
> > I know that rrdtool dump will export the rrd data into XML, but is there
> > something to either directly or via rrdtool create a CSV file for me?
> > Will probably want to run this on a cron job and email/save it.
> > --
> > Regards,
> > Mick
>
> Judging from a few cursory google searches, it won't output to CSV, but you
> can easily convert it. Try piping the file/output to these commands
> (yanked
>
> from Cacti forums):
> | grep -v NaN | grep '<row>' | tr e ' ' \
> | awk {'print "Q"$2"qcq"$3"qcq"$9"Q"'} \
> | tr Q '"' | tr c ',' | tr q '"'"
>
> Haven't tested it, but looks like it should work.
Thanks Mark, will give it a go and let you know.
--
Regards,
Mick
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] [OT] rrd to CSV
2009-07-04 16:23 ` Mark Shields
2009-07-04 19:20 ` Mick
@ 2009-07-05 22:07 ` Mick
2009-07-06 16:15 ` Willie Wong
1 sibling, 1 reply; 7+ messages in thread
From: Mick @ 2009-07-05 22:07 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1188 bytes --]
On Saturday 04 July 2009, Mark Shields wrote:
> On Sat, Jul 4, 2009 at 11:36 AM, Mick <michaelkintzios@gmail.com> wrote:
> > Hi All,
> >
> > I know that rrdtool dump will export the rrd data into XML, but is there
> > something to either directly or via rrdtool create a CSV file for me?
> > Will probably want to run this on a cron job and email/save it.
> > --
> > Regards,
> > Mick
>
> Judging from a few cursory google searches, it won't output to CSV, but you
> can easily convert it. Try piping the file/output to these commands
> (yanked
>
> from Cacti forums):
> | grep -v NaN | grep '<row>' | tr e ' ' \
> | awk {'print "Q"$2"qcq"$3"qcq"$9"Q"'} \
> | tr Q '"' | tr c ',' | tr q '"'"
>
> Haven't tested it, but looks like it should work.
Hmm, I don't think it gets anywhere:
=======================================
cat test.xml | grep -v NaN | grep '<row>' | tr e ' ' | awk
{'print "Q"$2"qcq"$3"qcq"$9"Q"'} | tr Q '"' | tr c ',' | tr q '"'" > test.csv
>
=======================================
It just sits there at the > cursor. I think it needs something more to it, or
I am not feeding the XML file to it correctly?
--
Regards,
Mick
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] [OT] rrd to CSV
2009-07-05 22:07 ` Mick
@ 2009-07-06 16:15 ` Willie Wong
2009-07-11 14:57 ` Mick
0 siblings, 1 reply; 7+ messages in thread
From: Willie Wong @ 2009-07-06 16:15 UTC (permalink / raw
To: gentoo-user
On Sun, Jul 05, 2009 at 11:07:23PM +0100, Penguin Lover Mick squawked:
> > from Cacti forums):
> > | grep -v NaN | grep '<row>' | tr e ' ' \
> > | awk {'print "Q"$2"qcq"$3"qcq"$9"Q"'} \
> > | tr Q '"' | tr c ',' | tr q '"'"
> >
> > Haven't tested it, but looks like it should work.
>
> Hmm, I don't think it gets anywhere:
> =======================================
> cat test.xml | grep -v NaN | grep '<row>' | tr e ' ' | awk
> {'print "Q"$2"qcq"$3"qcq"$9"Q"'} | tr Q '"' | tr c ',' | tr q '"'" > test.csv
> >
> =======================================
>
> It just sits there at the > cursor. I think it needs something more to it, or
Looks like a syntax error with improperly nested quotations marks.
The last command in the sequence, which reads
tr q '"'"
try replacing that with
tr q '"'
(remove the final double quote)
W
--
"`Eddies,' said Ford, `in the space-time continuum.'
`Ah,' nodded Arthur, `is he? Is he?'"
- Arthur failing in his first lesson of galactic physics
in four years.
Sortir en Pantoufles: up 941 days, 15:00
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] [OT] rrd to CSV
2009-07-06 16:15 ` Willie Wong
@ 2009-07-11 14:57 ` Mick
2009-07-12 23:59 ` Willie Wong
0 siblings, 1 reply; 7+ messages in thread
From: Mick @ 2009-07-11 14:57 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1473 bytes --]
On Monday 06 July 2009, Willie Wong wrote:
> On Sun, Jul 05, 2009 at 11:07:23PM +0100, Penguin Lover Mick squawked:
> > > from Cacti forums):
> > > | grep -v NaN | grep '<row>' | tr e ' ' \
> > > | awk {'print "Q"$2"qcq"$3"qcq"$9"Q"'} \
> > > | tr Q '"' | tr c ',' | tr q '"'"
> > >
> > > Haven't tested it, but looks like it should work.
> >
> > Hmm, I don't think it gets anywhere:
> > =======================================
> > cat test.xml | grep -v NaN | grep '<row>' | tr e ' ' | awk
> > {'print "Q"$2"qcq"$3"qcq"$9"Q"'} | tr Q '"' | tr c ',' | tr q '"'" >
> > test.csv
> >
> > =======================================
> >
> > It just sits there at the > cursor. I think it needs something more to
> > it, or
>
> Looks like a syntax error with improperly nested quotations marks.
>
> The last command in the sequence, which reads
>
> tr q '"'"
>
> try replacing that with
>
> tr q '"'
>
> (remove the final double quote)
>
> W
Thank you both! It works to a point. This is what the xml file contains:
<database>
<!-- 2009-07-02 07:41:00 EDT / 1246534860 --> <row><v>
7.3395000000e+01 </v><v> 4.7990000000e+01 </v></row>
The CSV file only shows the first value and then it does not pick up the fact
that it is exponential:
"2009-07-02","07:41:00","7.3395000000"
How could it be tweaked to a)account for e+01, b)include additional value
fields?
Thanks again.
--
Regards,
Mick
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] [OT] rrd to CSV
2009-07-11 14:57 ` Mick
@ 2009-07-12 23:59 ` Willie Wong
0 siblings, 0 replies; 7+ messages in thread
From: Willie Wong @ 2009-07-12 23:59 UTC (permalink / raw
To: gentoo-user
On Sat, Jul 11, 2009 at 03:57:26PM +0100, Penguin Lover Mick squawked:
> > > Hmm, I don't think it gets anywhere:
> > > =======================================
> > > cat test.xml | grep -v NaN | grep '<row>' | tr e ' ' | awk
> > > {'print "Q"$2"qcq"$3"qcq"$9"Q"'} | tr Q '"' | tr c ',' | tr q '"'" >
> > > test.csv
> > >
> > > =======================================
> > >
> > > It just sits there at the > cursor. I think it needs something more to
> > > it, or
> >
> > Looks like a syntax error with improperly nested quotations marks.
> >
> > The last command in the sequence, which reads
> >
> > tr q '"'"
> >
> > try replacing that with
> >
> > tr q '"'
> >
> > (remove the final double quote)
> >
> > W
>
> Thank you both! It works to a point. This is what the xml file contains:
>
> <database>
> <!-- 2009-07-02 07:41:00 EDT / 1246534860 --> <row><v>
> 7.3395000000e+01 </v><v> 4.7990000000e+01 </v></row>
>
> The CSV file only shows the first value and then it does not pick up the fact
> that it is exponential:
>
> "2009-07-02","07:41:00","7.3395000000"
>
> How could it be tweaked to a)account for e+01, b)include additional value
> fields?
>
Try:
cat test.xml | grep -v NaN | grep '<row>' | awk {'print "Q"$2"qcq"$3"qcq"$9"qcq"$11"Q"'} | tr Q '"' | tr c ',' | tr q '"'" > test.csv
Just to help you help yourself later: the 'tr' command "translates".
So the command
tr e ' '
swaps occurences of the letter e with a blank space. Removing that
command keeps the e in the numbers. (Though I am not certain how CSV
files deal with e notations...). awk prints the space-separated
fields. $2, $3, etc are the number of the field respectively. So
adding $11 allows printing the one additional field.
This, of course, only works if you have the same number of records in
each row.
HTH,
W
--
A gossip is someone with a great sense of rumour.
Sortir en Pantoufles: up 947 days, 22:39
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-07-12 23:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-04 15:36 [gentoo-user] [OT] rrd to CSV Mick
2009-07-04 16:23 ` Mark Shields
2009-07-04 19:20 ` Mick
2009-07-05 22:07 ` Mick
2009-07-06 16:15 ` Willie Wong
2009-07-11 14:57 ` Mick
2009-07-12 23:59 ` Willie Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox