torrus, 10574
[freeside.git] / FS / FS / NetworkMonitoringSystem.pm
diff --git a/FS/FS/NetworkMonitoringSystem.pm b/FS/FS/NetworkMonitoringSystem.pm
new file mode 100644 (file)
index 0000000..c16d5fe
--- /dev/null
@@ -0,0 +1,28 @@
+package FS::NetworkMonitoringSystem;
+
+use strict;
+use vars qw( $conf $system $AUTOLOAD );
+use FS::Conf;
+use FS::UID;
+
+FS::UID->install_callback( sub { 
+  $conf = new FS::Conf;
+  $system = $conf->config('network_monitoring_system');
+} );
+
+sub AUTOLOAD {
+  my $self = shift;
+
+  my($sub)=$AUTOLOAD;
+  $sub =~ s/.*://;
+
+  my $conf = new FS::Conf;
+  die "FS::NetworkMonitoringSystem::$AUTOLOAD called, but none configured\n"
+    unless $system;
+
+  eval "use FS::NetworkMonitoringSystem::$system;";
+  die $@ if $@;
+
+  $self .= "::$system";
+  $self->$sub(@_);
+}