]> git.uio.no Git - uio-zabbix.git/commitdiff
Add zabix externalscript used to get autodiscovery data with instance information...
authorRafael Martinez <r.m.guerrero@usit.uio.no>
Mon, 21 Mar 2016 13:57:02 +0000 (14:57 +0100)
committerRafael Martinez <r.m.guerrero@usit.uio.no>
Mon, 21 Mar 2016 13:57:02 +0000 (14:57 +0100)
get_webapp_instances.py [new file with mode: 0755]

diff --git a/get_webapp_instances.py b/get_webapp_instances.py
new file mode 100755 (executable)
index 0000000..68f693c
--- /dev/null
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+#
+# Authors:
+# rafael@postgresql.org.es / http://www.postgresql.org.es/
+#
+# Copyright (c) 2016 USIT-University of Oslo
+#
+# get_webapps_instances.py is free software: you can redistribute
+# it and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation, either version
+# 3 of the License, or (at your option) any later version.
+#
+# get_webapps_instances.py is distributed in the hope that it will
+# be useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with sms_send.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+import sys
+import json
+import requests
+
+# Zabbix-mgmt
+zabbix_mgmt_url = 'http://zabbix-mgmt.uio.no/zabbix' 
+
+# ############################################
+# get_webapps_servers()
+# ############################################
+
+def get_webapp_instances(application):
+
+    try:
+
+        request_data = requests.get(zabbix_mgmt_url + "/" + application + ".json")
+
+        if request_data.status_code != 200:
+            sys.exit(1)
+            
+        autodiscovery_data = request_data.content
+        print autodiscovery_data
+
+    except Exception:
+        sys.exit(1)
+
+
+# ############################################
+# Main
+# ############################################
+
+if __name__ == '__main__':
+
+    try:
+        application = sys.argv[1]
+        get_webapp_instances(application)
+        
+    except Exception, e:
+        sys.exit(1)