This article shares zabbix’s specific operation and practical objectives of system software and hardware monitoring, but does not describe the specific application construction of secondary development. In fact, after reading this article and knowing their own skilled operation, ordinary programmers will have specific implementation plans for secondary development.

Monitoring platform version:

Zabbix – release – 4.0

This article describes the specific objectives of the operation:

  • Mysql, Nginx and other development software performance monitoring
  • SNMP Third-party hardware performance monitoring
  • Physical disk I/O monitoring

Zabbix deployment preparation and installation configuration

1. Prepare documents

2. Install and compile zabbix server.

CD /usr/local/src/zabbix /** Start MySql**/ mkdir.. RPM -bundle.tar -c /usr/local/ SRC /MySql/ CD.. /MySql/ Chmod a+x MySql -* /* All mysql server first preinstallation relevant delete * * / RPM - aq | grep mysql Yum - remove mysql - libs * y/install their own version of * * * * / RPM - the ivh RPM RPM -ivh mysql-client-5.1.1.glibc23.x86_64. RPM RPM -ivh mysql-client-5.1.1.glibc23.x86_64 MySQL - devel - 5.1.72-1. Glibc23. X86_64. RPM RPM - the ivh MySQL - Shared - 5.1.72-1. Glibc23. X86_64. RPMCopy the code

cd .. /zabbix/conf/ cp my.cnf /etc cd /usr/bin/ ./mysql_install_db --user=root chkconfig mysql on mysqladmin -u root password 'sa'/start install libxml rely on * * * * / CD/usr/local/SRC/zabbix/tools/tar - ZXVF. / libxml2-2.9.1. Tar. Gz - C/usr/local/SRC/CD.. /.. /libxml2-2.9.1/./configure --with-python=no --enable-shared=no --with-pic=PIC make && make install /** Start installing zabbix **/ CD/usr/local/SRC/zabbix/tools/tar - ZXVF. / perl - 5.28.1. Tar. Gz - C/usr/local/SRC/CD. /.. /perl-5.28.1/ CFLAGS=' -m64-mtune =nocona'./ configure-des -a ccflags= -fpic make && make installCopy the code

Note:

yum install -y net-snmp-devel
yum install libevent-devel -y
yum -y install pcre*
yum install curl-devel -y
Copy the code

Or (when the above operation encounters error obstruction)

cd  /usr/local/src/zabbix/tools/net-snmp-devel
rpm -Uvh --force --nodeps *.rpm
cd /usr/local/src/zabbix/tools/libevent-devel
rpm -Uvh --force --nodeps *.rpm
cd /usr/local/src/zabbix/tools/curl-devel
tar -zxvf ./curl-7.64.0.tar.gz ./
cd ./curl-7.64.0
mkdir /usr/local/curl-devel
configure --prefix=/usr/local/curl-devel
make && make install
Copy the code

CD /usr/local/src/zabbix tar -zxvf. /zabbix-4.0.4.tar.gz -c /usr/local/src/cd.. /configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 make && make installCopy the code

3. Start installing the PHP nginx service.

