Tips & Triks

не ломается у того, кто ничего не делает...

Zabbix

Конфиг и скрипты для zabbix

/etc/zabbix/zabbix_agentd.conf

UserParameter=mysql.ping,mysqladmin -uroot ping|grep alive|wc -l
UserParameter=mysql.uptime,mysqladmin -uroot status|cut -f2 -d":"|cut -f1 -d"T"
UserParameter=mysql.threads,mysqladmin -uroot status|cut -f3 -d":"|cut -f1 -d"Q"
UserParameter=mysql.questions,mysqladmin -uroot status|cut -f4 -d":"|cut -f1 -d"S"
UserParameter=mysql.slowqueries,mysqladmin -uroot status|cut -f5 -d":"|cut -f1 -d"O"
UserParameter=mysql.qps,mysqladmin -uroot status|cut -f9 -d":"
UserParameter=mysql.version,mysql -V
UserParameter=mysql.param[*],/etc/zabbix/mysql_status.sh $1
UserParameter=mysql.repl[*],/etc/zabbix/mysql_repl.sh $1



mysql_status.sh

#!/bin/bash

STATUS_FILE="/tmp/mysql_status"
LOCK_FILE="/tmp/mysql_status_updating"

[ -f $STATUS_FILE ] || touch $STATUS_FILE


CUR_TIME=`date +%s`
MOD_TIME=`stat -c %Y $STATUS_FILE`
DELTA=$[$CUR_TIME-$MOD_TIME]


if [ $DELTA -ge 3 ] && [ ! -f $LOCK_FILE ];
then
#       echo -----updating------
        touch $LOCK_FILE
        /usr/bin/mysqladmin -u root ext >$STATUS_FILE
        rm $LOCK_FILE 2>/dev/null
#       echo -----updated------
fi

grep " $1 " $STATUS_FILE |awk '{print $4}'


mysql_repl.sh

 #!/bin/sh
case $1 in
        [iI][oO])
                mysql -uroot -Be 'show slave status\G' | grep 'Slave_IO_Running' | cut -f2 -d: | tr -d '[:space:]'
        ;;
        [sS][qQ][lL])
                mysql -uroot -Be 'show slave status\G' | grep 'Slave_SQL_Running' | cut -f2 -d: | tr -d '[:space:]'
        ;;
        [lL][aA][gG])
                mysql -uroot -Be 'show slave status\G' | grep 'Seconds_Behind_Master' | cut -f2 -d: | tr -d '[:space:]'
        ;;
        *)
                usage: $0 io|repl
        ;;
esac


zabbix_export_config.xml

Создание LVM больше 2 ТБСвои deb-пакеты

Write a comment

New comments have been disabled for this post.

June 2012
M T W T F S S
May 2012July 2012
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30