# Session monitor

## Installation

For security reasons, the client portion of the session montior may run on one or more external public machine(s). On these machines, install:

- Perl (at l east 5.004_05 for the 5.004 series or 5.005_03 for the 5.005 series. Don't enable experimental features like threads or the PerlIO abstraction layer.)
- FS::SessionClient (copy the fs_session/FS-SessionClient directory to the external machine, then: perl Makefile.PL; make; make install)

Then:

- Add the user `freeside' to the the external machine.
- Create the /usr/local/freeside directory on the external machine (owned by the freeside user).
- touch /usr/local/freeside/fs_sessiond_socket; chown freeside /usr/local/freeside/fs_sessiond_socket; chmod 600 /usr/local/freeside/fs_sessiond_socket
- Append the identity.pub from the freeside user on your freeside machine to the authorized_keys file of the newly created freeside user on the external machine(s).
- Run

      fs_session_server user machine

  on the Freeside machine.
  - user is a user from the mapsecrets file.
  - machine is the name of the external machine.

## Usage

- Web
  - Copy FS-SessionClient/cgi/login.cgi and logout.cgi to your web server's document space.
  - Use suEXEC or setuid (see install.html for details) to run login.cgi and logout.cgi as the freeside user.
- Command-line

      freeside-login username ( portnum | ip | nasnum nasport )
      freeside-logout username ( portnum | ip | nasnum nasport )

  - username is a customer username from the svc_acct table
  - portnum, ip or nasport and nasnum uniquely identify a port in the port database table.
- RADIUS - One of:
  - Run the freeside-sqlradius-radacctd daemon to import radacct records from all configured sqlradius exports: `freeside-sqlradius-radacctd username`
  - Configure your RADIUS server's login and logout callbacks to use the command-line `freeside-login` and `freeside-logout` utilites.
  - (incomplete)Use the fs_radlog/fs_radlogd tool to import records from a text radacct file.

## Callbacks

- Sesstion start - The command(s) specified in the session-start configuration file are executed on the Freeside machine. The contents of the file are treated as a double-quoted perl string, with the following variables available: `$ip`, `$nasip` and `$nasfqdn`, which are the IP address of the starting session, and the IP address and fully-qualified domain name of the NAS this session is on.
- Session end - The command(s) specified in the session-stop configuration file are executed on the Freeside machine. The contents of the file are treated as a double-quoted perl string, with the following variables available: `$ip`, `$nasip` and `$nasfqdn`, which are the IP address of the starting session, and the IP address and fully-qualified domain name of the NAS this session is on.

## Dropping expired users

Run

    bin/freeside-session-kill username

periodically from cron.