Most often, such data can be organized in a table with rows of information, each column representing a different type of data. For example, in the case of processes running on a system, rows might be sorted according to their unique process identifier, and columns might represent such values as CPU usage, memory usage, owner's name, time of creation, ...
The software used to view this type of information comes in different forms and shapes. Unix users might be familiar with the "top" application which presents rows of process data as lines of text, whereas RMON (Remote MONitoring) SNMP software usually uses multiple windows with graphical displays, curves, pie charts, multiple configuration dialog boxes, even 3D visualization modules to present network traffic, connection matrices, ...
In most cases, data comes from one or several tables. A common interface, graphical with menus, drag'n'drop capability, table widgets and graphical data viewers such as multiple line graphs, bar and pie charts, could be used. The user could then sort table rows, select one or more cells, rows, columns, to launch viewers such as other tables, charts, ... best suited to the way data should be presented. In effect, what is needed is a spreadsheet that is capable of dealing with dynamically changing data.
Moodss (Modular Object Oriented Dynamic SpreadSheet) is an attempt at answering these needs. It is composed of a main part (the core) and an unlimited number of modules, each module interfacing to a specific type of data. The core is written in the great Tcl language (http://sunscript.sun.com/ or http://www.scriptics.com/ ) using object oriented techniques thanks to the stooop and scwoop packages (http://www.mygale.org/~jfontain/). The module function is to describe the type of data that it is also in charge of retrieving and formatting when asked by the core. Modules can be written in plain Tcl and optionally use dynamically linked libraries written in the C language (modules are packages in the Tcl sense).
Modules are loaded when moodss is started. One or more modules can be handled concurrently (new feature of versions 3.x). This way, you may monitor data coming from any number of heterogeneous sources. Module names are specified in the command line and cannot be unloaded.
Since module data access is entirely customizable (through C code, Tcl, HTTP, ...) and since several modules can be loaded at once, applications for moodss become limitless. For example, comparing a remote database server CPU load and a network load from a probe on the same graph becomes possible.
As features are added to moodss, different ways of viewing data will be made available while the modules will stay the same. The goal of moodss is to become a nice feature packed generic way of viewing data. Moodss can be used to monitor any type of data, since the simplest cases can fit in a table with a single row.
As moodss is written in Tcl and uses well supported extensions (Tktable and BLT), it will run on most Tcl/Tk supported platforms: UNIX and Windows (I do not know if Tktable and BLT are available for the MacIntosh). Some modules may be specific to a platform, but the core is guaranteed to run on them all.
After reading and understanding this document, you should be able to write your own modules in order to monitor the data that you are interested in.
Moodss is free software. You can redistribute it and/or modify it under the terms of a BSD type license: please see the COPYRIGHT file or use the main window About help menu for more information.
The core will load one or more modules, whose names were passed as command line parameters and will start displaying module data in one or more tables. The tables are then updated at the frequency defined by the poll time, which the user may change. For example, to launch moodss with the random module, just type:
$ wish moodss randomAll the module code and data are kept in a separate namespace. The module data is stored is a single array including some configuration data used when the module is loaded by the core, and variable data (displayed in the application table and eventual graphical viewers) which the module must update when requested by the core.
The initial data tables represent the first data views, from which cells can be selected and when dropped through a drag'n'drop operation into a graph, bar chart or pie chart iconic site, result in the creation of graphical data viewers. In turn, these viewers can display more table cells, which when dropped into the graphical viewer, result in the creation of corresponding data graph lines, bars, or slices.
Any draggable data can be dropped in valid drop sites at any time. It is thus possible to drag several data cells from any table or any viewer into other ones, the trash, ... even if the data comes from different modules.
All data viewers can be moved and resized at will through a simple internal window manager.
The message area is used to display status information, such as when the data is being updated, and help information, as the user moves the mouse pointer over sensitive areas, such as table column headers. Further help is provided through widget tips (also known as balloons) when appropriate, and of course the Help menu.
The window title shows the name of the current module along with the poll time.
The File menu only contains the Exit menu entry, used to gracefully quit the moodss application.
The Options menu contains the Poll time entry which when
selected launches the corresponding dialog box, as shown below:
The user can select a new poll time among the module choices from a spin entry widget, or directly type in a new value, as long as it is not smaller than the module minimum poll time, in which case a message dialog box warns the user.
Table data can be sorted at any time by simply clicking on a column
title. Clicking on the same column title again sorts the data in opposite
order, thus toggling between increasing and decreasing orders.
When sorting, the selected column is used as a reference, meaning that
all rows will be rearranged so that the selected column appears sorted,
with values either increasing or decreasing.
The reference column for sorting always appear in a darker shade of
gray.
Aside from the main tables, graphical viewers can be created for viewing table cell data behavior over time. Viewers can also be deleted, data views (such as pie slices, curves, ...) can be added or removed from existing viewers, ... These functions are all implemented using the drag and drop functionality described below.
Graphical viewers available at this time are BLT graph viewers (such as can be seen below), side-by-side bars charts, stacked bars charts, 2D pie charts and 3D pie charts*.
*note: if you know of any other nice viewers (like 3D graphs) that work with Tcl, please let me know so I can integrate them. Many thanks in advance...
The Help menu contains Global help (actually launches an embedded HTML viewer with this very document), Modules help, and About general information entries.
Only valid drop sites for the data being dragged are highlighted when the mouse cursor passes over them, thus guaranteeing error free operations.
In summary, data cells can be dragged from any data table or any viewer into any viewer icon, any viewer or the trash can.
Once a viewer exists, it also acts as a drop site for data cells, which may be dragged from any data table or other viewers. Dropping one or more cells directly in the viewer results in corresponding lines, bars or slices being created and automatically updated. Each new graphical element is assigned a new and different color.
You may delete one or more graphical viewer elements (graph lines, bar
chart bars or pie charts slices) from a graphical viewer by selecting them
(using the first mouse button) through their labels. Several elements can
be selected by depressing the control key as the first mouse button is
pressed. The selection can also be extended by depressing the shift key
along with the first mouse button. The pie slices can also be directly
selected by clicking on the slices themselves.
Then dragging from the viewer to the trash drop site (the bullet hole)
on the upper right side of the main window and releasing the first mouse
button result in the corresponding viewer elements to be destroyed. If
there are no remaining lines, the graphical viewer itself (graph, bar chart
or pie) is destroyed.
Any graphical viewer is also a drag site. It requires selecting one or more graphical viewer elements before initiating the drag operation from any point in the viewer. If there are no selected elements, dragging is impossible: the mouse cursor is not changed into the drag circular cursor. If there are no elements, then the viewer itself can be dragged and dropped into the trash only.
$ wish moodss randomor, for 2 modules at once:
$ wish moodss ps cpustatsYou may not specify the same module more than once in the command line.
You may eventually specify a poll time in seconds using:
$ wish moodss -update 25 random
package provide random 1.1This line simply states that this is the 1.1 version of the random package. Please note that the package name must also be used as the module namespace name (see below).
namespace eval random { array set data { ... } proc update {} { ... } }
All the module configuration data is stored as array members of the array named data within the module namespace. For example:
namespace eval random { array set data { updates 0 0,label name 0,type ascii 0,message {user name} 1,label cpu 1,type real 1,message {cpu usage in percent} 2,label disk 2,type integer 2,message {disk usage in megabytes} 3,label command 3,type dictionary 3,message {most time consuming command} pollTimes {10 5 20 30 60 120 300} columns 4 sort {1 decreasing} indexColumns {0 3} helpText { This is a simple demonstration module ... } } ... }The updates member is a counter used to keep track of the number of times that the module data was updated, and is also used by the core to detect when module data display should be updated (see variable data for more information).
The columns member defines the number of columns in the table to be displayed by the core.
The n,label members define the text to be displayed as column
titles. There must be as many n,label members as they are columns.
The n,type members define the type of the corresponding column
data. Valid types are simply those that the Tcl lsort command can
handle: ascii, dictionary, integer and real.
There must be as many n,type members as they are columns.
The n,message members define the text of the help message to
be displayed in the message area (see User Interface)
as the user moves the mouse pointer over column titles. It should be composed
of only a few words, just enough to actually help the user understand what
the column data means. There must be as many n,message members as
they are columns.
Note that column numbers start at 0.
The pollTimes member is a list of valid poll times (in seconds)
for the module. The list need not be ordered, as its first element represents
the default poll time value to be used when the moodss application starts.
This value may be overridden by a command line argument. The smallest value
in the list is used by the core as the lowest possible poll time and checked
against when the user enters a new value through the poll time dialog box.
The list must not be empty.
Note that the list is also used by moodss as a set of possible choices
in the dialog box used to set the new poll time. The user may still directly
input any value as long as it is greater than or equal to the minimum value.
The sort list defines the index of the column which should be initially used as a reference for sorting the data table rows, and in which order (increasing or decreasing) the rows should be sorted. The column index for sorting works like the -index Tcl lsort command option, that is rows are sorted so that that specific column appears sorted in the specified order.
The indexColumns list specifies the columns required to uniquely identify a row in the table. In database talk, it represents the table key. To maintain backward compatibility, it is optional and defaults to 0, the leftmost column. The index columns are used when creating data viewer elements: their label is built by concatenating the key value for the cell row with the cell column title. The key value is the concatenation of the index column values for the cell.
The helpText member specifies a text of any length, to be displayed when the user requests help information on the current module from within the help menu.
The core invokes the module update procedure (which obviously must exist) when it is time to refresh the data display (tables and eventually graphical viewers). At this time, the update procedure may update the tabular data straight away (synchronous operation) or launch a request for later data update (asynchronous operation).
It actually does not matter when the data is updated. The core will
know that fresh data is available when the updates array member
is set (actually incremented as it also serves as a counter for the number
of updates so far).
It is the module programmer's responsibility to increment this counter
right after all tabular data has been updated.
For example, retrieving information for the processes running on a machine
is a local operation that can be achieved in a reasonably small amount
of time. In such a case, data would be updated immediately and the updates
variable incremented at the same time.
But if the data has to be retrieved from across a network, waiting
for it to come back would cause a delay that the user would certainly notice,
as the application would not respond to mouse or keyboard input during
the whole time that it would take to fetch the whole data. In such cases,
it is easier to let the update procedure return immediately without setting
the updates variable, which would be incremented at a later time,
only when the data would become available. For example, when waiting for
data to come across a network connection, the Tcl fileevent command
could be used on a non blocking channel, where the script to be evaluated
when the channel becomes readable would increment the updates array
member.
Thus, data update can occur synchronously or asynchronously.
For example:
namespace eval random { ... proc update {} { variable data array set data " 0,0 john 0,1 1234 0,2 4567 0,3 cc 1,0 william 1,1 8901 1,2 2345 1,3 xedit 2,0 anny 2,1 6789 2,2 0123 2,3 ps 4,0 peter 4,1 4567 4,2 8901 4,3 ls 6,0 laura 6,1 2345 6,2 6789 6,3 emacs 3,0 robert 3,1 1234 3,2 5678 3,3 top " incr data(updates) } }The tabular data array index is the row number followed by the column number separated by a comma. The column number must start from 0 up to the total number of columns minus 1 (no holes are allowed in the column sequence).
When all rows (or only those table cells that have changed) have been updated, the updates member array must be incremented so that the core knows that it can update the table data display.
package ifneeded random 1.0 "source [file join $dir random.tcl]"The line above says that if the random package is needed, the Tcl core should source the random.tcl module source code from the directory where it was installed. 1.0 is the version number for the package.
Modules can be installed at any valid place that the Tcl core allows (look at the pkg_mkIndex manual page for more information).
When you unpack moodss, you will find the sample modules in sub-directories. The current directory (.) is appended to the auto_load global list variable so that sample modules can be found when moodss is run from the unpacking directory.
For example, if you unpacked moodss in /home/joe/moodss-3.0/, you will find the random module package in /home/joe/moodss-3.0/random/ so that the following will work:
$ cd /home/joe/moodss-3.0/ $ wish moodss randomYou can install your new modules in the default location: /usr/local/lib/ on Unix. For example, if you move the files in /home/joe/moodss-3.0/random/ to /usr/local/lib/random/, moodss (actually Tcl :) will still be able to find the random module (again, look at the pkg_mkIndex manual page for more information).
Please take a look at the INSTALL file for the latest information on how to install the moodss application itself.
Send your comments, complaints, ... to Jean-Luc Fontaine.