Hi,
I'm running a multiwan setup and sometimes on a reboot the dpinger service is not started. This is obviously a pretty big problem, because the gateway is then not enabled.
1) Is there a way to see why this happened?
2) Should a service like this be monitored and started if it failed?
Dpinger does not enable the gateway, it merely monitors it. There is an option within the single gateway settings 'Disable Gateway Monitoring'. If that us ticked dpinger will not start on that gateway.
yes, but I have "Allow default gateway switching" enabled, so it needs to know if it's a usable gateway.
You should be able to look at the gateway log files to see what's happening,
There is a way to monitor dpinger and restart it, but it's not a default function, it's something you need to add to Monit. Here's how I do mine, maybe not the best or only way, but it's never let me down. I only monitor my v6 dpinger as that is the only one that occasionally fails when something happens ISP wise.
Go to Services->Monit and click on the 'Service Test Settings' tab. Add a new Service test, give it a name, such as 'Dpinger not Running Restart', set the Condition to 'does not exist' and the action to 'Execute'. Put this in the Path box '/usr/local/etc/rc.d/dpinger_starter', Save that and that's the first part done.
Now click on the 'Service Settings' tab and add a new entry. Give the new entry a name, mine is 'dpinger_WAN_V6_Dpinger_Restart', set the Type to 'Process'. Now you need to find the pid file you want to monitor, look in /var/run/ you'll see them, they will be named dpinger_*_ pid, copy the filename and enter the path an file name into the PID File box, e.g. mine is '/var/run/dpinger_WAN_V6_Monitor.pid'. Now select from the 'Tests' dropdown the test you created first, thats it, click on save.
All that's needed now is to copy the attached file to the /usr/local/etc/rc.d/ directory and make it executable, set the permissions to 755.
Works for me, not sure it will work for you as I suspect there's more afoot than just dpinger not starting.
@marjohn56 Thanks for your detailed reply, I'm gonna try this script when it happens again and see it that fixes it. Normally I'm a bit hesitant with placing scripts on the router, because after an update it's gone.
Best regards, Maarten
Then you need one of my other scripts which uses rsync to back up my scripts and other specific files to my QNAP. :)
Almost eight weeks later I had a pppoe down event which usually results in dpinger failing to restart. There's an issue with my script, it could be that it's because of an update and somethings moved, but it's easy to fix, just add this extra require in the script with the others.
require_once '/usr/local/etc/inc/system.inc';
Is there a reason "Disable Gateway Monitoring" is disabled by default? In my particular case I'm refering to a single WAN network. Also did Maarten find a bug with dpinger not restarting after a reboot?
Quote from: packet loss on October 15, 2020, 08:05:26 PM
Is there a reason "Disable Gateway Monitoring" is disabled by default? In my particular case I'm refering to a single WAN network. Also did Maarten find a bug with dpinger not restarting after a reboot?
Because 90% only use single WAN where it's not relevant?
Dpinger, on occasion, will not restart after a PPPoE loss, usually the ISP side. I run a Monit task which watches dpinger and will restart it if it's not running, it doesn't really matter what the cause is, the script and monit will restart it, that's what I was referring to. It was to help the OP with the original issue he posted.
Quote from: marjohn56 on October 16, 2020, 10:02:39 AM
Dpinger, on occasion, will not restart after a PPPoE loss, usually the ISP side. I run a Monit task which watches dpinger and will restart it if it's not running, it doesn't really matter what the cause is, the script and monit will restart it, that's what I was referring to. It was to help the OP with the original issue he posted.
Can you post screenshots? I'd like to add this to the examples .. (or you can add them yourself)
I can, but I have a vague memory of @Franco telling me there was an easier way than using a script.. whatever, I can't remember and this works so I stick with it.
What is it you want, images of the Monit setup etc?
Yes ... so I can just add a 4th example. monit is so powerful but noone knows how to work with it. It needs practical examples.
@mimugmail
Here you, go, note it monitors the wan v6 dpinger pid, but the script restarts all dpinger instances.
Thx for the script and the parameter description.
dpinger got started after reboot, but unfortunately I have a message in my mailbox now every 20 minutes
DPinger_WAN_V6_Gateway_Restart at XXX.YYYYYYY.net failed (replaced real values with X and Y)
How can I avoid this? dpinger is alive all the time
Regrads
Torsten
Did you change the dpinger*.pid file that's monitored to match that of your system?
Sorry I missed that... adjusted it to "/var/run/dpinger_WAN_DHCP6.pid"
For completeness, with @franco's input, I have implemented @marjohn56's solution except that, instead of his script, my Execute command in the Service Test Settings is:
/bin/sh -c '/usr/local/sbin/pluginctl -s dpinger restart WAN_DHCP6'
"WAN_DHCP6" is the name of my IPv6 gateway (as shown under System>Gateways>Single), which is the gateway on which dpinger can sometimes fail to restart when the gateway goes down and comes up again. It is the PID for this gateway that monit is monitoring.
This directly restarts dpinger on the named gateway. Seems to work well, based on brief testing.
Update:
For whatever reason, a reboot just now resulted in the monit process not restarting dpinger on the IPv6 gateway.
So I made some tweaks to the monit config that seem to work more reliably.
First I changed the Service Tests Settings config so that the Action was not Execute, but just Restart.
Then in the Service Settings config, I added Start and Stop commands based on the previous Execute command.
Start:
/bin/sh -c '/usr/local/sbin/pluginctl -s dpinger start WAN_DHCP6'
Stop:
/bin/sh -c '/usr/local/sbin/pluginctl -s dpinger stop WAN_DHCP6'
My understanding is that these configs mean that when monit detects that the IPv6 dpinger process is not running, it will trigger a restart, meaning first a stop and then a start. In theory the previous setup should have had the same result, but for whatever reason it did not seem to after a reboot.
Edit: Because a picture is worth a thousand words, I have added screenshots. The Start and Stop commands in the Service Settings are cut off, see above for full contents.