added software field
This commit is contained in:
parent
77859cae09
commit
a93edaf002
|
|
@ -34,6 +34,11 @@ class Api(object):
|
|||
response = json.load(urllib.urlopen(self.get_request(url)))
|
||||
return response
|
||||
|
||||
def get_software_list(self):
|
||||
url = self.url + 'software'
|
||||
response = json.load(urllib.urlopen(self.get_request(url)))
|
||||
return response
|
||||
|
||||
|
||||
class Agent(object):
|
||||
|
||||
|
|
@ -49,6 +54,7 @@ class Agent(object):
|
|||
self.status = agent_json['status']
|
||||
self.details = self.download_agent_details()
|
||||
self.wmi_details = self.extract_wmi_details()
|
||||
self.software = Software(self.agent_id,self.api).software_json
|
||||
|
||||
def download_agent_details(self):
|
||||
url = self.api.url + 'agents' + '/' + str(self.agent_id)
|
||||
|
|
@ -77,7 +83,7 @@ class Agent(object):
|
|||
|
||||
def get_agent_metrics(self):
|
||||
new_values = {'agent_id': self.agent_id, 'hostname': self.hostname, 'site_name': self.site_name,
|
||||
'client_name': self.client_name, 'status': self.status}
|
||||
'client_name': self.client_name, 'status': self.status, 'software': self.software}
|
||||
agent_details = self.wmi_details
|
||||
agent_details['agent_info'] = new_values
|
||||
new_dict = {}
|
||||
|
|
@ -117,6 +123,15 @@ class Agent(object):
|
|||
return str(params)
|
||||
|
||||
|
||||
class Software(object):
|
||||
def __init__(self, agent_id, api_object):
|
||||
self.software_json = self.get_json(agent_id, api_object)
|
||||
|
||||
def get_json(self, agent_id, api_object):
|
||||
url = api_object.url + '/' + 'software' + '/' + agent_id
|
||||
response = urllib.urlopen(api_object.get_request(url))
|
||||
return json.load(response)
|
||||
|
||||
api = Api(URL, TOKEN)
|
||||
agent_list = api.get_agent_list()
|
||||
telegraf_client = TelegrafClient(host=config['telegraf']['host'], port=config['telegraf']['port'])
|
||||
|
|
|
|||
Loading…
Reference in New Issue