Skip to content

Instantly share code, notes, and snippets.

@jalexandre0
Last active December 16, 2015 15:19
Show Gist options
  • Save jalexandre0/5454606 to your computer and use it in GitHub Desktop.
Save jalexandre0/5454606 to your computer and use it in GitHub Desktop.
Perl quick and dirty to get blockdevices. Used only in zabbix low level discovery. Its ugly, and works for me and... oh, wait, its perl. :D
#!/usr/bin/perl
$first = 1;
print "{\n";
print "\t\"data\":[\n\n";
#Need fix here. Proc Partitions to rescue
for (`/usr/bin/iostat -d 1 1 | grep -v Device | grep -v Linux| awk '{print \$1}' | sed '/^\$/d' `)
{
chomp $_ ;
print "\t,\n" if not $first;
$first = 0;
print "\t{\n";
print "\t\t\"{#BLOCKDEVICES}\":\"$_\"\n";
print "\t}\n";
}
print "\n\t]\n";
print "}\n";
#!/bin/bash
STATS=$(/usr/bin/iostat -d 1 1 $1 | grep -v Device | grep -v Linux | awk '{print $2}' | sed 's/,/./g')
if [ -z $STATS ] ; then
echo "NOT SUPPORTED"
else
echo $STATS
fi
##User Parameter for disks
UserParameter=disks.tps[*],/usr/local/bin/zabbix.disks.tps $1
UserParameter=disks.tps.discovery,/usr/local/bin/zabbix.blockdevices.discovery.pl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment