Hello all! This checkbox is disabled by default, and then new host was autodiscovered and added to hosts, profile is unreacheabe. I wrote a script, adding host's information in profile from other database (directly in hosts_profiles table) but if this option is disabled, data cannot be added in this table. How can I enable it? Thanks!
Ad Widget
Collapse
'Use profile' checkbox disable by default, how to enable?
Collapse
X
-
Tags: None
-
A record in table "hosts_profiles" defines if host profile is used or not. -
-
I have the same issue. I'm trying to use the zabbix_api.py but i can't seem to figure out how to "enable" useprofile. When i used the webui with a script i made with wget commands, simply putting useprofile=yes worked fine
here is some of my code in my api:
If i update a host and use the profile fields as above it updates them accordingly. I just need to figure out how to set "useprofile" for the host.HTML Code:h_info = zapi.host.create({"host" : h_name, "devicetype" : h_group, "status" : h_status, "name" : h_name, "useprofile" : "yes", # not working right "profile" : {"tag" : h_tag, "macaddress" : h_mac, "hardware" : h_hardware, "software" : h_software, "serialno" : h_sn, "contact" : "", "location" : h_location, "os" : h_os, "notes" : h_notes}, "config" : "0", "groups" : {"groupid" : h_groupid}, "port" : "0", "ip" : h_ip, "useip" : "1", "proxy_hostid" : "0", "dns" : "", "ipmi_ip" : "", "ipmi_port" : "0", "ipmi_authtype" : "0", "ipmi_privilege" : "0", "ipmi_username" : "", "ipmi_password" : "", "templates" : [{"templateid" : template} , {"templateid" : template_two}] })
i installed phpmyadmin and found the table in zabbix hosts_profiles but i didn't see a record to change to enable it by default to all hosts.
please help as i'm almost done, got over 10k hosts waiting to be added.Comment
-
Never Mind. I figured a way around it.
First you create the host. Then once the host is created successfully it will return the hostid (so you don't have to do host.get to get the hostid) and then update the host with the values. Here is small PART of my script:
I hope this is helpful to some other people as it took a while to figure this out as the documentation on the api is VERY limited.HTML Code:h_info = zapi.host.create({"host" : h_name, "devicetype" : h_group, "status" : h_status, "name" : h_name, "config" : "0", "groups" : {"groupid" : h_groupid}, "port" : "0", "ip" : h_ip, "useip" : "1", "proxy_hostid" : "0", "dns" : "", "ipmi_ip" : "", "ipmi_port" : "0", "ipmi_authtype" : "0", "ipmi_privilege" : "0", "ipmi_username" : "", "ipmi_password" : "", "templates" : [{"templateid" : template} , {"templateid" : template_two}] }) if h_info == []: result = "ERROR" else: #add profile info (hack around for now since host.create doesn't want to work) for field in h_info: zh_hostid = field['hostid'] h_info = zapi.host.update({"hostid" : zh_hostid, "profile":{"tag" : h_tag, "macaddress" : h_mac, "hardware" : h_hardware, "software" : h_software, "serialno" : h_sn, "contact" : "", "location" : h_location, "os" : h_os, "notes" : h_notes}, })
would be nice to just beable to create the host with its profile but then again it only milliseconds to update the profile since its not mass updating groups or anything hardcore.Comment
Comment