In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
#-*-coding: utf-8-*-import json,reimport urllib.request, urllib.error Urllib.parseclass ZabbixAPI: # initialize def _ _ init__ (self): self.__url = 'http://192.168.74.133/api_jsonrpc.php' self.__user =' admin' self.__password = 'zabbix' self.__header = {"Content-Type": "application/json-rpc"} self.__token_id = self.UserLogin () # Log in to get token def UserLogin (self): data = {"jsonrpc": "2.0" "method": "user.login", "params": {"user": self.__user, "password": self.__password}, "id": 0,} return self.PostRequest (data) # push request def PostRequest (self, data): request = urllib.request.Request (self.__url Json.dumps (data) .encode ('utf-8'), self.__header) result = urllib.request.urlopen (request) response = json.loads (result.read (). Decode (' utf-8')) try: return response ['result'] except KeyError: pass # get the specified template ID name def GetTemplatesID (self Template_name): data = {"jsonrpc": "2.0"," method ":" template.get "," params ": {" output ":" templateid "," filter ": {" host ": Template_name}}," auth ": self.__token_id "id": 0} Template_ID_List = self.PostRequest (data) return Template_ID_List [0] ["templateid"] # get all trigger ID from the specified template ID and return the trigger name description def GetAllTriggersIDFromTemplatesID (self,Template_name): TemplatesID = self.GetTemplatesID (Template_name) data = {"jsonrpc": "2.0" "method": "trigger.get", "params": {"templateids": TemplatesID, "output": ["description"]}, "auth": self.__token_id, "id": 0} return self.PostRequest (data) # Update trigger name def updateTriggerName (self,TriggerID=None Description=None): data = {"jsonrpc": "2.0"," method ":" trigger.update "," params ": {" triggerid ": TriggerID," description ": description}," auth ": self.__token_id "id": 0} return self.PostRequest (data) # get the original trigger name And replace a specific string for batch update trigger name def ReWriteTriggerName (self,Template_name): StringJson = self.GetAllTriggersIDFromTemplatesID (Template_name) # print (StringJson) # print (type (StringJson)) for i in range (len (StringJson)): ret = re.sub ('closed','is down'' StringJson [I] ["description"]) self.updateTriggerName (StringJson [I] ["triggerid"], ret) def main (): # instantiate zabbix class zapi=ZabbixAPI () # template Select hosts=zapi.ReWriteTriggerName ("Template OS Linux") if _ _ name__ ='_ _ main__': main ()
List of trigger names in the previous Templates-OS-linux template:
List after use:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.