CD/usr/local/SRC/zabbix/tools/tar - ZXVF. / openssl - s.t ar 1.0.1. Gz - C/usr/local/SRC/tar - ZXVF. / pcre - 8.21. Tar. Gz - C /usr/local/src/ cd .. / tar -xf./nginx-1.15.1.tar.gz -c /usr/local/ SRC CD.. /openssl-1.0.1s/./config --prefix=/usr/local/openssl make && make install CD.. / nginx - 1.15.1 /. / configure -- prefix = / usr/local/nginx - with - pcre = / usr/local/SRC/pcre - 8.21 --with-openssl=/usr/local/ SRC/openSSL-1.0.1s --with-http_ssl_module --with-http_stub_status_module make && make install cd /usr/local/src/zabbix/tools/ tar -zxvf ./jpegsrc.v9c.tar.gz -C /usr/local/src cd .. /.. /jpeg-9c/ ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static make && make install cd / usr/local/SRC/zabbix/tools/tar - ZXVF. / db - 4.7.25. Tar. Gz - C/usr/local/SRC CD.. /.. / db - 4.7.25 / build_unix /.. /dist/configure --prefix=/usr/local/BerkeleyDB make && make install cd /usr/local/src/zabbix/tools/ tar -zxvf ./openldap-2.4.40. TGZ -c /usr/local/src CD.. /.. / openldap - 2.4.40 / CPPFLAGS = "-i/usr/local/BerkeleyDB/include/" export CPPFLAGS LDFLAGS =" -l/usr/local/lib -L/usr/local/BerkeleyDB/lib/" export LDFLAGS LD_LIBRARY_PATH="/usr/local/BerkeleyDb/lib/" export LD_LIBRARY_PATH ./configure --prefix=/usr/local/openldap make && make install cd /usr/local/src/zabbix/tools/ tar -zxvf ./freetype-2.4.0.tar.gz -c /usr/local/src CD.. /.. / freetype - 2.4.0 /. / configure -- perfix = / usr/local/freetype make && make install CD/usr/local/SRC/zabbix/tools/tar ZXVF. - ./libpng-1.2.58.tar.gz -c /usr/local/src CD.. /.. /configure --prefix=/usr/local/libpng --enable-shared --enable-static make && make install CD /usr/local/ SRC /zabbix tar -zxvf. /php-7.1.26.tar.gz -c /usr/local/ SRC CD.. /php-7.1.26/ groupadd -g 101 zabbix-web useradd zabbix-web -g zabbix-web -p 123456./configure --prefix=/usr/local/ PHP --enable-fpm --with-fpm-user=zabbix-web --with-fpm-group=zabbix-web --with-openssl --with-libxml-dir --with-zlib --enable-mbstring --enable-bcmath --with-mysqli=mysqlnd --enable-mysqlnd --with-pdo-mysql --with-gd --with-png-dir=/usr/local/libpng/ --with-jpeg-dir=/usr/local/jpeg/ --with-zlib-dir --with-gettext --with-ldap=/usr/local/openldap/ --with-freetype-dir=/usr/local/freetype --enable-sockets --with-curl --enable-maintainer-zts make && make install cp php.ini-development /usr/local/php/lib/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp/usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cd .. /zabbix/conf/ cp php-fpm /etc/init.d/ cp nginx /etc/init.d/ cd /etc/init.d/ chmod a+x nginx php-fpm chkconfig --add PHP -fpm chkconfig PHP -fpm on chkconfig --add nginx chkconfig nginx on CD /usr/local/src/php-7.1.26/ex/g/. /configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir=/usr/local/jpeg/ --with-freetype-dir=/usr/local/freetype  --with-png-dir=/usr/local/libpng/ make && make install cp modules/* /usr/local/php/lib/php/extensions/no-debug-zts-20160303/Copy the code

cd /usr/local/src/zabbix/conf/
cp nginx.conf /usr/local/nginx/conf/
cp php.ini /usr/local/php/lib/
vim /usr/local/nginx/conf/nginx.conf
Copy the code

Service php-fpm start service nginx start CD /usr/local/src/zabbix-4.0.4/frontends/ PHP/mkdir /usr/local/nginx/html/zabbix cp -R * /usr/local/nginx/html/zabbix/Copy the code

4. Start importing zabbix basic database

service mysql start
Copy the code

Note: If Manager of pid-file quit without updating file appears when starting mysql, use the following method to solve the problem

ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock chown -R mysql:mysql /var/lib/mysql/ mysql -uroot -psa use mysql update user set password=password('sa') where user='root'; update user set host='%' where user='root' and host='localhost'; flush privileges; create user zabbix identified by 'zabbix'; grant all privileges on *.* to 'zabbix'@'%' identified by 'zabbix' with grant option; flush privileges; create database zabbix character set utf8 collate utf8_bin; grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'zabbix'; flush privileges; Exit CD/usr/local/SRC/zabbix/zabbix_scripts/zabbix server - mysql - 4.0.4 / zcat. Create SQL. Gz | mysql - uzabbix - h192.168.77.153 - database = zabbix - pCopy the code

5. Configure the Zabbix Web server.

http://192.168.77.153/zabbix/index.php or
http://192.168.77.153/zabbix/setup.php 
Copy the code

Start and configure Zabbix Server.

cd /usr/local/zabbix/ cp /usr/local/src/zabbix/conf/zabbix-server /etc/init.d/ cp /usr/local/src/zabbix/conf/zabbix-agent /etc/init.d/ cp /usr/local/src/zabbix/conf/zabbix_agentd.conf /usr/local/zabbix/etc/ cp /usr/local/src/zabbix/conf/zabbix_server.conf /usr/local/zabbix/etc/ chmod a+x/etc/init.d/zabbix-agent /etc/init.d/zabbix-server chkconfig zabbix-server on chkconfig zabbix-agent on vim /etc/zabbix_server.conf Modify the following configuration items: ListenPort=10051 DBHost=192.168.77.153 DBName= Zabbix DBUser= Zabbix DBPassword= Zabbix DBPort=3306 ListenIP=192.168.77.153 AllowRoot=1 User=root service zabbix-server startCopy the code

Vim. /etc/zabbix_agent Modify the following configuration items: Server=192.168.77.153 ListenPort=10050 ListenIP=192.168.77.153 ServerActive=192.168.77.153 Hostname=Zabbix Server AllowRoot=1 User=root UnsafeUserParameters=1 UserParameter=mysql.version,mysql -V UserParameter=mysql.status[*], /usr/local/zabbix/scripts/chk_mysql.sh $1 UserParameter=mysql.ping,/usr/bin/mysqladmin -uzabbix ping | grep -c alive UserParameter=nginx.status[*],/usr/local/zabbix/scripts/chk_nginx.sh $1 service zabbix-agent startCopy the code

Start and configure Zabbix Agent.

cd /usr/local/zabbix/
cp /usr/local/src/zabbix/conf/zabbix-agent /etc/init.d/
cp /usr/local/src/zabbix/conf/zabbix_agentd.conf /usr/local/zabbix/etc/
chmod a+x /etc/init.d/zabbix-agent
chkconfig zabbix-agent on
Copy the code

Open your browser and add a monitoring client.

Vim. /etc/zabbix_agent Modify the following configuration items: Server=192.168.77.153 ListenPort=10050 ListenIP=192.168.77.153 ServerActive=192.168.77.153 Hostname=153_agent AllowRoot=1 User=root UnsafeUserParameters=1 UserParameter=mysql.version,mysql -V UserParameter=mysql.status[*], /usr/local/zabbix/scripts/chk_mysql.sh $1 UserParameter=mysql.ping,/usr/bin/mysqladmin -uzabbix ping | grep -c alive UserParameter=nginx.status[*],/usr/local/zabbix/scripts/chk_nginx.sh $1 service zabbix-agent startCopy the code

Configuring database monitoring.

cd /usr/local/zabbix/
mkdir scripts
cp /usr/local/src/zabbix/zabbix_scripts/chk_mysql.sh /usr/local/zabbix/scripts/
chmod a+x ./scripts/chk_mysql.sh
chown -R root:root ./scripts/chk_mysql.sh
killall zabbix_agentd
service zabbix-agent start
Copy the code

Nginx HTTP service monitoring configuration.

cd /usr/local/zabbix/
mkdir scripts
cp /usr/local/src/zabbix/zabbix_scripts/chk_nginx.sh /usr/local/zabbix/scripts/
chmod a+x ./scripts/chk_nginx.sh
chown -R root:root ./scripts/chk_nginx.sh
vim ./scripts/chk_nginx.sh
Copy the code

killall zabbix_agentd
service zabbix-agent start
Copy the code

SNMP Third-party hardware device monitoring.

CD/usr/local/SRC/zabbix/tools/SNMP - 5.7.3. Tar ZXVF.net - tar. Gz - C/usr/local/SRC/CD. /.. /./configure --prefix=/usr/local/ SNMP Make && Make install vim /etc/profileCopy the code

Source /etc/profile
Copy the code

Note: SNMP monitors the common OID of third-party devices.

Here, IKuai soft routing is used to simulate third-party switch devices. Open the switch configuration page and enable the SNMP function.

The SNMP parameter values of the device model are obtained from the official website.

Add a host group.

Enter the host group name.

Added monitoring templates.

Enter the name of the monitoring template and the bound host group.

Find the newly added template and click in to configure monitoring items.

Go to Items -> Create Item.

Test several memory OID in IKuai with SNMPWalk to confirm that the server SNMP is ok.

Continue to configure monitoring parameters and confirm that the Settings are saved.

Configure the OID to be monitored based on the preceding figure. Four NEW OID monitoring items are added here.

Click Graphs -> Create GRAPs.

Select the monitoring item that you want to draw a diagram for and save it.

Click to select a monitoring server.

Configure the SNMP device address.

Bind templates to monitored hosts.

Confirm, add templates, update.

Wait a few minutes and check that SNMP is green.

Click Monitoring -> Graphs -> IKuai MemoryStatus to see switch usage information.

Note: SNMP monitors the private OID of a third-party device

1. Prepare the official private MIB file.

net-snmp-config --default-mibdirs
Copy the code

cd /usr/local/snmp/share/snmp/mibs/
cp /usr/local/src/zabbix/conf/ikuai-mib.txt /usr/local/snmp/share/snmp/mibs/
Vim ./ikuai-mib.txt
Copy the code

snmptranslate -Tz -m IKUAI-MIB | column -t | head
Copy the code

Snmpwalk -v 2c -p public 192.168.77.1 1.3.6.1.4

Disk I/O Monitoring

yum install sysstat cp /usr/local/src/zabbix/zabbix_scripts/chk_disk_status.sh /usr/local/zabbix/scripts/ cd /usr/local/zabbix/scripts/ chmod a+x chk_disk_status.sh vim .. /etc/zabbix_agentd.confCopy the code

killall zabbix_agentd
service zabbix-agent start
Copy the code

Added a monitoring template.

Enter the template name and host group.

Click the newly created monitoring template.

Go to Items -> Create Item.

Configure Name and Key.

Configure all monitoring items based on the preceding picture. Dist. Status [1,1,1,2] 1= disks,1 = disks,1 = disks,2 = monitoring items.

Create a chart.

Enter a chart name, select all monitoring items, and finish.

Select a monitor host, click Template, Link new Template and select the newly created Template.

Key script code

The following is the shell script code needed to complete the monitoring work in the process of the above operation, posted below, together with the reference, if you need my directory structure full package file, you can private letter myself, see the letter, will be private letter sharing.

nginx

#! /bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # description: NGINX is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /etc/nginx/nginx.conf # config: /etc/sysconfig/nginx # pidfile: /var/run/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/local/nginx/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() { # make required directories user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -` if [ -z "`grep $user /etc/passwd`" ]; then useradd -M -s /bin/nologin $user fi options=`$nginx -V 2>&1 | grep 'configure arguments:'` for opt in $options; do if [ `echo $opt | grep '.*-temp-path'` ]; then value=`echo $opt | cut -d "=" -f 2` if [ ! -d "$value" ]; then # echo "creating" $value mkdir -p $value && chown -R $user $value fi fi done } start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 make_dirs echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop sleep 1 start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esacCopy the code

template nginx.xml

In addition, the content is too much, the text system character limit, temporarily do not post the code.

zabbix-agent

#! /bin/sh # # chkconfig: - 86 14 # description: Zabbix agent daemon # processname: zabbix_agentd # config: /etc/zabbix/zabbix_agentd.conf # ### BEGIN INIT INFO # Provides: zabbix-agent # Required-Start: $local_fs $network # Required-Stop: $local_fs $network # Should-Start: zabbix zabbix-proxy # Should-Stop: zabbix zabbix-proxy # Default-Start: # Default-Stop: 0 1 2 3 4 5 6 # Short-Description: Start and stop Zabbix agent # Description: Zabbix agent ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions if [ -x /usr/local/zabbix/sbin/zabbix_agentd ]; then exec=/usr/local/zabbix/sbin/zabbix_agentd else exit 5 fi prog=${exec##*/} conf=/usr/local/zabbix/etc/zabbix_agentd.conf pidfile=$(grep -e "^PidFile=.*$" $conf | cut -d= -f2 | tr -d '\r') timeout=10 if [ -f /etc/sysconfig/zabbix-agent ]; then . /etc/sysconfig/zabbix-agent fi lockfile=/var/lock/subsys/zabbix-agent start() { echo -n $"Starting Zabbix agent: " daemon $exec -c $conf rv=$? echo [ $rv -eq 0 ] && touch $lockfile return $rv } stop() { echo -n $"Shutting down Zabbix agent: " killproc -p $pidfile -d $timeout $prog rv=$? echo [ $rv -eq 0 ] && rm -f $lockfile return $rv } restart() { stop start } case "$1" in start|stop|restart) $1 ;; force-reload) restart ;; status) status -p $pidfile $prog ;; try-restart|condrestart) if status $prog >/dev/null ; then restart fi ;; reload) action $"Service ${0##*/} does not support the reload action: " /bin/false exit 3 ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" exit 2 ;; esacCopy the code

