#!/bin/bash

if [[ `ls /proc/1/fd | wc -l` -eq 3  ]]; then
    ip_addr=`ip addr show dev eth1 | grep 'inet ' | awk '{print $2}'`
    mac=`ip addr show dev eth1 | grep 'link/ether ' | awk '{print $2}'`
    msg="{\"ip_addr\": \"$ip_addr\", \"mac\": \"$mac\", \"time\": `date '+%s'`}"
    curl -m 10 -X POST http://dfarvrsm01.dfa.local/api/HttpSystemDFault -H "Content-Type: application/json" -d "$msg"
    sleep 1
    reboot -f
fi
