in
/usr/local/opnsense/service/conf/actions.d/
i added
more actions_pingtest.conf
and the script
[start]
command:/etc/pingtest.sh
parameters:
type:script
description:run custom script
message:run script
and the pingtest script
#!/bin/sh
#=====================================================================
# pingtest.sh, v1.0.1
# Created 2009 by Bennett Lee
# Released to public domain
#*/30 * * * * #
# (1) Attempts to ping several hosts to test connectivity. After
# first successful ping, script exits.
# (2) If all pings fail, resets interface and retries all pings.
# (3) If all pings fail again after reset, then reboots pfSense.
#
# History
# 1.0.1 Added delay to ensure interface resets (thx ktims).
# 1.0.0 Initial release.
#=====================================================================
#=====================================================================
# USER SETTINGS
#
# Set multiple ping targets separated by space. Include numeric IPs
# (e.g., remote office, ISP gateway, etc.) for DNS issues which
# reboot will not correct.
ALLDEST="ping.sunet.se idg.se"
#ALLDEST="irc.com"
# Interface to reset, usually your WAN
BOUNCE=igb3
# Log file
LOGFILE=/tmp/pingtest.log
#=====================================================================
COUNT=1
while [ $COUNT -le 2 ]
do
for DEST in $ALLDEST
do
#echo `date +%Y%m%d.%H%M%S` "Pinging $DEST" >> $LOGFILE
ping -c1 $DEST >/dev/null 2>/dev/null
if [ $? -eq 0 ]
then
echo `date +%Y%m%d.%H%M%S` "Ping $DEST OK." >> $LOGFILE
exit 0
fi
done
if [ $COUNT -le 1 ]
then
echo `date +%Y%m%d.%H%M%S` "All pings failed. Resetting interface $BOUNCE." >> $LOGFILE
/sbin/ifconfig $BOUNCE down
# Give interface time to reset before bringing back up
sleep 20
/sbin/ifconfig $BOUNCE up
# Give WAN time to establish connection
sleep 20
else
echo `date +%Y%m%d.%H%M%S` "All pings failed twice. Rebooting..." >> $LOGFILE
# /sbin/shutdown -r now >> $LOGFILE
exit 1
fi
COUNT=`expr $COUNT + 1`
done
it runs if i do
configctl pingtest start
any ideas why it doesent run on the 5min schedule
/s
start with "*/5" (every 5 minutes) instead of "5" (5 past every whole hour)
if you look at the atached screenshot, should that really be that syntax
get the cron running from with crontab -e is no problem
but in order to get it persistand i was looking for this solution
/s
good question. The other field really look "crontab-like" so if the crontab listing is correct it should be another issue.
I now see "custom script" is not a default option. So you are "hacking" the system. This will possible break with a opnsense update. It is an appliance.
Quote from: EdwinKM on December 14, 2022, 12:49:26 PM
I now see "custom script" is not a default option. So you are "hacking" the system. This will possible break with a opnsense update. It is an appliance.
well, read up on that will ya
"hacking"..was that the scariest word you could come up with?
Quote from: sp33dy on December 14, 2022, 01:59:47 PM
Quote from: EdwinKM on December 14, 2022, 12:49:26 PM
I now see "custom script" is not a default option. So you are "hacking" the system. This will possible break with a opnsense update. It is an appliance.
well, read up on that will ya
"hacking"..was that the scariest word you could come up with?
Do you want people to actually try to help you or do you want to make snarky remarks....I spend my free time to give pointers. Maybe it is incorrect. Figure it out yourself if you know it all.
Quote from: sp33dy on December 14, 2022, 12:39:27 PM
if you look at the atached screenshot, should that really be that syntax
Of course. "Minutes: 5" means "every minute numbered '5' after each full hour". if you want every five minutes, "*/5" is what you need to put in there.
You can even specify "1/5", "2/5", etc. to specify it should run at minutes 1, 6, 11, 16, ... or 2, 7, 12, 17 ... respectively.