Skip to content

Commit

Permalink
Add toggle (#51)
Browse files Browse the repository at this point in the history
* exclude partitions when raid-, no-partitions- or raw-disk-option is present
* Rename discovery keys

- vfs.dev.discovery.detail tp vfs.dev.discovery.rawdisks
  It is neccessary to update the templates in your installation.
- Introduce a new discovery explicitly for smart devices
  vfs.dev.discovery.smart
  • Loading branch information
scoopex authored Dec 22, 2024
1 parent a5272a3 commit c284440
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion extension-files/agent-config/zabbix_disk_discovery.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Add a configfile to /etc/zabbix/item_zabbix_discovery_devices.conf
UserParameter=custom.vfs.dev.discovery,/usr/bin/zabbix_discovery_devices --config /etc/zabbix/item_zabbix_discovery_devices.json
Alias=vfs.dev.discovery:custom.vfs.dev.discovery
UserParameter=vfs.dev.discovery.detail,/usr/bin/zabbix_discovery_devices --smart --config /etc/zabbix/item_zabbix_discovery_devices.json
UserParameter=vfs.dev.discovery.rawdisks,/usr/bin/zabbix_discovery_devices --only_rawdisk --config /etc/zabbix/item_zabbix_discovery_devices.json
UserParameter=vfs.dev.discovery.softwareraid,/usr/bin/zabbix_discovery_devices --software_raid --config /etc/zabbix/item_zabbix_discovery_devices.json
2 changes: 1 addition & 1 deletion extension-files/agent-config/zabbix_smartmontools.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# invoke /usr/bin/zabbix_discovery_devices --help to view information about configuration format
UserParameter=vfs.dev.discovery.rawdisks,/usr/bin/zabbix_discovery_devices --config /etc/zabbix/item_zabbix_discovery_devices.json --only_rawdisk
UserParameter=vfs.dev.discovery.smart,/usr/bin/zabbix_discovery_devices --config /etc/zabbix/item_zabbix_discovery_devices.json --only_rawdisk --smart
#
UserParameter=hardware.disk.health[*],sudo /usr/bin/zabbix_check_smartmontools --health --device "$1"
UserParameter=hardware.disk.smart.attributes[*],sudo /usr/bin/zabbix_check_smartmontools --device "$1" --attribute "$2"
Expand Down
30 changes: 22 additions & 8 deletions extension-files/tools/zabbix_discovery_devices
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,24 @@ parser.add_argument(

parser.add_argument(
'--software_raid',
help='Discovery for software_raid devices',
help='Discovery only for software_raid devices',
action='store_true',
)


parser.add_argument(
'--only_rawdisk',
help='Discovery for real raw/hardware devices',
help='Discovery only for real raw/hardware devices',
action='store_true',
)

parser.add_argument(
'--no_partitions',
help='Exclude partitions from discovery',
action='store_true',
)


parser.add_argument(
'--config',
nargs='?',
Expand Down Expand Up @@ -261,12 +268,19 @@ for filename in glob.glob('/sys/block/*'):
device['{#DEVTYPE}'] = "disk"
devices_discovered['data'].append(device)

for filename in glob.glob('/sys/block/*/*/partition'):
partition = os.path.basename(os.path.dirname(filename))
device = {}
device['{#DEVNAME}'] = partition
device['{#DEVTYPE}'] = "partition"
devices_discovered['data'].append(device)
if args.debug:
sys.stderr.write("** Discover partitions\n")

if args.no_partitions or args.software_raid or args.only_rawdisk:
if args.debug:
sys.stderr.write("do not add partitions to the result\n")
else:
for filename in glob.glob('/sys/block/*/*/partition'):
partition = os.path.basename(os.path.dirname(filename))
device = {}
device['{#DEVNAME}'] = partition
device['{#DEVTYPE}'] = "partition"
devices_discovered['data'].append(device)

if args.debug:
print(json.dumps(devices_discovered, sort_keys=True, indent=2))
Expand Down
2 changes: 1 addition & 1 deletion zabbix_templates/6.4/custom-os-linux-disk-io-details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<uuid>6e50927ae08242c0a136e53e23500428</uuid>
<name>Disk IO detail discovery</name>
<type>ZABBIX_ACTIVE</type>
<key>vfs.dev.discovery.detail</key>
<key>vfs.dev.discovery.rawdisks</key>
<delay>60m</delay>
<filter>
<conditions>
Expand Down
2 changes: 1 addition & 1 deletion zabbix_templates/6.4/custom-os-linux-hardware.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<uuid>841fe680e6cc4f1c9b6e7065ca044ffe</uuid>
<name>Hard Disk discovery</name>
<type>ZABBIX_ACTIVE</type>
<key>vfs.dev.discovery.rawdisks</key>
<key>vfs.dev.discovery.smart</key>
<delay>15m</delay>
<filter>
<conditions>
Expand Down

0 comments on commit c284440

Please sign in to comment.