Monitoring disk IO Discovery scripts
Script content:
#!/usr/bin/perl
# Notice
# Apply Zabbix version 2.4.x to 3.0.3
# Auto Search disk I/O
#################################################################################
Sub get_vmname_by_id
{
$vmname = ' cat/etc/qemu-server/$_[0].conf | grep name | cut-d \: F 2 ';
$vmname =~ s/^\s+//;
$vmname =~ s/\s+$//;
Return $vmname
}
$first = 1;
print "{\ n";
Print "\t\" "data\": [\ n];
For (' Cat/proc/diskstats ')
{
($major, $minor, $disk) = m/^\s* ([0-9]+) \s+ ([0-9]+) \s+ (\s+) \s.*$/;
$dmnamefile = "/sys/dev/block/$major: $minor/dm/name";
$vmid = "";
$vmname = "";
$dmname = $disk;
$diskdev = "/dev/$disk";
if (-e $dmnamefile) {
$dmname = ' Cat $dmnamefile ';
$dmname =~ s/\n$//; #remove trailing \ n
$diskdev = "/dev/mapper/$dmname";
if ($dmname =~ m/^.*--([0-9]+)--. *$/) {
$vmid = $;
}
}
Print "\t,\n" if not $first;
$first = 0;
print "\t{\n";
Print "\t\t\" {#DISK}\ ": \" $disk \, \ n ";
Print "\t\t\" {#DMNAME}\ ": \" $dmname \, \ n ";
Print "\t\t\" {#VMNAME}\ ": \" $vmname \, \ n ";
Print "\t\t\" {#VMID}\ ": \" $vmid \ \ n;
print "\t}\n";
}
print "\n\t]\n";
print "}\n";
Userparameter:
userparameter=discovery.disks.iostats,/etc/zabbix/scripts/disk.pl
Userparameter=custom.vfs.dev.read.sectors[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$6} '
Userparameter=custom.vfs.dev.write.sectors[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$10} '
Userparameter=custom.vfs.dev.read.ops[*],cat/proc/diskstats | grep $ | Head-1 |awk ' {print $$4} '
Userparameter=custom.vfs.dev.write.ops[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$8} '
Userparameter=custom.vfs.dev.read.ms[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$7} '
Userparameter=custom.vfs.dev.write.ms[*],cat/proc/diskstats | grep $ | head-1 | awk ' {print $$11} '
Disk Io.png
TCP Monitoring:
To schedule tasks to add:
*/1 * * * */usr/sbin/ss-tan|awk ' nr>1{++s[$1]}end{for (A in S) print A,s[a]} ' >/tmp/tcp-status.txt
*/1 * * * */usr/sbin/ss-o State established ' (Dport =: http or sport =: http) ' |grep-v netid >/tmp/httpnub.txt
Userparameter:
Userparameter=tcp.status[*],awk ' {if ($$1~/^$1/) print $$2} '/tmp/tcp-status.txt
Userparameter=tcp.httpd_established,awk ' nr>1 '/tmp/httpnub.txt|wc-l