Zabbix automatic disk IO and TCP monitoring

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.