session monitor
[freeside.git] / fs_sesmon / fs_session_server
1 #!/usr/bin/perl -Tw
2 #
3 # fs_session_server
4 #
5
6 use strict;
7 use vars qw( $opt $Debug );
8 use IO::Handle;
9 use Net::SSH qw(sshopen3)
10 use FS::UID qw(adminsuidsetup);
11 use FS::Record qw( qsearch qsearchs );
12 #use FS::cust_main_county;
13 #use FS::cust_main;
14 use FS::session;
15
16 #require "configfile";
17 $Debug = 1;
18
19 my $user = shift or die &usage;
20 &adminsuidsetup( $user ); 
21
22 my $machine = shift or die &usage;
23
24 my $fs_sessiond = "/usr/local/sbin/fs_sessiond";
25
26 my $me = "[fs_session_server]";
27
28 while (1) {
29   my($reader, $writer) = (new IO::Handle, new IO::Handle);
30   $writer->autoflush(1);
31   warn "$me Connecting to $machine\n" if $Debug;
32   sshopen2($machine,$reader,$writer,$fs_signupd);
33
34   warn "$me Entering main loop\n" if $Debug;
35   while (1) {
36     warn "$me Reading (waiting for) data\n" if $Debug;
37     my $command = scalar(<$reader));
38     #DoS protection here too, to protect against a compromised client?  *sigh*
39     while ( ( my $key = scalar(<$reader>) ) != "END\n" ) {
40       chomp $key;
41       chomp( $hash{$key} = scalar(<$reader>) );
42     }
43
44     if ( $command eq 'login' ) {
45
46     } elsif ( $command eq 'logoff' ) {
47
48     } elsif ( $command eq 'portnum' ) {
49
50     } else {
51       warn "$me WARNING: unrecognized command";
52     }
53