Import host CSV file?

Jon Lyons jlyons30 at yahoo.com
Tue Nov 4 20:41:45 CET 2003


Skip, Thanks for the reply, Jeff Vier Sent me a small simple awk scrip that works great, I'm sending it to the nagios list for the archives. I hope Jeff doesn't mind.. :)
 
I would've spent the entire day trying to do something in perl(Not much of a perl/scripting person)....
 

#!/bin/awk -f# usage: ./csv.to.nagios.hosts.awk [file.csv]...BEGIN { FS="," }{	print "define host {"	print "\tuse\t\tgeneric"	print "\thost_name\t" $1	print "\talias\t\t" $2	print "\taddress\t\t" $3	print "\tparents\t\t" $4 "," $5	print "\t}"	print ""}

 
 


Skip Montanaro <skip at pobox.com> wrote:

Jon> Has anyone writen a script to import a large number of hosts from a
Jon> CSV file into nagios? Just wondering...

No, but it shouldn't be too difficult. I use Python (2.3 comes with an
easy-to-use csv module of which I am a co-author), but I suspect you
wouldn't have much trouble with Perl, Tcl or Ruby presuming they either
support csv file reading or that your csv file doesn't exercise csv's corner
cases.

What sort of information do you have in your csv file? If it's just basic
name, alias, ip sorts of stuff, then generating host definitions from that
should be a breeze.

-- 
Skip Montanaro
Got gigs? http://www.musi-cal.com/
http://www.mojam.com/
Got spam? http://spambayes.sf.net/


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null

---------------------------------
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20031104/7cd3db84/attachment.html>


More information about the Users mailing list