Decision Support System to MODEM communications Guy Van Sanden gvsanden@sckcen.be
Decision Support System to MODEM communications by Guy Van Sanden This document describes how to set up the dss2modem communications
Table of Contents 1. Introduction...1 2. Transport over FTP...2 3. dss2modem daemon...3 3.1. Requirements...3 3.1.1. Win32 platforms...3 3.2. Installing dss2modem daemon...3 3.2.1. Unix/Linux...3 3.2.2. Windows...5 3.3. Configuring dss2modem daemon...5 3.3.1. XML configuration file...5 3.4. Running dss2modem daemon...7 3.4.1. Running on Windows...7 3.4.2. Running on Linux/Unix...7 Glossary...8 iii
Chapter 1. Introduction MODEM is invoked and requires data from the Decision Support System. The communication between the Decision Support System and MODEM is referred to as dss2modem. It consists mainly of file transfers to MODEM, these files are then processed by the MODEM software. The standard way of doing this is by using the dss2modem daemon (dss2modemd), This is a cross platform daemon/service written in perl that will monitor a given set of directories for incoming files and transfer the relevant ones to the MODEM server for processing over a Secure Shell (SSH) connection. This method does not require the use of passwords but uses a system of public keys to authenticate. Instead of this daemon, some sites prefer to use FTP instead. MODEM software will process these files correctly (as with the SSH transfers), but the logic for doing this will have to be build in by the DSS development teams. 1
Chapter 2. Transport over FTP Sites that will not use the dss2modem daemon will need support in the Decision Support System itself for transfering the files to the MODEM server. The most common protocol to do this is ftp (although something like rsync can also be used). The use of FTP as the transfer protocol requires saving passwords in a file or program code on the DSS side. FTP is an insecure protocol. Transmission of data and passwords during connections is trivial. To avoid this, you can use SSL ftp but you will need support for this in both the DSS system and the FTP server on MODEM. For this method to work, FTP server software has to be installed and configured on the MODEM server. 2
Chapter 3. dss2modem daemon 3.1. Requirements The dss2modem daemon depends on a working version of perl 5.6 or later (5.8 recommended). It also requires certain perl modules which can be downloaded from CPAN (search.cpan.org) if they did not come standard with your perl install. File::Find File::Basename File::Copy File::Path XML::Simple To communicate, the dss2modem daemon uses OpenSSH. You will need a working OpenSSH-server install on your MODEM server and a working OpenSSH-client install on the machine that is running the DSS software. SSH software handles authentication to your system, it is therefor critical to keep up to date with security patches that are released for it. 3.1.1. Win32 platforms The dss2modem daemon requires an extra program on windows to make it run as a Win32 service. The program is called svrany and can be found in the Windows Resource Kit. You can always find an updated link to this on the main MODEM site. You can download a perl implementation for Win32 from Activestate at their site (http://www.activestate.com/products/activeperl/). OpenSSH for windows (using Cygwin) is available from Sourceforge (http://sshwindows.sourceforge.net). 3.2. Installing dss2modem daemon 3
Chapter 3. dss2modem daemon 3.2.1. Unix/Linux This step assumes you have installed Perl and the required modules. Download the dss2modem daemon from the MODEM site (http://modemsrv.sckcen.be) (section downloads) to a temporary local directory (example: /tmp/dss2modem). Unpack the zip archive with the tools on your system. In the directory where you unpacked the files, run perl install.pl. 3.2.1.1. Unix/Linux init script This is an example init script for starting the dss2modem daemon at boot time. Please adapt it to work on your system. #! /bin/sh case "$1" in start) echo -n "Starting service newfile daemon" ## Start daemon with startproc(8)d. If this fails ## the echo return value is set appropriate. # NOTE: startproc return 0, even if service is # already running to match LSB spec. su dss -c /srv/www/tomcat/base/webapps/modemex/web-inf/classes/newfile.sh start ;; stop) echo -n "Shutting down service newfile daemon" ## Stop daemon with killproc(8) and if this fails ## set echo the echo return value. kill cat /srv/www/tomcat/base/webapps/modemex/web-inf/classes/newfile.pid ;; restart) ## Stop the service and regardless of whether it was ## running or not, start it again. $0 stop $0 start *) ;; echo "Usage: $0 {start stop status try-restart restart force-reload reload}" exit 1 ;; 4
Chapter 3. dss2modem daemon esac 3.2.2. Windows This step assumes you have installed Perl. Download the zip-file from the main MODEM site to a local directory (example: c:\tmp). Unpack the zip-file using your system tools. Open a command shell by clicking Start, then Run, and finally typing cmd. In the console window, type: c:\>cd tmp c:\tmp> perl install.pl Follow the instructions on the screen. 3.3. Configuring dss2modem daemon 3.3.1. XML configuration file The configuration file for dss2modem daemon is in XML format. It has the following structure <?xml version= 1.0?> <config profile="" logfile=""> <directory> <path></path> <sleeptime></sleeptime> <marktime></marktime> <debug></debug> <changedcheck></changedcheck> <deletedcheck></deletedcheck> <scpcmd></scpcmd> <sshport></sshport> <modemhost></modemhost> <modemuser></modemuser> <transitdir></transitdir> <ontransmit></ontransmit> <archivedir/> 5
Chapter 3. dss2modem daemon </directory> </config> The profile attribute is just an informal name for this setup (remember that you can have multiple instances of dss2modem daemon running at the same time). logfile specifies the file were the daemon writes it s messages to. <path> indicates which directory has to be monitored (for example c:\tmp or /tmp). <sleeptime> is the time in seconds that the daemon sleeps before checking the directory aain. 20 seconds has proven to be a reasonable value. <marktime> is the time in seconds between two -- mark -- messages in the logfile. They are written to indicate that the daemon is still working even when nothing is logged for long periods of time. A good value is 2400 <debug> is a switch (0 or 1) to turn on debugging. In debug mode, the daemon writes a lot of extra information to the logfile. This can help track down a problem. Normally the value is 0. <changedcheck> is a switch (0 or 1) that tells the daemon if it should also detect changes in files (1) instead of only detecting new files (0). <deletedcheck> is a switch (0 or 1) that tells the daemon if it should also check for files being deleted. It is recommended to turn this option on because it removes entries for deleted files from the internal hash, limiting memory consumption (especially over a longer period of time). <scpcmd> specifies which command should be used to transfer files over ssh. If the scp binary is in your PATH, the value scp will work. <modemhost> is the fully qualified hostname of you MODEM server (including domain). <modemuser> is the userid on the MODEM server that is used for the SSH connection. <transitdir> is a directory on the MODEM server where files are stored temporarily before being picked up by the NewFile daemon (see MODEM documentation for more information on this). If your MODEM server is running OpenSSH on a Windows platform, this element must specify the CygWin drive path instead of a normal directory. This naming scheme emulates the Unix directory tree on Windows. A CygWin directory is specified by /cygdrive/driveletter/directory. For example, the real directory c:\tmpmaps to the Cygdrive path /cygdrive/c/tmp. 6
Chapter 3. dss2modem daemon <ontransmit> can be either delete, move or none. It controls what is done with the detected files after transferring to MODEM. <archivedir> only applies when ontransmit is set to move. In that case, the processed files are moved to the archive directory while retaining the relative filestructure of the original. 3.4. Running dss2modem daemon 3.4.1. Running on Windows You can start the daemon from the command line using the command supplied by the install script (example below): c:\>perl c:\bin\dss2modemd.pl c:\etc\dss2modem_conf.xml Or start it as a service from the windows services menu. 3.4.2. Running on Linux/Unix You can start the daemon in a console with the command supplied by the install script (example below): # /usr/local/bin/dss2modemd.pl /etc/dss2modem_conf.xml Or use an init script. 7
Glossary D Daemon This term originated on Unix systems. It is used for programs that run in the background without user-interaction. A daemon typically has no controlling terminal. On Microsoft Windows, the term service is mostly used instead of daemon. 8