summaryrefslogtreecommitdiff
path: root/package/webif/files/www/cgi-bin/webif/status-dhcp.sh
blob: 5517b781f4bf7b2e51e9b25a72dcee4d8a22dd06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/webif-page
<? 
. /usr/lib/webif/webif.sh
header "Status" "DHCP" "@TR<<DHCP leases>>"
?>
<table style="width: 90%; text-align: left;" border="0" cellpadding="2" cellspacing="2" align="center">
<tbody>
	<tr>
		<th>@TR<<MAC Address>></th>
		<th>@TR<<IP Address>></th>
		<th>@TR<<Name>></th>
		<th>@TR<<Expires in>></th>
	</tr>
<? [ -e /tmp/dhcp.leases ] && awk -vdate="$(date +%s)" '
$1 > 0 {
	print "<tr>"
	print "<td>" $2 "</td>"
	print "<td>" $3 "</td>"
	print "<td>" $4 "</td>"
	print "<td>"
	t = $1 - date
	h = int(t / 60 / 60)
	if (h > 0) printf h "h "
	m = int(t / 60 % 60)
	if (m > 0) printf m "min "
	s = int(t % 60)
	printf s "sec "
	printf "</td>"
	print "</tr>"
}
' /tmp/dhcp.leases ?>
</tbody>
</table>

<? footer ?>
<!--
##WEBIF:name:Status:150:DHCP
-->