Further are considerations about running ftp and WWW servers on a BSDi machine.
This module is in charge of collecting the data from the satellite modem and store them in files.
The average data are stored in a file name from the month and year; for example the file for January 1998 will be Jan-98 (starting January 2000, the files will be called with 4 digits for the year).
Each line in the data file is in the format: Day Time AGC EbNo
For example:
16 20:48 60 11.4
represent a data collected on the 16th of the month, at 8:48 pm, when the AGC level was 60 and the Eb/No level was 11.4.
The data file represent 180KB/month with one measure every 5 minutes.
By default, the data files are created in /var/spool/ftp/pub/comstream/data/ (further /var/spool/ftp/pub is referenced as BASEFTP, it can be relocated). The files has to be created in a directory accessible via ftp so they can be downloaded.
At the same time, average data are stored in a MySQL database, the
value stored are Time Stamp, Avg EB/No, Avg
AGC, Min Eb/No, Max Eb/no, Min AGC,
Max Agc, Error Eb/No, Error AGC,
Interval.
The interval for data collection can be adjusted by setting the number of seconds in the INTERVAL macro at the top of the program. As the data collection is separated from it's analyze, the collecting interval can be adjusted independently.
The serial port on the modem must be set to 9600 bauds, and 8bit, no parity. In case this should be changed, the C code would have to be adapted. I suggest the following way to proceed:
As default it is installed in /usr/local/comstream (this is further refered under the name BASELOG) and it is called comstream.
It consists in a single C file, that has been compiled and tested on BSDi 2.1 (gcc version 2.7.2).
To compile it, use a command line like:
ai3gate
the library mysqlclient is required to store the data on MySQL database.
When called, comstream starts a subprocess that will collect the data every 5 minutes. The interval can be adjusted. The pid of the subprocess is stored in BASELOG/lock.
When called with option -q, it stops the subprocess collecting data.
When called with option -i, it starts the interactive mode that allows user exchanging commands with the modem. The interactive mode shares the serial connection to the modem with the subprocess that collects data.
The data collection module should be started at boot time, with an entry in /etc/rc.local that looks like:
# start the login of satellite modem if [ -f /usr/local/comstream/comstream ] then /usr/local/comstream/comstream fiComstream is made available under the the GNU General Public Licence.
This module is in charge of reading the data files collected by the comstream module and producing graphs and HTML as shown on the page http://ai3gate.cs.ait.ac.th/comstream/.
Eb/No level is represented in blue line. It is scaled to be ploted only for the values in the range 9..14 dB (this can be adjusted with MINEBNO and MAXEBNO).
AGC level is represented in green impulses. It is scaled to be ploted only for the values in the range 50..70 (this can be adjusted with MINAGC and MAXAGC). The scale for AGC level is located on the right handside of the graph.
The weekly, monthly and yearly graphs are not computed on average data but on the full set of data as it seams important to keep the full details, including the maximum and minimum values that data can reach. Saying that the Eb/No level was average of 11 toward the day, while it was 8.5 for 12 hours and 13.5 for 12 hours, is meaning less, 8.5 is not a workable situation and 13.5 is a very good situation, as a result the link has been working good for12 hours, not working average for 24 hours.
Dayly graph is updated every time the module is run. It is created in BASEWWW/comstream/images/oneday.gif.
Weekly graph is updated every 30 minutes, at 0:00 am, 0:30 am, 1:00 am, etc. or if the previous weekly graph is more than 30 minutes old. It is created in BASEWWW/comstream/images/onweek.gif.
Monthly graph is updated every 2 hours, at 0:00 am, 2:00 am, 4:00 am, etc. or if the previous weekly graph is more than 2 hours old. It is created in BASEWWW/comstream/images/onemonth.gif.
Yearly graph is updated every day, at 0:00 am, or if the previous graph is more than 24 hours old. It is created in BASEWWW/comstream/images/oneyear.gif.
The four graphs may be forced to be computed when using the option initialise (-i).
Each graph requires 5KB of hard disk space.
It is created in BASEWWW/comstream/index.html.
The module is called analyze, and is installed as default in BASELOG.
It consist in a single Perl script that has been tested under BSDi 2.1, Perl 5.3.
It requires the tools Gnuplot and ppmtogif, both tools are available in BSDi. The exact location for those tools has to be updated if needed.
The location for BASEFTP has to be updated accordingly with the comstream module.
The graphs and the HTML files are created in the directory /var/www/docs/comstream (further, /var/www/docs is referenced as BASEWWW). It created several temporary files in BASELOG, the total size needed for temporary files is up to 2MB (when computing a full year graph). Some temporary graph in pbm format are also created in BASEWWW/comstream/image the size should not exceed 300K.
Temporary files in BASELOG are important and should not be deleted! as they are used to save maximum and minimum values for each graph, those values being used later to create the HTML file.
The analyze module is run through crontab(1). I suggest an entry like:
0-55/5 * * * * /usr/local/comstream/analyze
to run the analyze module every 5 minutes.
The option -i (initialise) is provided for ionteractive run of the module, it will force an update of every of the four graphs, as well as the update of the HTML file.
Analyze is made available under the the GNU General Public Licence.
The data analysis module will consume the following dik I/O:
As the amount of disk I/O is much more important for the analysis module than for the collecting module, I recommend, if both modules run on separate machines, that the data are located on the local dik of the machine computing the analysis.
In order to start up WWW server and ftp server on a BSDi machine, here is a summary of the procedure.
You then need to create the directories /var/spool/ftp/pub/comstream and /var/spool/ftp/pub/comstream/data.