]> git.uio.no Git - uio-zabbix.git/blob - get_webapp_instances_v2.py
Add zabbix autodiscovery script for rabbitmq
[uio-zabbix.git] / get_webapp_instances_v2.py
1 #!/usr/bin/env python
2 #
3 # Authors:
4 # rafael@e-mc2.net / https://e-mc2.net/
5 #
6 # Copyright (c) 2016-2017 USIT-University of Oslo
7 #
8 # get_webapps_instances.py is free software: you can redistribute
9 # it and/or modify it under the terms of the GNU General Public
10 # License as published by the Free Software Foundation, either version
11 # 3 of the License, or (at your option) any later version.
12 #
13 # get_webapps_instances.py is distributed in the hope that it will
14 # be useful, but WITHOUT ANY WARRANTY; without even the implied
15 # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 # See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with sms_send.  If not, see <http://www.gnu.org/licenses/>.
20 #
21
22 import os
23 import sys
24 import json
25 import requests
26
27 # Zabbix-mgmt
28 zabbix_mgmt_url = 'http://zabbix-mgmt.uio.no/zabbix/V2' 
29
30 # ############################################
31 # get_webapps_servers()
32 # ############################################
33
34 def get_webapp_instances(application):
35
36     try:
37
38         request_data = requests.get(zabbix_mgmt_url + "/" + application + ".json")
39
40         if request_data.status_code != 200:
41             sys.exit(1)
42             
43         autodiscovery_data = request_data.content
44         print autodiscovery_data
45
46     except Exception:
47         sys.exit(1)
48
49
50 # ############################################
51 # Main
52 # ############################################
53
54 if __name__ == '__main__':
55
56     try:
57         application = sys.argv[1]
58         get_webapp_instances(application)
59         
60     except Exception, e:
61         sys.exit(1)