diff options
author | Mika Havela <mika.havela@gmail.com> | 2007-12-22 09:18:24 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2007-12-22 09:18:24 +0000 |
commit | d93688f0d12c5c7c9f35d4746eef58bac11a144a (patch) | |
tree | a6e5b82eb5694d9c82599808b13e61242ecb0660 | |
parent | 4062108ee8796ab9f64f05d55cd48352399cd34c (diff) | |
download | acf-alpine-baselayout-d93688f0d12c5c7c9f35d4746eef58bac11a144a.tar.bz2 acf-alpine-baselayout-d93688f0d12c5c7c9f35d4746eef58bac11a144a.tar.xz |
Display general healt on the system
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@447 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | health-controller.lua | 36 | ||||
-rw-r--r-- | health-model.lua | 62 | ||||
-rw-r--r-- | health-modules-html.lsp | 8 | ||||
-rw-r--r-- | health-network-html.lsp | 11 | ||||
-rw-r--r-- | health-proc-html.lsp | 11 | ||||
-rw-r--r-- | health-storage-html.lsp | 14 | ||||
-rw-r--r-- | health-system-html.lsp | 17 | ||||
-rw-r--r-- | health.menu | 2 |
8 files changed, 161 insertions, 0 deletions
diff --git a/health-controller.lua b/health-controller.lua new file mode 100644 index 0000000..2ce32d4 --- /dev/null +++ b/health-controller.lua @@ -0,0 +1,36 @@ +module (..., package.seeall) + +local list_redir = function (self) + self.conf.action = "system" + self.conf.type = "redir" + error (self.conf) +end + +mvc={} +mvc.on_load = function(self, parent) + if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then + self.worker[self.conf.action] = list_redir(self) + end +end + +-- Public methods + +system = function (self ) + return ({system = self.model:get_system(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) +end + +storage = function (self ) + return ({storage = self.model:get_storage(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) +end + +network = function (self ) + return ({network = self.model:get_network(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) +end + +modules = function (self ) + return ({modules = self.model:get_modules(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) +end + +proc = function (self ) + return ({proc = self.model:get_proc(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller} ) +end diff --git a/health-model.lua b/health-model.lua new file mode 100644 index 0000000..e0e2cf3 --- /dev/null +++ b/health-model.lua @@ -0,0 +1,62 @@ +-- acf model for displaying logfiles recusivly +module (..., package.seeall) + +require("fs") +require("date") + +-- ############################################################### +-- Private functions +local function querycmd ( cmdline ) + local cmd = io.popen( cmdline ) + local cmd_result = cmd:read("*a") or "unknown" + cmd:close() + return cmd_result +end + +local function diskfree ( media ) + if not (media) then media = "" end + local cmd = io.popen( "df -h " .. media ) + local cmd_result = cmd:read("*a") or "unknown" + cmd:close() + return cmd_result +end + +-- ############################################################### +-- Public functions +get_system = function (self) + local system = {} + system.uptime = querycmd("/usr/bin/uptime") + system.date = querycmd("/bin/date") + system.timezone = date.what_tz() + system.uname = querycmd("/bin/uname -a") + system.memory = querycmd("/usr/bin/free") + return system +end + +get_storage = function (self) + local storage = {} + storage.floppycapacity = diskfree("/media/floppy") + storage.hdcapacity = diskfree() + storage.partitions = fs.read_file("/proc/partitions") + return storage +end + +get_network = function (self) + local network = {} + network.interfaces = querycmd("/sbin/ifconfig") + network.routes = querycmd("/sbin/route") + return network +end + +get_modules = function (self) + local modules = {} + modules.list = querycmd("/sbin/lsmod") + return modules +end + +get_proc = function (self) + local proc = {} + proc.processor = fs.read_file("/proc/cpuinfo") + proc.memory = fs.read_file("/proc/meminfo") + return proc +end diff --git a/health-modules-html.lsp b/health-modules-html.lsp new file mode 100644 index 0000000..eef9655 --- /dev/null +++ b/health-modules-html.lsp @@ -0,0 +1,8 @@ +<? local view = ... ?> + +<h1>General health</h1> + +<h2>Modules</h2> + +<h3>Installed modules</h3> +<pre><?= view.modules.list ?></pre> diff --git a/health-network-html.lsp b/health-network-html.lsp new file mode 100644 index 0000000..f04faaf --- /dev/null +++ b/health-network-html.lsp @@ -0,0 +1,11 @@ +<? local view = ... ?> + +<h1>General health</h1> + +<h2>Network</h2> + +<h3>Interface status</h3> +<pre><?= view.network.interfaces ?></pre> + +<h3>Routes</h3> +<pre><?= view.network.routes ?></pre> diff --git a/health-proc-html.lsp b/health-proc-html.lsp new file mode 100644 index 0000000..3387688 --- /dev/null +++ b/health-proc-html.lsp @@ -0,0 +1,11 @@ +<? local view = ... ?> + +<h1>General health</h1> + +<h2>Process information</h2> + +<h3>Processor</h3> +<pre><?= view.proc.processor ?></pre> + +<h3>Memory</h3> +<pre><?= view.proc.memory ?></pre> diff --git a/health-storage-html.lsp b/health-storage-html.lsp new file mode 100644 index 0000000..ed20c64 --- /dev/null +++ b/health-storage-html.lsp @@ -0,0 +1,14 @@ +<? local view = ... ?> + +<h1>General health</h1> + +<h2>Storage</h2> + +<h3>Floppy capacity</h3> +<pre><?= view.storage.floppycapacity ?></pre> + +<h3>HD capacity</h3> +<pre><?= view.storage.hdcapacity ?></pre> + +<h3>HD Partitions</h3> +<pre><?= view.storage.partitions ?></pre> diff --git a/health-system-html.lsp b/health-system-html.lsp new file mode 100644 index 0000000..6bb0887 --- /dev/null +++ b/health-system-html.lsp @@ -0,0 +1,17 @@ +<? local view = ... ?> + +<h1>General health</h1> + +<h2>System</h2> + +<h3>Uptime</h3> +<pre><?= view.system.uptime ?></pre> + +<h3>Time/TimeZone</h3> +<pre><?= view.system.date ?></pre> +<pre><?= view.system.timezone ?></pre> + +<h3>Name</h3> +<pre><?= view.system.uname ?></pre> +<h3>Memory</h3> +<pre><?= view.system.memory ?></pre> diff --git a/health.menu b/health.menu new file mode 100644 index 0000000..35361c2 --- /dev/null +++ b/health.menu @@ -0,0 +1,2 @@ +#CAT GROUP/DESC TAB ACTION +General 01General_health General_health system |