I am able to get the host group id by
puts zbx.hostgroups.get(:name => "Dev" )
give this o/p
{"groupid"=>"13", "name"=>"Dev", "internal"=>"0", "flags"=>"0"}
But I want to get all the nodes under this host group. Although I tried in other way like get all host under this host group but I didnt find groupid attribute in host please refer below o/p
puts zbx.hosts.get(:host => "ip-10-10-111-11.ec2.internal")
{"maintenances"=>[], "hostid"=>"10251", "proxy_hostid"=>"10109", "host"=>"ip-10-10-111-11.ec2.internal", "status"=>"0", "disable_until"=>"0", "error"=>"", "available"=>"1", "errors_from"=>"0", "lastaccess"=>"0", "ipmi_authtype"=>"0", "ipmi_privilege"=>"2", "ipmi_username"=>"", "ipmi_password"=>"", "ipmi_disable_until"=>"0", "ipmi_available"=>"0", "snmp_disable_until"=>"0", "snmp_available"=>"0", "maintenanceid"=>"0", "maintenance_status"=>"0", "maintenance_type"=>"0", "maintenance_from"=>"0", "ipmi_errors_from"=>"0", "snmp_errors_from"=>"0", "ipmi_error"=>"", "snmp_error"=>"", "jmx_disable_until"=>"0", "jmx_available"=>"0", "jmx_errors_from"=>"0", "jmx_error"=>"", "name"=>"ip-10-10-111-11.ec2.internal", "flags"=>"0", "templateid"=>"0"}
I didnot find any relation between hosts & hostgroups.
I got it working in the below manner
host_grps = zbx.query(
:method => "host.get",
:params => {
"output" => "extend",
"groupids" => [14]
}
)
puts host_grps
Its gives host groups in list of hashmap.