I use this script to get alerts from some systems to insure they are still up. It gives me local IP address, hostname and the WAN IP for the network.
#!/bin/sh
IP=”$(ip addr | grep ‘state UP’ -A2 | tail -n1 | awk ‘{print $2}’ | cut -f1 -d’/’)”
IP2=”$(curl ifconfig.co)”
HST=”$(hostname)”
CN=”$(curl ifconfig.co/country)”
CT=”$(curl ifconfig.co/city)”
HST=”$(hostname)”
echo $IP2 > /tmp/$HST
echo $IP >> /tmp/$HST
echo $CN >> /tmp/$HST
echo $CT >> /tmp/$HST
/usr/bin/sendemail -t info\@mydomain.org -f hb\@mydomain.org -u “HB from $HST” -s smtp.server -o message-file=/tmp/$HST;