zabbix-server

#! /bin/sh # # chkconfig: - 85 15 # description: Zabbix server daemon # config: /etc/zabbix/zabbix_server.conf # ### BEGIN INIT INFO # Provides: zabbix # Required-Start: $local_fs $network # Required-Stop: $local_fs $network # Default-Start: # Default-Stop: 0 1 2 3 4 5 6 # Short-Description: Start and stop Zabbix server # Description: Zabbix server ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions if [ -x /usr/local/zabbix/sbin/zabbix_server ]; then exec=/usr/local/zabbix/sbin/zabbix_server else exit 5 fi prog=${exec##*/} conf=/usr/local/zabbix/etc/zabbix_server.conf pidfile=$(grep -e "^PidFile=.*$" $conf | cut -d= -f2 | tr -d '\r') timeout=10 if [ -f /etc/sysconfig/zabbix-server ]; then . /etc/sysconfig/zabbix-server fi lockfile=/var/lock/subsys/zabbix-server start() { echo -n $"Starting Zabbix server: " daemon $exec -c $conf rv=$? echo [ $rv -eq 0 ] && touch $lockfile return $rv } stop() { echo -n $"Shutting down Zabbix server: " killproc -p $pidfile -d $timeout $prog rv=$? echo [ $rv -eq 0 ] && rm -f $lockfile return $rv } restart() { stop start } case "$1" in start|stop|restart) $1 ;; force-reload) restart ;; status) status -p $pidfile $prog ;; try-restart|condrestart) if status $prog >/dev/null ; then restart fi ;; reload) action $"Service ${0##*/} does not support the reload action: " /bin/false exit 3 ;; *) echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" exit 2 ;; esacCopy the code

