Browse Source

Add support for 'local' WEB/SSL probes

Emmanuel Bouthenot 3 years ago
parent
commit
47193e8f4d

+ 1 - 1
plugins/client/ssl-discovery/conf/ssl-discovery.conf

@@ -1 +1 @@
-UserParameter=ssl.discovery,/etc/zabbix/scripts/yaml2json /etc/zabbix/zabbix_plugins.conf.d/ssl-discovery.yml
+UserParameter=ssl.discovery,/etc/zabbix/scripts/yaml2json /etc/zabbix/zabbix_plugins.conf.d/ssl-discovery.yml /etc/zabbix/zabbix_plugins.conf.d/ssl-discovery.local.yml

+ 23 - 22
plugins/client/utils/scripts/yaml2json

@@ -13,7 +13,7 @@ import traceback
 # {{{ Constants
 _NAME = "yaml2json"
 _DESC = "Convert yaml data to zabbix json discovery format"
-_VERSION = "0.1"
+_VERSION = "0.2"
 # }}}
 
 # {{{ main()
@@ -23,29 +23,30 @@ def main():
                         version='%(prog)s ' + _VERSION)
     parser.add_argument('-d', '--debug', dest='debug', default=False, action='store_true',
                         help='Print additional debug informations: traceback, etc. (default: no)')
-    parser.add_argument('datafile')
+    parser.add_argument('datafiles', nargs='+')
     options = parser.parse_args()
     data = {'data': []}
-    if os.path.exists(options.datafile):
-        try:
-            with open(options.datafile, encoding='utf-8') as f:
-                datayml = yaml.safe_load(f)
-                if datayml is not None:
-                    for section in datayml:
-                        localdata = {
-                            '{#KEY}': section,
-                        }
-                        for k in datayml[section]:
-                            localdata['{#%s}' % (k.upper())] = datayml[section][k]
-                        data['data'].append(localdata)
-        except Exception as e:
-            if not options.debug:
-                print('Exception raised (use --debug option to get more info): %s' % (e), file=sys.stderr)
-            else:
-                print('Exception raised: %s' % (e), file=sys.stderr)
-                traceback.print_exc(file=sys.stderr)
-            print('ZBX_NOTSUPPORTED')
-            sys.exit(-1)
+    for datafile in options.datafiles:
+        if os.path.exists(datafile):
+            try:
+                with open(datafile, encoding='utf-8') as f:
+                    datayml = yaml.safe_load(f)
+                    if datayml is not None:
+                        for section in datayml:
+                            localdata = {
+                                '{#KEY}': section,
+                            }
+                            for k in datayml[section]:
+                                localdata['{#%s}' % (k.upper())] = datayml[section][k]
+                            data['data'].append(localdata)
+            except Exception as e:
+                if not options.debug:
+                    print('Exception raised (use --debug option to get more info): %s' % (e), file=sys.stderr)
+                else:
+                    print('Exception raised: %s' % (e), file=sys.stderr)
+                    traceback.print_exc(file=sys.stderr)
+                print('ZBX_NOTSUPPORTED')
+                sys.exit(-1)
     print(json.dumps(data, indent=4))
 # }}}
 

+ 2 - 2
plugins/client/web-discovery/conf/web-discovery.conf

@@ -1,2 +1,2 @@
-UserParameter=web.availability.discovery,/etc/zabbix/scripts/yaml2json /etc/zabbix/zabbix_plugins.conf.d/web-availability-discovery.yml
-UserParameter=web.metrics.discovery,/etc/zabbix/scripts/yaml2json /etc/zabbix/zabbix_plugins.conf.d/web-metrics-discovery.yml
+UserParameter=web.availability.discovery,/etc/zabbix/scripts/yaml2json /etc/zabbix/zabbix_plugins.conf.d/web-availability-discovery.yml /etc/zabbix/zabbix_plugins.conf.d/web-availability-discovery.local.yml
+UserParameter=web.metrics.discovery,/etc/zabbix/scripts/yaml2json /etc/zabbix/zabbix_plugins.conf.d/web-metrics-discovery.yml /etc/zabbix/zabbix_plugins.conf.d/web-metrics-discovery.local.yml