From 40d299e6a33d3b3c4e2121e351ab2180023f16e7 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Wed, 13 Jul 2011 08:32:02 +0000 Subject: [PATCH] replaced lua pages by html pages --- www/Makefile.am | 2 +- www/index.html | 25 ++++++++ www/index.lua | 28 --------- www/monitor.lua | 188 -------------------------------------------------------- www/style.css | 4 +- 5 files changed, 28 insertions(+), 219 deletions(-) create mode 100644 www/index.html delete mode 100644 www/index.lua delete mode 100644 www/monitor.lua diff --git a/www/Makefile.am b/www/Makefile.am index 2c7a3ab..4ad4850 100644 --- a/www/Makefile.am +++ b/www/Makefile.am @@ -1,4 +1,4 @@ defaultwwwdir = $(pkgdatadir)/www -defaultwww_DATA = monitor.lua style.css favicon.ico index.lua monitor.html jquery.js +defaultwww_DATA = index.html style.css favicon.ico index.lua monitor.html jquery.js EXTRA_DIST=$(defaultwww_DATA) diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..b3c235b --- /dev/null +++ b/www/index.html @@ -0,0 +1,25 @@ + + + Psensor Server + + + + + +
+ + +
+

Go to the Monitoring page

+ +
+
+ + + + + diff --git a/www/index.lua b/www/index.lua deleted file mode 100644 index 817535a..0000000 --- a/www/index.lua +++ /dev/null @@ -1,28 +0,0 @@ - -function footer() - return "" -end - -str = "\ -\ - \ - Psensor Web Server\ - \ - \ -\ - \ -\ -

Welcome to the Psensor Web Server!

\ -\ -

Go to the Monitoring Page.

\ -\ -
" - .. footer() - .. "\ -\ -" - -return str \ No newline at end of file diff --git a/www/monitor.lua b/www/monitor.lua deleted file mode 100644 index 57b7a46..0000000 --- a/www/monitor.lua +++ /dev/null @@ -1,188 +0,0 @@ --- --- Convenient functions for HTML output --- - -function td(content) - return "" .. content .. "" -end - -function th(style, content) - if style then - return ""..content.."" - else - return ""..content.."" - end -end - -function tr(style,...) - if style then - ret = "" - else - ret = "" - end - - for i,s in ipairs(arg) do - ret = ret .. s - end - - ret = ret .. "\n" - - return ret -end - -function h2(str) - return "

"..str.."

\n" -end - - --- Formats sensor information to HTML 'tr' -function sensor_to_tr(id,sensor) - return tr(nil, - td(sensor["name"]), - td(sensor["measure_last"]), - td(sensor["measure_min"]), - td(sensor["measure_max"])) -end - - --- Formats number of bytes to string -function format_mem_size(bytes) - if (bytes == 0) then - return "0" - end - - if (bytes < 1024) then - return bytes .. " o"; - end - - mo_bytes = 1024 * 1024; - - if (bytes < mo_bytes) then - return math.ceil(bytes / 1024) .. " Ko" - end - - go_bytes = 1024 * mo_bytes; - - if (bytes < go_bytes) then - return math.ceil(bytes / mo_bytes) .. " Mo" - end - - return math.ceil(bytes / go_bytes) .. " Go" -end - --- Formats uptime to string -function format_uptime(uptime) - uptime_s = sysinfo["uptime"]%60 - uptime_mn = math.floor( (sysinfo["uptime"] / 60) % 60) - uptime_h = math.floor( (sysinfo["uptime"] / (60*60)) % 24) - uptime_d = math.floor(sysinfo["uptime"] / (60*60*24)) - - return uptime_d .. "d " .. - uptime_h .. "h " .. - string.format("%02.d",uptime_mn) .. "mn " .. - string.format("%02d",uptime_s) .. "s" -end - -str = "

Psensor Monitoring Server

" - -if sysinfo then - --- --- Uptime --- - - str = str .. "

Uptime: " .. format_uptime(sysinfo["uptime"]) .. "

" - --- --- CPU --- - - str = str .. h2("CPU") - - str = str .. "" - .. "" .. tr("title", - th(nil,"Current usage"), - th(nil,"Load 1mn"), - th(nil,"Load 5mn"), - th(nil,"Load 15mn")) .. "" - - str = str .. "" - - if sysinfo["load"] then - str = str .. td(math.ceil(100*sysinfo["load"]) .. "%") - else - str = str .. td("N/A") - end - - str = str .. td(string.format("%.2f",sysinfo["load_1mn"])) .. - td(string.format("%.2f",sysinfo["load_5mn"])) .. - td(string.format("%.2f",sysinfo["load_15mn"])) .. - "" .. - "
" - --- --- Memory --- - - totalram = format_mem_size(sysinfo["totalram"] * sysinfo["mem_unit"]) - freeram = format_mem_size(sysinfo["freeram"] * sysinfo["mem_unit"]) - sharedram = format_mem_size(sysinfo["sharedram"] * sysinfo["mem_unit"]) - bufferram = format_mem_size(sysinfo["bufferram"] * sysinfo["mem_unit"]) - usedram = format_mem_size(sysinfo["totalram"] - sysinfo["freeram"]) - - totalswap = format_mem_size(sysinfo["totalswap"] * sysinfo["mem_unit"]) - freeswap = format_mem_size(sysinfo["freeswap"] * sysinfo["mem_unit"]) - usedswap = format_mem_size(sysinfo["totalswap"] - sysinfo["freeswap"]) - - str = str - .. h2("Memory") - - .. "" - - .. tr("title", - th(nil,""), - th(nil,"Total"), - th(nil,"Used"), - th(nil,"Free"), - th(nil,"Shared"), - th(nil,"Buffer")) - - .. tr(nil, - th(nil,"Memory"), - td(totalram), - td(usedram), - td(freeram), - td(sharedram), - td(bufferram)) - - .. tr(nil, - th(nil,"Swap"), - td(totalswap), - td(usedswap), - td(freeswap)) - - .. "
" - -end - --- --- Sensors --- - -if sensors then - - str = str .. "

Sensors

" - .. "" - .. "" - - for i,sensor in ipairs(sensors) do - str = str .. sensor_to_tr(i,sensor) - end - - str = str .. "
NameValueMinMax

psensor-server" - -end - - -return str - diff --git a/www/style.css b/www/style.css index 61c0719..b42f601 100644 --- a/www/style.css +++ b/www/style.css @@ -108,12 +108,12 @@ th, td { padding: 4px 4px 4px 4px; } -a:link, a:visited, a:active { +.page-footer a:link , .page-footer a:visited, .page-footer a:active { text-decoration: none; color: #333333; } -a:hover { +.page-footer a:hover { text-decoration: underline; color: #333333; } -- 2.7.4