chk_nginx.sh

#! /bin/bash # date : 2018-05-04 # Description: Zabbix monitors nginx performance and process status. This script needs to be configured on the monitored side, Otherwise the ping test will be does not conform to the expected result HOST = "192.168.77.1" PORT = "80" # detection nginx process whether there is the function ping {/ sbin/pidof nginx | wc - l} # Nginx performance function active {/ usr/bin/curl "http://$HOST:$PORT/status" > 2 / dev/null | grep 'active' | awk '{print $NF}} function reading { /usr/bin/curl "http://$HOST:$PORT/status" 2>/dev/null| grep 'Reading' | awk '{print $2}' } function writing { /usr/bin/curl "http://$HOST:$PORT/status" 2>/dev/null| grep 'Writing' | awk '{print $4}' } function waiting { /usr/bin/curl "http://$HOST:$PORT/status" 2>/dev/null| grep 'Waiting' | awk '{print $6}' } function accepts { /usr/bin/curl "http://$HOST:$PORT/status" 2>/dev/null| awk NR==3 | awk '{print $1}' } function handled { /usr/bin/curl "http://$HOST:$PORT/status" 2>/dev/null| awk NR==3 | awk '{print $2}' } function requests { /usr/bin/curl "Http://$HOST:$PORT/status" > 2 / dev/null | awk NR = = 3 | awk '{print $3}} $1 # executive functionCopy the code

