Estimating server disk space availability using the Zabbix API

Source: Internet
Author: User

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:

  1. 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 ']
  2. 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}
  3. 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
  4. The current remaining space/average to get the final result.

Objective:

    1. Master the use of Python to access the Zabbix API.

    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.