Hello fellow monkeys,
I am new to perl scripting and I have spent 6 hours trying to write a script that would prase a nagios services.cfg file.
One variable in the services.cfg file called "services_description" is missing in many definitions, some do have them set, the definition always start with
definition{ and ends with }.
I was doing line by line with many if's to go thru the 30 thousand lines text file,but still not working :(
Anyways here is the example of the file...
define service{
use sam_win_cpu_load
host_name buo.va.com
contact_groups buo_admins
}
define service{
use generic-service
host_name buo.va.com
service_description MS SQL Server
check_command check_service_state!MSSQLSERVE
+R!public
contact_groups buo_admins
}
When the service_definition dosent exist I have a subroutine
that parses the use and just remove the sam from it and returns... (that is the easy part)
Should I put entire file into an array, split it?
Any ideas are very very welcome
p.s. i can paste my ugly code if anyone wants...
thanks,
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.