Add notes via add_items_from_csv.pl with hosts already added

User / Community contributed content: modifications, patches, extensions, modules, scripts etc.

Add notes via add_items_from_csv.pl with hosts already added

Postby afrazee » Sun Jun 24, 2012 20:11

I am trying to add notes to existing hosts via a csv file. Here is what my csv file looks like:


Code: Select all
host_name,notes
xxx.xxx.com,"latlng: 00.354174999999998,-00.818301000000005"


and when i run it in simulation mode it says:

Code: Select all
[INFO]  Running in simulation mode. No modifications will be made to the database!
[INFO]  Started executing /var/www/nconf/bin/add_items_from_csv.pl
[INFO]  CSV syntax found in file header. Using it.
[INFO]  Adding host 'xxx.xxx.com'
[WARN]  host with host_name 'xxx.xxx.com' already exists!
[ERROR] Failed to add host 'xxx.xxx.com'. Aborting


Is there a way to just update the notes field while already having host_name already existing? Any help is appreciated, thanks.
afrazee
beginner
beginner
 
Posts: 5
Joined: Mon Mar 19, 2012 23:45

Re: Add notes via add_items_from_csv.pl with hosts already a

Postby Guest » Mon Jun 25, 2012 15:53

I have come up with my own solution, I am doing it via php/mysql, here is how I did it:

Code: Select all
$result_nconfdb_autoadd_lat_and_long = mysql_query("REPLACE INTO ConfigValues (attr_value, fk_id_attr, fk_id_item) VALUES ('latlng: 00.354174999999998,-00.818301000000005', '24', '$fk_id_item_var')");


attr_value = what you want notes to have
fk_id_attr = 24 = notes
fk_id_item = each host has an unique fk_id_item, i have not presented how I determined this, but could be done easily.

Maybe this will help someone in the future, thanks :)
Guest
 


Return to Contributions

Who is online

Users browsing this forum: No registered users and 1 guest

cron