monit e executar script

0

Eu quero monitorar MariaDB com monit tools . meu monit script é:

check process mariadb_pid with pidfile /var/lib/mysql/db1.pid
check program telnet with path "/root/telnet.sh"
   if status eq 99 then exec "/usr/bin/systemctl restart mariadb.service"

e telnet script são:

#!/bin/bash
cat /root/ips | \
while read host port; do
  result=$(bash -c 'exec 3<> /dev/tcp/'$host'/'$port';echo $?' 2>/dev/null)
  echo $result
 if [ "$result" != "0" ]; then
        exit 99
 fi
done
O arquivo

ips é: %código% Agora, é esperado que, se o arquivo mariadb ip1 e ip2 no arquivo ips estiver inativo, execute

192.168.10.10 3306 192.168.10.20 3306

Mas não está funcionando. por favor, olhe o log de monitoramento.

[EST Mar  5 00:34:19] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:34:24] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:34:29] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:34:34] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:34:39] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:34:44] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:34:49] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:34:54] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:34:59] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:35:04] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:35:09] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:35:14] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:35:19] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:35:24] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:35:29] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:35:34] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:35:39] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:35:44] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:35:49] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:35:54] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:00] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:05] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:10] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:15] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:20] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:25] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:30] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:35] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:40] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:45] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:50] error    : 'telnet' status failed (99) -- 1    
[EST Mar  5 00:36:55] error    : 'telnet' status failed (99) -- 1    

também, quando reiniciar o monit, esta linha é executada pela primeira vez.

[EST Mar  5 00:39:05] error    : 'telnet' status failed (99) -- 1                  
[EST Mar  5 00:39:10] error    : 'telnet' status failed (99) -- 1                  
[EST Mar  5 00:39:15] error    : 'telnet' status failed (99) -- 1                  
[EST Mar  5 00:39:20] error    : 'telnet' status failed (99) -- 1                  
[EST Mar  5 00:39:25] error    : 'telnet' status failed (99) -- 1                  
[EST Mar  5 00:39:26] info     : Reinitializing monit daemon                       
[EST Mar  5 00:39:26] info     : Reinitializing Monit -- control file '/etc/monitrc
[EST Mar  5 00:39:26] info     : 'db1' Monit reloaded                              
[EST Mar  5 00:39:31] error    : 'telnet' status failed (99) -- 1                  
[EST Mar  5 00:39:31] info     : 'telnet' exec: '/usr/bin/systemctl restart mariadb.service'                                                                              
[EST Mar  5 00:39:36] error    : 'telnet' status failed (99) -- 1                  
[EST Mar  5 00:39:41] error    : 'telnet' status failed (99) -- 1                  
[EST Mar  5 00:39:46] error    : 'telnet' status failed (99) -- 1                  
[EST Mar  5 00:39:51] error    : 'telnet' status failed (99) -- 1                  
[EST Mar  5 00:39:56] error    : 'telnet' status failed (99) -- 1                  
[EST Mar  5 00:40:01] error    : 'telnet' status failed (99) -- 1  

Alguém tem alguma experiência neste campo?

    
por pyramid13 05.03.2018 / 06:42

0 respostas