Hello.
Zabbix API is a great thing to do certain tasks automatically trough scripts.
Currently I have to do a very simple thing: Get all the hosts from a group which contain only one or less templates and direct those hosts into a text file.
This is needed as all hosts from discovery get one template and therefore its needed to notify the admins who forgot to configure their hosts(eg, add more templates to them).
Currently with the help of Zabbix documentation I've only managed to pull all the hosts from a particular group and list all of the templates attached to them(very crudely).
I've made it into a bash script and ideally it should be a weekly cronjob.
The current script resides in my github repo: LINK
Briefly, how it works:
1) Script checks if there is a place to put the host list file, if not , creates it, if it fails stops.
2) Authenticates using credentials given in static variables section
2.1) makes auth token a variable for use in next step
3) Pulls all information about hosts in a group specified in static variables
4) Sends it trough python JSON tool and then using grep cuts out everything unneccesary and sends the results to a file.
Usually the result is like this(i'll use zabbix server as an example):
"name": "Zabbix server",
<IDENT>"name": "Template OS Linux",
<IDENT>"name": "Template App Zabbix Server",
But in production we have over 500 Windows hosts and over 500 GNU/Linux hosts. So the list is huge and finding the hosts that have 1 or less templates attached to them is tedious and beats the point of an script in a weekly cron.
My Zabbix test server is CentOS7 with Zabbix 2.2.8 and production is CentOS6 with Zabbix 2.2.7.
Anyone got any ides to achieve such a thing?
I'll post more info if needed.
Thanks,
Kristjan
Zabbix API is a great thing to do certain tasks automatically trough scripts.
Currently I have to do a very simple thing: Get all the hosts from a group which contain only one or less templates and direct those hosts into a text file.
This is needed as all hosts from discovery get one template and therefore its needed to notify the admins who forgot to configure their hosts(eg, add more templates to them).
Currently with the help of Zabbix documentation I've only managed to pull all the hosts from a particular group and list all of the templates attached to them(very crudely).
I've made it into a bash script and ideally it should be a weekly cronjob.
The current script resides in my github repo: LINK
Briefly, how it works:
1) Script checks if there is a place to put the host list file, if not , creates it, if it fails stops.
2) Authenticates using credentials given in static variables section
2.1) makes auth token a variable for use in next step
3) Pulls all information about hosts in a group specified in static variables
4) Sends it trough python JSON tool and then using grep cuts out everything unneccesary and sends the results to a file.
Usually the result is like this(i'll use zabbix server as an example):
"name": "Zabbix server",
<IDENT>"name": "Template OS Linux",
<IDENT>"name": "Template App Zabbix Server",
But in production we have over 500 Windows hosts and over 500 GNU/Linux hosts. So the list is huge and finding the hosts that have 1 or less templates attached to them is tedious and beats the point of an script in a weekly cron.
My Zabbix test server is CentOS7 with Zabbix 2.2.8 and production is CentOS6 with Zabbix 2.2.7.
Anyone got any ides to achieve such a thing?
I'll post more info if needed.
Thanks,
Kristjan
Comment