Exemplo n.º 1
0
        private static void ModifyIpAccounting(ITikConnection connection)
        {
            var accounting = connection.LoadSingle <IpAccounting>();

            accounting.Threshold = 257;
            connection.Save(accounting);
        }
Exemplo n.º 2
0
        public static InterfacePppoeClientMonitor GetInterfacePppoeClientMonitorSnapshot(this ITikConnection connection, string numbers)
        {
            var result = connection.LoadSingle <InterfacePppoeClientMonitor>(
                connection.CreateParameter("numbers", numbers, TikCommandParameterFormat.NameValue),
                connection.CreateParameter("once", "", TikCommandParameterFormat.NameValue));

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets snapshot of actual traffic RX/TX values for given <paramref name="interfaceName"/>.
        /// </summary>
        public static InterfaceMonitorTraffic GetInterfaceMonitorTrafficSnapshot(this ITikConnection connection, string interfaceName)
        {
            var result = connection.LoadSingle <InterfaceMonitorTraffic>(
                connection.CreateParameter("interface", interfaceName, TikCommandParameterFormat.NameValue),
                connection.CreateParameter("once", "", TikCommandParameterFormat.NameValue));

            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets snapshot of actual values for given <paramref name="interfaceName"/>.
        /// </summary>
        public static EthernetMonitor GetEthernetMonitorSnapshot(this ITikConnection connection, string interfaceName)
        {
            var result = connection.LoadSingle <EthernetMonitor>(
                connection.CreateParameter("numbers", interfaceName, TikCommandParameterFormat.NameValue),
                connection.CreateParameter("once", "", TikCommandParameterFormat.NameValue));

            return(result);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Called when the package is started.
 /// </summary>
 public override void OnStart()
 {
     Task.Factory.StartNew(async() =>
     {
         while (PackageHost.IsRunning)
         {
             try
             {
                 if (this.connection == null || !this.connection.IsOpened)
                 {
                     this.connection = this.GetConnection();
                 }
                 if (this.connection != null && this.connection.IsOpened)
                 {
                     try
                     {
                         // Test connection with simple command
                         connection.CreateCommand("/system/identity/print").ExecuteScalar();
                         // Query & push
                         // - Base objects -
                         this.QueryAndPush("SystemResource", () => connection.LoadSingle <SystemResource>());
                         this.QueryAndPush("Interfaces", () => connection.LoadList <Interface>());
                         this.QueryAndPush("IpAddresses", () => connection.LoadList <IpAddress>());
                         this.QueryAndPush("Pools", () => connection.LoadList <IpPool>());
                         this.QueryAndPush("Queues", () => connection.LoadList <QueueSimple>());
                         // - DHCP client & server leases -
                         this.QueryAndPush("DhcpClient", () => connection.LoadList <IpDhcpClient>());
                         this.QueryAndPush("DhcpServerLeases", () => connection.LoadList <DhcpServerLease>());
                         // - IPv6 objects -
                         this.QueryAndPush("Ipv6Neighbors", () => connection.LoadList <Ipv6Neighbor>());
                         this.QueryAndPush("Ipv6Pools", () => connection.LoadList <Ipv6Pool>());
                         this.QueryAndPush("Ipv6Addresses", () => connection.LoadList <Ipv6Address>());
                         this.QueryAndPush("Ipv6DhcpClient", () => connection.LoadList <Ipv6DhcpClient>());
                         // - CAPSMAN registration table  -
                         this.QueryAndPush("WirelessClients", () => connection.LoadList <CapsManRegistrationTable>());
                     }
                     catch (IOException)
                     {
                         this.connection = null;
                     }
                 }
                 await Task.Delay(Math.Min(1000, PackageHost.GetSettingValue <int>("QueryInterval")));
             }
             catch (Exception ex)
             {
                 PackageHost.WriteError($"Fatal error in the main loop : {ex}");
                 await Task.Delay(5000);
             }
         }
     }, TaskCreationOptions.LongRunning);
     PackageHost.WriteInfo("Package started !");
 }
Exemplo n.º 6
0
        /// <summary>
        /// Called when the package is started.
        /// </summary>
        public override void OnStart()
        {
            DateTime lastQuery = DateTime.MinValue;
            Thread   thQuery   = new Thread(new ThreadStart(() =>
            {
                while (PackageHost.IsRunning)
                {
                    if (DateTime.Now.Subtract(lastQuery).TotalMilliseconds >= PackageHost.GetSettingValue <int>("QueryInterval"))
                    {
                        if (this.connection == null || !this.connection.IsOpened)
                        {
                            this.connection = this.GetConnection();
                        }
                        if (this.connection != null && this.connection.IsOpened)
                        {
                            try
                            {
                                // Test connection with simple command
                                connection.CreateCommand("/system/identity/print").ExecuteScalar();
                                // Query & push
                                // - Base objects -
                                this.QueryAndPush("SystemResource", () => connection.LoadSingle <SystemResource>());
                                this.QueryAndPush("Interfaces", () => connection.LoadList <Interface>());
                                this.QueryAndPush("IpAddresses", () => connection.LoadList <IpAddress>());
                                this.QueryAndPush("Pools", () => connection.LoadList <IpPool>());
                                this.QueryAndPush("Queues", () => connection.LoadList <QueueSimple>());
                                // - DHCP client & server leases -
                                this.QueryAndPush("DhcpClient", () => connection.LoadList <IpDhcpClient>());
                                this.QueryAndPush("DhcpServerLeases", () => connection.LoadList <DhcpServerLease>());
                                // - IPv6 objects -
                                this.QueryAndPush("Ipv6Neighbors", () => connection.LoadList <Ipv6Neighbor>());
                                this.QueryAndPush("Ipv6Pools", () => connection.LoadList <Ipv6Pool>());
                                this.QueryAndPush("Ipv6Addresses", () => connection.LoadList <Ipv6Address>());
                                this.QueryAndPush("Ipv6DhcpClient", () => connection.LoadList <Ipv6DhcpClient>());
                                // - CAPSMAN registration table  -
                                this.QueryAndPush("WirelessClients", () => connection.LoadList <CapsManRegistrationTable>());
                            }
                            catch (IOException)
                            {
                                this.connection = null;
                            }
                        }
                        lastQuery = DateTime.Now;
                    }
                    Thread.Sleep(100);
                }
            }));

            thQuery.Start();
            PackageHost.WriteInfo("Package started !");
        }
Exemplo n.º 7
0
 private static void PrintSystemResource(ITikConnection connection)
 {
     var sysRes = connection.LoadSingle<SystemResource>();
     Console.WriteLine(sysRes.EntityToString());
 }
Exemplo n.º 8
0
 private static void ModifyIpAccounting(ITikConnection connection)
 {
     var accounting = connection.LoadSingle<IpAccounting>();
     accounting.Threshold = 257;
     connection.Save(accounting);
 }
Exemplo n.º 9
0
        private static void PrintSystemResource(ITikConnection connection)
        {
            var sysRes = connection.LoadSingle <SystemResource>();

            Console.WriteLine(sysRes.EntityToString());
        }
Exemplo n.º 10
0
        public string PrintSystemResource()
        {
            var sysRes = connection.LoadSingle <SystemResource>();

            return(sysRes.EntityToString());
        }