Code GitHub location .
Main function: Get all the machines under a Zabbix, calculate how many days the remaining disk space of these machines can be used according to "natural" growth.
Main process:
Get all the machines under a group.
def host_get_by_groupid (self,groupid): data = json.dumps ( { "Jsonrpc": "2.0", "Method": "Host.get", " Params ": { "Output": "Shorten", " Groupids ": Groupid, }, "Auth": self.authid, "id": 1, }) res = self.get_data (data) [' Result ']
The
Gets the remaining space on the disk for these machines at some point in the historical X-day time.
def history_get (Self,itemid,time_from): data = json.dumps ( { "Jsonrpc": "2.0", "Method": "History.get", "params": { "Itemids": [itemid], "Time_from": time_from, "Output": "Extend", " SortOrder ": " ASC ", "Limit": "1" }, "Auth": self.authid, "id": 1 }) res = self.get_data (data) [' Result '] log.debug (res) if (res != 0) and (len (res) == 1): return res[0] else: return {"Value":-1, " Clock ": Time_from}
Use 2 of the data to calculate the daily decrease value, remove the 2 maximum, and use these positive values for an average if decrease is a positive number for more than half days.
#if The decrease if more than increase, maybe they has a crontab to relase space. #like this 5 4 5 4 5 4
The current remaining space/average to get the final result.
Objective:
Master the use of Python to access the Zabbix API.
In order to more "realistic" to do capacity planning.
Reference:
#base from Http://wangwei007.blog.51cto.com/68019/1249770#The API document HTTPS://WWW.ZABBIX.COM/DOCUMENTATION/1.8/API
This article is from the "Intelligent Future _XFICC" blog, please be sure to keep this source http://xficc.blog.51cto.com/1189288/1692387
Estimating server disk space availability using the Zabbix API