q1x / zabbix-gnomes

Various scripts to automate tasks in Zabbix
Other
179 stars 94 forks source link

Getting error when I run zgetinventory.py on certain hostgroups #2

Closed tomcote01 closed 8 years ago

tomcote01 commented 8 years ago

When I run this on my "Elastic Search" hostgroup I get this error:

./zgetinventory.py --hostgroups "Elastic Search" -F "software" "id","host","software" "12522","nw-es-201","2.4.0" "12523","nw-es-202.prod.pcln.com","2.4.0" "12524","nw-es-203.prod.pcln.com","2.4.0" "12525","nw-es-204.prod.pcln.com","2.4.0" "12526","nw-es-205.prod.pcln.com","2.4.0" "13493","ny-es-001.prod.pcln.com","2.4.0" "13494","ny-es-002.prod.pcln.com","2.4.0" "13495","ny-es-003.prod.pcln.com","2.4.0" "13550","ny-esclient-001.prod.pcln.com","2.4.0" "13580","nw-esclient-201.prod.pcln.com","2.4.4" "13655","nw-esmaster-201.prod.pcln.com","2.4.0" "13656","nw-esmaster-202.prod.pcln.com","2.4.0" "13657","nw-esmaster-203.prod.pcln.com","2.4.0" Traceback (most recent call last): File "./zgetinventory.py", line 305, in row.append(host['inventory'][field]) TypeError: list indices must be integers, not str

q1x commented 8 years ago

Hi, thanks for using this! Could it be the next hosts in the group doesn't have inventory enabled? You should be able to test with the '-i' flag. Please let me know the result!

q1x commented 8 years ago

Just tested this, it is indeed an error when encountering a host without inventory set. I've now commited a version which will handle this gracefully by returning empty fields for theses hosts.

Let me know if it work for you!

tomcote01 commented 8 years ago

Hey thanks Ray! It works finie now. I appreciate the quick fix

q1x commented 8 years ago

Awesome!