[SOLVED] Cronjob & Script to sending Heartbeat (by url / IP) to external (for example StatusCake) server
-
Hi, pfSense Gurus!
Could You be so please to suggest me .sh script to making “heartbeat” to external server outside pfSense?
For example, so-called “Push URL “ for StatusCake service:
https://push.statuscake.com/?PK=abc123&TestID=123456&time=0.
Parsing the answer not needed, only checking by ping and sending heartbeat if ping are ok. And write appropriate string with timestamp into syslog (or separate log) file.
Thank You so much!
-
Creating cronjob successfully, but curl cannot working as needed:
from shell CLI
curl ‘https://push.statuscake.com/?PK=123456789&TestID=987654321&time=0’
return ‘success’BUT when the same string put in .sh file
the same command
curl ‘https://push.statuscake.com/?PK=123456789&TestID=987654321&time=0’
lead to error in log
‘curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535’What I am doing wrong?
-
- Need to specify the entire path for curl
/usr/local/bin/curl
- Make sure the .sh file has execute permissions
chmod a+x {filename}
- Include the shebang in the .sh file
#!/bin/sh
-
@elvisimprsntr said in Cronjob & Script to sending Heartbeat (by url / IP) to external StatusCake server:
- Need to specify the entire path for curl
/usr/local/bin/curl
Done.
- Make sure the .sh file has execute permissions
chmod a+x {filename}
Already done.
- Include the shebang in the .sh file
#!/bin/sh
Already done.
But result are the same:
(In initial question I forgot to write that this is arpwatch message)
—-pf.local.lan pf.local.lan - Arpwatch Notification : Cron <root@pf> /usr/local/bin/pingtest_statuscake.sh - X-Cron-Env: <SHELL=/bin/sh> X-Cron-Env: <PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin> X-Cron-Env: <LOGNAME=root> X-Cron-Env: <USER=root> curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
——
-
[SOLVED] need to put URL between “ and #!/bin/sh:
#!/bin/sh curl “https://push.statuscake.com/?PK=123456789&TestID=987654321&time=0”
Thank You all here!
-
Little update for this shell script in case You have MULTIPLE WAN (and need testing each uplink connection):
THIS SCRIPT SENDS HEARTBEAT ON ONE (1) CERTAIN TEST ID.
So, if You need really monitoring all WANS and receiving SEPARATE ALERT on EACH WAN,- You may create several Tests on StatusCake and USING V.2 OF THIS SCRIPT
#!/bin/sh # HEARTBEAT to StatusCake external monitoring and alerting service # Examples and additional information # https://www.statuscake.com/kb/knowledge-base/what-is-push-monitoring/ # Successfully working on pfSense CE 2.7.X # List of network interfaces INTERFACES="igb10 igb11 igb12 igb13" # StatusCake URL URL="https://push.statuscake.com/?PK=123456764226&TestID=7347942&time=0"" # Loop through each interface and send a curl request for INTERFACE in $INTERFACES do echo "Sending request through interface $INTERFACE" /usr/local/bin/curl --interface "$INTERFACE" "$URL" echo "" # Print a newline for better readability done
YOU MAY TEST exactly script from Diagnostic / Command Shell TO ENSURE THAT ALL ARE WORKING as expected!
The result MUST be looks like this:
Sending request through interface igb0 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 7 100 7 0 0 12 0 --:--:-- --:--:-- --:--:-- 12 success Sending request through interface igb1 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 7 100 7 0 0 13 0 --:--:-- --:--:-- --:--:-- 13 success Sending request through interface igb2 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 7 100 7 0 0 13 0 --:--:-- --:--:-- --:--:-- 13 success Sending request through interface igb3 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 7 100 7 0 0 13 0 --:--:-- --:--:-- --:--:-- 13 success
P.S.
1.
After testing on exactly Your setup, You MUST comment both ‘echo’ command to avoid unnecessary output to terminal.
2.
logger’ command not using also: because of a lot of calling (1 time / min, 1 time / 5 min,…) system log would be filled by unnecessary records that not helping You even when You have automatic log aggregator & analyser like Splunk, ELK, Graylog,….