示例#1
0
 public void Add(ZabbixQueueItem log)
 {
     lock (_logItems)
     {
         _logItems.Add(log);
     }
 }
示例#2
0
        public void Dispose()
        {
            if (VUCount != null)
            {
                VUCount.Dispose();
            }
            if (Result != null)
            {
                Result.Dispose();
            }
            if (Debug != null)
            {
                Debug.Dispose();
            }
            if (Zabbix != null)
            {
                Zabbix.Dispose();
            }
            if (ZabbixNetwork != null)
            {
                ZabbixNetwork.Dispose();
            }

            this.VUCount       = null;
            this.Result        = null;
            this.Debug         = null;
            this.Zabbix        = null;
            this.ZabbixNetwork = null;
        }
示例#3
0
 public QueueItem(ZabbixQueueNetworkItem ZabbixNetwork)
 {
     this.VUCount       = null;
     this.Result        = null;
     this.Debug         = null;
     this.Zabbix        = null;
     this.ZabbixNetwork = ZabbixNetwork;
 }
示例#4
0
 public QueueItem(TextQueueItem Debug)
 {
     this.VUCount       = null;
     this.Result        = null;
     this.Debug         = Debug;
     this.Zabbix        = null;
     this.ZabbixNetwork = null;
 }
示例#5
0
 public QueueItem(WebResultQueueItem Result)
 {
     this.Result        = Result;
     this.VUCount       = null;
     this.Debug         = null;
     this.Zabbix        = null;
     this.ZabbixNetwork = null;
 }
示例#6
0
 public QueueItem(VUQueueItem VUCount)
 {
     this.VUCount       = VUCount;
     this.Result        = null;
     this.Debug         = null;
     this.Zabbix        = null;
     this.ZabbixNetwork = null;
 }
示例#7
0
 public void Add(ZabbixQueueItem log)
 {
     Add(new QueueItem(log));
 }
示例#8
0
        private void CounterProcNet(Object st)
        {
            MonitorTheadStarter info = (MonitorTheadStarter)st;

            Zabbix zbx = new Zabbix(info.config.Host, info.config.Port);
            //String tmp = zbx.GetItem(info.key);

            //

            ZabbixQueueItem lastIn  = null;
            ZabbixQueueItem lastOut = null;

            while (_running)
            {
                try
                {
                    if (lastIn == null)
                    {
                        lastIn = new ZabbixQueueItem(DateTime.Now, info.config.Host, info.key, 0, Int64.Parse(zbx.GetItem("net.if.in[" + info.key + "]")));
                    }

                    if (lastOut == null)
                    {
                        lastOut = new ZabbixQueueItem(DateTime.Now, info.config.Host, info.key, 0, Int64.Parse(zbx.GetItem("net.if.out[" + info.key + "]")));
                    }

                    ZabbixQueueItem actualIn  = new ZabbixQueueItem(DateTime.Now, info.config.Host, info.key, 0, Int64.Parse(zbx.GetItem("net.if.in[" + info.key + "]")));
                    ZabbixQueueItem actualOut = new ZabbixQueueItem(DateTime.Now, info.config.Host, info.key, 0, Int64.Parse(zbx.GetItem("net.if.out[" + info.key + "]")));

                    try
                    {
                        double lapIn  = ((TimeSpan)(actualIn.date - lastIn.date)).TotalSeconds;
                        double lapIn2 = double.Parse(actualIn.value.ToString()) - double.Parse(lastIn.value.ToString());

                        double valueIn = (lapIn2 / lapIn);

                        if (double.IsNaN(valueIn) || double.IsInfinity(valueIn))
                        {
                            valueIn = 0;
                        }

                        if (valueIn < 0)
                        {
                            valueIn = 0;
                        }

                        double lapOut  = ((TimeSpan)(actualOut.date - lastOut.date)).TotalSeconds;
                        double lapOut2 = double.Parse(actualOut.value.ToString()) - double.Parse(lastOut.value.ToString());

                        double valueOut = (lapOut2 / lapOut);

                        if (double.IsNaN(valueOut) || double.IsInfinity(valueOut))
                        {
                            valueOut = 0;
                        }

                        if (valueOut < 0)
                        {
                            valueOut = 0;
                        }

                        _queue[info.index].Add(new ZabbixQueueNetworkItem(actualIn.date, actualIn.host, info.key, ((Int64)valueIn), ((Int64)valueOut)));

                        lastIn  = actualIn;
                        lastOut = actualOut;
                    }
                    catch { }
                }
                catch { }
                finally
                {
                    Thread.Sleep(10000);
                }
            }
        }