Java scripts
As part of my GUI project, I wanted to get a real time overview of the tc counters in a graph in a browser. I discovered a java applet (www.hav.com) that does this and after contacting the author, he gave me permission to use his applet. But after studying his script, I created my own java applet, based on his applet.This is my first applet. It's very handy if you want to create real time graphs. The main problem is getting the data to the applet. I fetch an url and parse the data, ideally it should contact a daemon running on the host. It also should better if the url contains a very accurate timestamp so the rate can be calculated.
TODO
- more options
- nicer output
- getting the data to the javascript with a daemon
URL issue
- The dataSource parameter MUST be on the same server as the source of the java applet !!!
- The URL that's fetched can only contain counters. So no <body> and/or <html>. See the rand.php or time.php script as example.
Applets
Tcgraph applet
This applet fetches an url with one ore more counters (maximum = 10). These counters are used to create a chart.Tcgraph applet options
- dataSource : URL that contains 1 line with a counter
- gridSize : the number of pixes between 2 vertical grid lines (default 10)
- counterSize : the number of counters between 2 grid lines (default 10)
If gridSize = counterSize you have a value on each pixel - type : = 0 : draw the counters as a line
!= 0 : draw the counters as an area - speed : # seconds the applet waits before fetching a new counter (default 3)
Tcgraph applet demo
tcgraph.phptcgraph_inaccuracy.php
Bar applet
I also created the bar.class applet. This applet takes 1 number as input and creates a bar.Bar applet options
- dataSource : URL that contains 1 line with a counter
- red : in % (default 90)
- yellow : in % (default 80)
- speed : # seconds the applet waits before fetching a new counter (default 3)
- Space we left open around the bar :
- lSpace : left space (default = 2, in pixels)
- tSpace : top space (default = 2, in pixels)
- rSpace : right space (default = 2, in pixels)
- bSpace : bottom space (default = 2, in pixels)
- max : the maximum counter we can get
if this is not 100, we calculate the counter in % and we show the counter value in the bar
if this is 100 or not specified, we consider the counter as % - showCou : do we show the counter in the bar
If you don't specify this, or you give not true as value, the counter is shown
If you have a counter in %, the counter in % is also not shown - showPro : do we show the counter in % at the bottom of the bar
If you don't specify this, or you give not true as value, the counter in % is shown - bgOffset : the bar has a background in green, yellow and red
bgOffset determines how light the background will be
0 < bgOffset < 255
the bigger the number, the lighter the background
default = 200 - The background of the bar is by default white. You can overrule that with 3 numbers. White is 255:255:255, black is 0:0:0.
- bgcol1
- bgcol2
- bgcol3