?Notifications for a network node rebooting

?Notifications for a network node rebooting

This is a simple mechanism to notify a person of a system reboot. This will work on most Linux systems including SDWAN nodes. In the latter case, the cause is often a power outage.

Install Pushbullet on your phone and PC after registering for an account. Create an access token in the settings section.

On the Linux node create a bash script in /usr/local/sbin.

rebootubl.sh:
#!/bin/bash
/sbin/iptables -I INPUT 1 -s 154.0.0.1 -j ACCEPT -m comment --comment "netman"
/sbin/iptables -I INPUT 1 -p udp -m udp -s 102.102.102.248/29 --dport 161 -j ACCEPT -m comment --comment "netman"
actual='who -b'
/usr/bin/curl --silent -u """x.token"":" -d type="note" -d body="Reboot detected @ $actual" -d title="Reboot: Splashy Fen - FBSA" 'https://api.pushbullet.com/v2/pushes'

where x.token is the Pushbellet access token. The other commands whitelist management plane systems.

All that remains now is to execute the script and boot time. Use sudo crontab -e

#
# m h  dom mon dow   command
@reboot sleep 180 && /usr/local/sbin/rebootubl.sh

The 180 seconds delay is to ensure all WAN links startup successfully.

No alt text provided for this image


要查看或添加评论,请登录

Ronald Bartels的更多文章

社区洞察

其他会员也浏览了