473,398 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Easiest way to parse text from xml file (sed, awk, shell?)

Colloid Snake
144 100+
Hey everyone. I'm currently attempting to band-aid an horrible use of a Cacti implementation (and I swear, this is only temporary! No, really! They told me it's in the budget for next year, and has already been approved... I hope...) Anyway... I am using rrdtool to dump the data into an xml file.

So this xml file is going to have several hundred (possibly thousand) lines that consist of:
<some tag I'm forgetting> <some other tag> datestamp </some other tag> <v> (either NaN or 0.0000000000000000000000e1)</v> </some tag I'm forgetting>

I apologize for my wonderfully specific detail in there, but I had a systems crash last night, which means I can't ssh into the cacti box (I forgot the IP :( ), or pull up the xml or rrd files I had on my local computer - sorry!.

My goal is to do two things - make sure the date is within a week of the date parsed (this is going to be in cron), and increment either of two counters (one for NaN, one for the .0000whatever). There are approximately 300 hosts/rrd files that I have to do this for, I believe the rrd files contain data from the last month, so there's a good portion of the data I will be dropping, and I was wondering if there was an "easy" language in which to do the date comparison/incrementing. Right now it's all in shell, but that is just as a proof of concept for management, I haven't tried to parse through that xml file or read all the hostnames from the other cacti database yet, it seems like sed or awk might be more convenient, or should I just try to do the whole thing in python or perl or something?

Any input is appreciated.
Jul 2 '07 #1
1 21842
cnemo
1
check it out: SED to parse and modify XML element nodes

hope it helps,
cnemo
Sep 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Rigga | last post by:
Hi, I am new to Python and need to parse a text file and cut parts out i.e. say the text file contained 5 rows of text: line 1 of the text file line 2 of the text file line 3 of the text...
0
by: John M. Lembo | last post by:
I am using Perl to parse a text file and output to another file. The text file has data on Unix virtual memory (vmstat) and I want to delete lines that I don't want and output lines that I want to...
2
by: Tyaan | last post by:
Hi.. I'm a perl noob need to know how to write a script to parse a file containing one to four of the following blocks of text? I then want to print the results in a format showing the memory size...
6
by: Porky | last post by:
I have an asp page that successfully writes out the form data to a text file. I would like to use Blat (or other free email utility) to send the contents of the text file to a user. The code to...
2
by: Sacha Korell | last post by:
How would I check for an end of file when parsing a text file using the StreamReader object? I would like to do something like this: '******************************** Dim objStreamReader As...
3
by: boukaka | last post by:
Hi there, I have a text file that does not have any delimiters - it is simply assumed that I know how long each field is and they are always in the same order. (i.e. JOHN DOE ...
13
by: gavino | last post by:
This seems easy but I have been asking tcl and python IRC chat all day and no one gave an answer. I have 100 servers which need a new backup server added to a text file, and then the backup agent...
15
by: batman | last post by:
i have a text file that is like: date = OCT0606 asdf sdaf asdfasdgsdgh asdfsdfasdg START-OF-DATA asdfasdfg asdfgdfgsfg
1
by: ljungers | last post by:
Help needed with shell script using the sed command. Need to extract a date from a text file. Each record contains the text "Date Entered:" and following that literial is a space followed by...
0
by: =?Utf-8?B?TW9ydGVuIFdlbm5ldmlrIFtDIyBNVlBd?= | last post by:
"DavidM" wrote: That is correct. My code only checks for a single "Blocks used" section. If there are more just run the method again with the same binaryreader, or find the next matching...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.