chk_mysql.sh

#! /bin/bash # MYSQL_USER='zabbix' # password MYSQL_PWD='zabbix' # host address /IP MYSQL_HOST='192.168.77.1' # port #MYSQL_CONN="/usr/bin/mysqladmin -u${MYSQL_USER} -p${MYSQL_PWD} -h${MYSQL_HOST} -p ${MYSQL_PORT}" MYSQL_CONN="/usr/bin/mysqladmin" then echo "arg error!" Fi # to get data case $1 in Uptime) result = ${MYSQL_CONN} ` status | the cut - f2 - d ":" | the cut - f1 - d "T" ` echo $result;; Com_update) result=`${MYSQL_CONN} extended-status |grep -w "Com_update"|cut -d"|" -f3` echo $result ;; Slow_queries) result=`${MYSQL_CONN} status |cut -f5 -d":"|cut -f1 -d"O"` echo $result ;; Com_select) result=`${MYSQL_CONN} extended-status |grep -w "Com_select"|cut -d"|" -f3` echo $result ;; Com_rollback) result=`${MYSQL_CONN} extended-status |grep -w "Com_rollback"|cut -d"|" -f3` echo $result ;; Questions) result=`${MYSQL_CONN} status|cut -f4 -d":"|cut -f1 -d"S"` echo $result ;; Com_insert) result=`${MYSQL_CONN} extended-status |grep -w "Com_insert"|cut -d"|" -f3` echo $result ;; Com_delete) result=`${MYSQL_CONN} extended-status |grep -w "Com_delete"|cut -d"|" -f3` echo $result ;; Com_commit) result=`${MYSQL_CONN} extended-status |grep -w "Com_commit"|cut -d"|" -f3` echo $result ;; Bytes_sent) result=`${MYSQL_CONN} extended-status |grep -w "Bytes_sent" |cut -d"|" -f3` echo $result ;; Bytes_received) result=`${MYSQL_CONN} extended-status |grep -w "Bytes_received" |cut -d"|" -f3` echo $result ;; Com_begin) result=`${MYSQL_CONN} extended-status |grep -w "Com_begin"|cut -d"|" -f3` echo $result ;; *) echo "Usage:$0(Uptime|Com_update|Slow_queries|Com_select|Com_rollback|Questions|Com_insert|Com_delete|Com_commit|Bytes_sent|B ytes_received|Com_begin)" ;; esacCopy the code

