From d6e68ff5b9e3996ee10262f48038a8d8c9dff1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Sch=C3=B6chlin?= Date: Thu, 22 Sep 2022 15:00:02 +0200 Subject: [PATCH] add device file check --- extension-files/tools/zabbix_discovery_devices | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/extension-files/tools/zabbix_discovery_devices b/extension-files/tools/zabbix_discovery_devices index 7b7fb14..8121599 100755 --- a/extension-files/tools/zabbix_discovery_devices +++ b/extension-files/tools/zabbix_discovery_devices @@ -141,6 +141,13 @@ parser.add_argument( action='store_true', ) +parser.add_argument( + '--check_devdev', + help='Check fpr a device at /dev', + action='store_true', +) + + parser.add_argument( '--software_raid', help='Discovery for software_raid', @@ -176,15 +183,20 @@ else: if args.debug: sys.stderr.write("** Effective config:\n%s\n" % json.dumps(config, indent=2)) + # perform discovery for filename in glob.glob('/sys/block/*'): if not os.path.islink(filename): continue + device_name = os.path.basename(filename) device_model_file = "/sys/block/%s/device/model" % device_name device_model = "UNDEFINED" + if args.check_devdev and not os.path.exists("/dev/%s" % device_name): + continue + if os.path.isfile(device_model_file): with open(device_model_file) as f_model: device_model = f_model.readline() @@ -220,6 +232,7 @@ for filename in glob.glob('/sys/block/*'): sys.stderr.write("ignoring device %s, its size is 0\n" % device_name) continue + raid_disks_level_file = "/sys/block/%s/md/level" % device_name raid_disks_level = None if os.path.isfile(raid_disks_level_file):