Advertisement
Guest User

Zabbix HDD LLD

a guest
Jul 18th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.98 KB | None | 0 0
  1. /etc/zabbix/device.discovery.pl:
  2. #!/usr/bin/env perl
  3. #
  4. # Zabbix device discovery to monitor Linux devices
  5. # https://www.kernel.org/doc/Documentation/iostats.txt
  6.  
  7. $first = 1;
  8.  
  9. print "{\n";
  10. print "\t\"data\":[\n\n";
  11.  
  12. for (`/bin/cat /proc/diskstats | /usr/bin/awk '{ print \$3 }'`)
  13. {
  14.     ($device) = m/(\S+)/;
  15.  
  16.     print "\t,\n" if not $first;
  17.     $first = 0;
  18.  
  19.     print "\t{\n";
  20.     print "\t\t\"{#DEVICE}\":\"$device\"\n";
  21.     print "\t}\n";
  22. }
  23.  
  24. print "\n\t]\n";
  25. print "}\n";
  26.  
  27.  
  28. /etc/zabbix/zabbix_agentd.conf.d/hdd.conf:
  29. # Disk IO metrics
  30.  
  31. # Discovery script
  32. UserParameter=linux.proc.diskstats.discovery,/etc/zabbix/device.discovery.pl
  33. # Keys (See https://www.kernel.org/doc/Documentation/iostats.txt)
  34. # TODO: Augment the device.discovery.pl script to double as a stat selector
  35. UserParameter=linux.proc.diskstats.read.completed[*],/bin/grep " $1 " /proc/diskstats|tr -s ' '|cut -d' ' -f5
  36. UserParameter=linux.proc.diskstats.read.merged[*],/bin/grep " $1 " /proc/diskstats|tr -s ' '|cut -d' ' -f6
  37. UserParameter=linux.proc.diskstats.read.sectors[*],/bin/grep " $1 " /proc/diskstats|tr -s ' '|cut -d' ' -f7
  38. UserParameter=linux.proc.diskstats.read.ms_spent[*],/bin/grep " $1 " /proc/diskstats|tr -s ' '|cut -d' ' -f8
  39. UserParameter=linux.proc.diskstats.write.completed[*],/bin/grep " $1 " /proc/diskstats|tr -s ' '|cut -d' ' -f9
  40. UserParameter=linux.proc.diskstats.write.merged[*],/bin/grep " $1 " /proc/diskstats|tr -s ' '|cut -d' ' -f10
  41. UserParameter=linux.proc.diskstats.write.sectors[*],/bin/grep " $1 " /proc/diskstats|tr -s ' '|cut -d' ' -f11
  42. UserParameter=linux.proc.diskstats.write.ms_spent[*],/bin/grep " $1 " /proc/diskstats|tr -s ' '|cut -d' ' -f12
  43. UserParameter=linux.proc.diskstats.io.current[*],/bin/grep " $1 " /proc/diskstats|tr -s ' '|cut -d' ' -f12
  44. UserParameter=linux.proc.diskstats.io.ms_spent[*],/bin/grep " $1 " /proc/diskstats|tr -s ' '|cut -d' ' -f13
  45. UserParameter=linux.proc.diskstats.io.weighted[*],/bin/grep " $1 " /proc/diskstats|tr -s ' '|cut -d' ' -f14
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement