What i did was:
Create a directory called /opt/dhcpactive
Put the dhcpactiv.sh script in there:
#!/bin/sh
#
# dhcpactiv.sh
#
# v.004
# - rewritten again to pull data from dhcpd files according to labels instead of position
#
# v.003
# - add code to remove tstp information from dpcpd.leases
#
# v.002
# - rewritten to use awk more for parsing
# - added "GMT" indicator to Expiration col head
#
date
echo "Source Host MAC Address IP Address Expiration (GMT)"
echo "============= ========================= ====================== =============== ================"
#
awk ' { out = ""} \
{ $1=="lease"||$1=="client-hostname" ? out=" " $2 : out=out } \
{ $1=="binding"||$1=="hardware" ? out= " " $3: out=out } \
{ $1=="ends"? out=" " $3 " " $4: out=out } \
{ $1=="}"? out="\n": out=out } \
{ printf out," " }' /var/lib/dhcp/dhcpd.leases \
| grep active \
| sed -e s/'[{};" ]'/\ /g \
| awk '{ printf "%-13s %-25s %-22s %-15s %-10s %-5s\n", "dhcpd.leases", $6, $5, $1, $2, $3 }'
#
# Now do the same for /etc/dhcpd.conf~
#
awk ' { out = ""}
{ $1=="host"||$1=="fixed-address" ? out=" " $2 : out=out } \
{ $1=="hardware" ? out= " " $3: out=out } \
{ $1=="}"? out="\n": out=out } \
{ printf out," " }' /etc/dhcpd.conf \
| grep : \
| sed -e s/'[{};\" ]'/\ /g -e s/\.`config get DomainName`// \
| awk '{ printf "%-13s %-25s %-22s %-15s %-15s \n", "dhcpd.conf", $1, $2, $3, "reservation"}'
#
# Finally, grab the current arp table
#
arp -a \
| sed -e s/\\..*\(/\ / -e s/\)// \
| awk '{ printf "%-13s %-25s %-22s %-15s %-15s \n", "arp", $1, $4, $2, "n/a"}'
Note I changed the script ever so slightly to include the current date/time in the output as well as making the columns for the output just a little bit wider so it was easier to read.
Then created another script called dhcplog:
#!/bin/sh
#
# Creats a log file from the dhcpactiv.sh script
./dhcpactiv.sh > ./dhcpleases.now
Which simply writes the output to a file in the /opt/dhcpactive directory.
Then, I created a symbolic link from /opt/dhcpactive/dhcpleases.now to /var/log
ln -s /opt/dhcpactive/dhcpleases.now /var/log/dhcpleases.now
Finally, I used Stephen Nobels dungog-cron contrib.
http://www.dungog.net/wiki/Dungog-cron to create a cron job that runs every 5 mins to update the /opt/dhcpactive/dhcpleases.now file. I can now take a look at it in the server-manager Administration -> View log files panel.
-Rick