chk_disk_status.sh

#! /bin/bash Device=$1 function rrqm { /usr/local/bin/iostat -dxkt 1 2|grep "\b$Device\b"|tail -1|awk '{print $2}' } function wrqm { /usr/local/bin/iostat -dxkt 1 2|grep "\b$Device\b"|tail -1|awk '{print $3}' } function rps { /usr/local/bin/iostat -dxkt 1 2|grep "\b$Device\b"|tail -1|awk '{print $4}' } function wps { /usr/local/bin/iostat -dxkt  1 2|grep "\b$Device\b" |tail -1|awk '{print $5}' } function rKBps { /usr/local/bin/iostat -dxkt 1 2|grep "\b$Device\b" |tail -1|awk '{print $6}' } function wKBps { /usr/local/bin/iostat -dxkt 1 2|grep "\b$Device\b" |tail -1|awk '{print $7}' } function avgrq_sz { /usr/local/bin/iostat -dxkt 1 2|grep "\b$Device\b" |tail -1|awk '{print $8}' } function await  { /usr/local/bin/iostat -dxkt 1 2|grep "\b$Device\b" |tail -1|awk '{print $10}' } function svctm { /usr/local/bin/iostat -dxkt 1 2|grep "\b$Device\b" |tail -1|awk '{print $11}' } function util { /usr/local/bin/iostat -dxkt |grep "\b$Device\b" |tail -1|awk '{print $12}' } $2Copy the code