#!/bin/bash

IFACE="br-lan"
SERVIP="narodmon.ru"
SERVPO="8283"

DEVID=`ifconfig $IFACE | grep HWaddr | awk '{FS=" "; if(NR==1) {print "#"$5}};'`
DEVMAC=`echo $DEVID | tr -d '#:'`

BRIGID="$DEVMAC"00
TEMPID="$DEVMAC"01
PRESID="$DEVMAC"02
TRINID="$DEVMAC"03
TROUID="$DEVMAC"04

BRIG=`bh1750 | grep -e "Brightness" | awk '{print $3}'`
TEMP=`bmp085 | grep -e "Temperature" | awk '{print $3}'`
PRES=`bmp085 | grep -e "Pressure" | awk '{print $3}'`
TRAFIN=`ifconfig $IFACE | grep bytes | tr ':' ' ' | awk '{print $3}'`
TRAFOU=`ifconfig $IFACE | grep bytes | tr ':' ' ' | awk '{print $8}'`

#clear
echo -e "Brightness $BRIG Lux ; Temperature: $TEMP C ; Pressure: $PRES mmHg ; Traffic: $TRAFIN/$TRAFOU bytes "  | logger -t narodmon
echo -e "$DEVID\n#$BRIGID#$BRIG\n#$TEMPID#$TEMP\n#$PRESID#$PRES\n#$TRINID#$TRAFIN\n#$TROUID#$TRAFOU\n##" | logger -t narodmon
echo -e "$DEVID\n#$BRIGID#$BRIG\n#$TEMPID#$TEMP\n#$PRESID#$PRES\n#$TRINID#$TRAFIN\n#$TROUID#$TRAFOU\n##" | nc $SERVIP $SERVPO | logger -t narodmon


