Skip to content

Commit

Permalink
add device file check
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Schöchlin committed Sep 22, 2022
1 parent a2a4d59 commit d6e68ff
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions extension-files/tools/zabbix_discovery_devices
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d6e68ff

Please sign in to comment.