January 2019
Intermediate to advanced
798 pages
20h 33m
English
First, let's try to do something that is already available in recent Zabbix agents—discovering CPUs. We do this both because it could be useful if you have a system running an old agent and because it shows how straightforward LLD can be on occasion. To do this, let's consider the following script:
for cpu in $(ls -d /sys/devices/system/cpu/cpu[0-9]*/); do
cpui=${cpu#/sys/devices/system/cpu/cpu}
[[ $(cat ${cpu}/online 2>/dev/null) == 1 || ! -f ${cpu}/online]] && status=online || status=offline; cpulist=$cpulist,'{{#CPU.NUMBER}:'${cpui%/}', {#CPU.STATUS}:'$status'}'
done
echo '{data:['${cpulist#,}']}'
It relies on /sys/devices/system/cpu/ holding a directory for each CPU, named cpu, followed by the CPU number. ...
Read now
Unlock full access