Exec binding help

Hi,

I am trying to use the exec binding to restart an ipsec connection if I detect a remote host to be down.

I have tried the following:
Switch ipsecRestart "Ipsec restart if ipcam NOK" {nh="ipcamIPAddress:80", exec=">[OFF:ssh root@routerIPAddress ipsec restart]"}

this will indeed restart ipsec if I manually switch off the switch but not when the host (ipcam) goes offline. The network health binding is working fine too.

I have no advice for getting it to work in the one Switch. But a simple rule would work. I do similar stuff in my setup with the Network Health but I separate the nh and exec into separate switches and trigger the exec in a rule.

Thanks @rlkoshak, yes a rule should be no problem, it’s just that I saw an example in the wiki and got the idea it would be possible in a one-liner item.

Is it that you are trying to invoke ssh, but you either need proper permissions on .ssh and its contents, or it’s prompting you for a password?

If I switch off the ipsecRestart switch manually, the service is restarted, so ssh is working.

Reading the wiki I understood that a similar item definition would allow to invoke the exec when network health detects a problem.

It very well be possible. I’ve never really tried to make it work. I like to keep such things separate and join them up with a rule. It gives me more flexibility in the long run.