#!/bin/bash

LIST="/var/www/maclist"

if [ ! -f "$LIST" ]; then 
	echo "Could not find maclist file ($LIST)" 1>&2
	exit 3
fi

while read ip host mac; do
	ping -c 1 $ip >& /dev/null
	if [ $? -eq 0 ]; then
		line=$(/usr/sbin/arp -n | grep $ip | tr [a-z] [A-Z])
		mac=$(echo $mac | tr [a-z] [A-Z])
		echo $line | grep $mac >& /dev/null
		if [ $? -eq 0 ]; then
			echo "$ip#$host#$mac#online"
		else
			echo "$ip#$host#$mac#offline"
		fi
	else
		echo "$ip#$host#$mac#offline"
	fi
done < "$LIST"

