Add notes via with hosts already added

User / Community contributed content: modifications, patches, extensions, modules, scripts etc.
Posts: 5
Joined: Mon Mar 19, 2012 23:45

Add notes via with hosts already added

Post by 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,"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/
[INFO]  CSV syntax found in file header. Using it.
[INFO]  Adding host ''
[WARN]  host with host_name '' already exists!
[ERROR] Failed to add host ''. Aborting
Is there a way to just update the notes field while already having host_name already existing? Any help is appreciated, thanks.


Re: Add notes via with hosts already a

Post by 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 :)