#!/mod/bin/jimsh
source /mod/webif/lib/setup
require system.class
package require json

httpheader {application/json}

catch {
	set ds [system diskstats]
	lappend vars \
		bootreason [system lastbootreason] \
		busy [system busy] \
		connectivity [system connectivity] \
		diskfree [system diskfree] \
		diskhours $ds(hours) \
		diskpending $ds(pending) \
		diskreallocated $ds(realloc) \
		disktemp $ds(temp) \
		diskuncorrectable $ds(uncorr) \
		dlnastatus [system dlnastatus] \
		encryptionkey [system encryptionkey] \
		fhtcpversion [system fhtcpversion] \
		hostname [::js::escape [system hostname]] \
		idletime [system idletime] \
		instandby [system instandby] \
		kernelver [system kernelver] \
		loaderver [system loaderver] \
		macaddr [system macaddr] \
		modbuild [system modbuild] \
		model [system model] \
		modversion [system modversion] \
		nuggeted [system nuggeted] \
		pkgver [system pkgver] \
		restartpending [system isrestartpending] \
		serialno [regsub -all -- {[[:space:]]+} [system serialno] ""] \
		systemid [system systemid] \
		tuners [system tuners] \
		uptime [system uptime]

	puts [json::encode $vars obj]
}
