Ad Widget

Collapse

Restarting a service from a Linux system to a remote Linux system

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pmurtey
    Member
    • Mar 2020
    • 91

    #1

    Restarting a service from a Linux system to a remote Linux system

    Hi All,
    Is it possible to set a trigger command so that if an alert occurs on server 1 in a log monitor alert, it will issue a restart command of the same service on two remote servers, Server 2 and Server3?
  • guille.rodriguez
    Senior Member
    • Jun 2022
    • 114

    #2
    Maybe with SSH script (set as parameter host and service)


    restart_service.sh 192.168.100.25 zabbix-agent2

    That action can execute

    Code:
    #!/bin/bash
    server=$1
    service=$2
    ssh root@$server "systemctl restart $service"​
    You need to set before RSA public key of Zabbix Server on remote machines, from zabbix

    Code:
    ssh-copy-id root@server1
    In Zabbix Server config there is a parameter to set the location of the RSA key
    Last edited by guille.rodriguez; 27-10-2022, 18:12.

    Comment

    Working...