Ad Widget

Collapse

Looking for proper Key(zabbix-UI) for Mysql_Seconds_Behind_Master

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ang3lwich
    Junior Member
    • Dec 2020
    • 7

    #1

    Looking for proper Key(zabbix-UI) for Mysql_Seconds_Behind_Master

    I found this for mysql replication and how far the slave is behind master, works great manually.
    how do i create the key in the zabbix-ui (version 5.0)

    The SEC=$ throws me off
    -P $1 // i just give random port because I am using multi-instance mysql

    UserParameter=mysql.seconds-behind-master,SEC=$(mysql --defaults-file=/etc/zabbix/.multi.cnf -h 127.0.0.1 -P $1 -e 'show slave status\G' | grep Seconds | awk '{print $2}'); if [ "$SEC" = "NULL" ]; then SEC="-1"; fi; echo $SEC

    KeyNow is as follows in the UI:
    mysql.seconds-behind-master[,SEC{#MYSQLPORT}]


    If ran manually with desired port it does as expected from desired host
  • ang3lwich
    Junior Member
    • Dec 2020
    • 7

    #2
    Well, other sysadmin did some trickery, this seems to be better and strips, "Seconds_Behind_Master" and gives value.

    UserParameter=mysql.seconds-behind-master[*],mysql --defaults-file=/etc/zabbix/.multi.cnf -h 127.0.0.1 -P $1 -e 'show slave status\G' | grep Seconds | sed -E s/.+:.\(.+\)/\\1/

    Comment

    Working...