Exemplo n.º 1
0
            public PerformanceCounterTracker(Logging.IBasicLogger logger, PerformanceCounterSpec pcs)
            {
                this.pcs = pcs;
                pcc      = pcs.GetPerformanceCounterCategory();

                useRawPerfCtrValue = pcs.UseRawValue;

                gpInfo = new MDRF.Writer.GroupPointInfo()
                {
                    Name     = pcs.PointName,
                    ValueCST = ContainerStorageType.None,
                };

                try
                {
                    var categorySample = pcc.ReadCategory();
                    Service(logger, categorySample, true);
                }
                catch (System.Exception ex)
                {
                    Logging.IMesgEmitter emitter = (logger == null ? Logging.NullEmitter : logger.Info);

                    emitter.Emit("{0} for '{1}' generated unexpected exception: {2}", CurrentMethodName, gpInfo.Name, ex.ToString(ExceptionFormat.TypeAndMessage));

                    isUsable = false;
                }
            }
Exemplo n.º 2
0
 public GPIPair(int setNum)
 {
     pidGPI = new MDRF.Writer.GroupPointInfo()
     {
         Name = "Set.{0:d2}.pid".CheckedFormat(setNum), Comment = "Gives the process ID of the process in set {0}".CheckedFormat(setNum), ValueCST = ContainerStorageType.Int32, VC = new ValueContainer(0)
     };
     nameGPI = new MDRF.Writer.GroupPointInfo()
     {
         Name = "Set.{0:d2}.name".CheckedFormat(setNum), Comment = "Gives the process name of the process in set {0}".CheckedFormat(setNum), ValueCST = ContainerStorageType.String, VC = new ValueContainer("")
     };
 }
Exemplo n.º 3
0
            public SerialEchoTracker(string portPartID, string portTargetSpec, double[] binBoundariesArray, SerialEchoPerformancePartConfig config, INotifyable notifyOnDone, Logging.IBasicLogger logger)
            {
                PortTargetSpec = portTargetSpec;
                Config         = config;
                NotifyOnDone   = notifyOnDone;
                Logger         = logger;

                h = new Histogram(binBoundariesArray);

                timeoutCountGPI = new MDRF.Writer.GroupPointInfo()
                {
                    Name = "timeoutCount", ValueCST = ContainerStorageType.UInt64, VC = new ValueContainer(0L)
                };
                failureCountGPI = new MDRF.Writer.GroupPointInfo()
                {
                    Name = "failureCount", ValueCST = ContainerStorageType.UInt64, VC = new ValueContainer(0L)
                };

                hGrp = new MDRFHistogramGroupSource("{0}".CheckedFormat(portPartID),
                                                    h,
                                                    (ulong)config.AggregateGroupsFileIndexUserRowFlagBits,
                                                    extraClientNVS: new NamedValueSet()
                {
                    { "SerialEcho" }, { "PortTargetSpec", PortTargetSpec }
                },
                                                    extraGPISet: new[] { timeoutCountGPI, failureCountGPI });

                try
                {
                    portConfig = new PortConfig(portPartID, portTargetSpec)
                    {
                        TxLineTerm          = LineTerm.None,
                        RxLineTerm          = LineTerm.CR,
                        ConnectTimeout      = (2.0).FromSeconds(),
                        WriteTimeout        = (1.0).FromSeconds(),
                        ReadTimeout         = (1.0).FromSeconds(),
                        IdleTime            = (1.0).FromSeconds(),
                        EnableAutoReconnect = true,
                    };

                    port = MosaicLib.SerialIO.Factory.CreatePort(portConfig);

                    portGetNextPacketAction = port.CreateGetNextPacketAction();
                    portFlushAction         = port.CreateFlushAction();
                    portWriteAction         = port.CreateWriteAction(portWriteActionParam = new WriteActionParam());
                }
                catch (System.Exception ex)
                {
                    Logger.Error.Emit("Port setup for '{0}' failed: {1}", portTargetSpec, ex.ToString(ExceptionFormat.TypeAndMessage));
                }
            }
Exemplo n.º 4
0
            public PingTracker(string hostNameOrAddress, double[] binBoundariesArray, PingPerformancePartConfig config, INotifyable notifyOnDone)
            {
                HostNameOrAddress = hostNameOrAddress;
                NotifyOnDone      = notifyOnDone;

                // calling GetHostAddresses can throw for many reasons (invalid app.config for example...)
                Func <System.Net.IPAddress []> getHostAddressesDelegate = () => System.Net.Dns.GetHostAddresses(hostNameOrAddress);

                IPAddressArray = getHostAddressesDelegate.TryGet();

                IPAddress = IPAddressArray.SafeAccess(0, System.Net.IPAddress.None);
                h         = new Histogram(binBoundariesArray);

                timeoutCountGPI = new MDRF.Writer.GroupPointInfo()
                {
                    Name = "timeoutCount", ValueCST = ContainerStorageType.UInt64, VC = new ValueContainer(0L)
                };
                failureCountGPI = new MDRF.Writer.GroupPointInfo()
                {
                    Name = "failureCount", ValueCST = ContainerStorageType.UInt64, VC = new ValueContainer(0L)
                };

                hGrp = new MDRFHistogramGroupSource("hPing_{0}".CheckedFormat(HostNameOrAddress),
                                                    h,
                                                    (ulong)config.AggregateGroupsFileIndexUserRowFlagBits,
                                                    extraClientNVS: new NamedValueSet()
                {
                    { "Ping" }, { "Host", HostNameOrAddress }, { "IPAddress", IPAddress.ToString() }
                },
                                                    extraGPISet: new[] { timeoutCountGPI, failureCountGPI });

                extraData = new byte[config.ExtraLength];

                responseTimeLimitInMSec = unchecked ((int)config.ResponseTimeLimit.TotalMilliseconds);
                responseWaitTimeLimit   = (config.ResponseTimeLimit.TotalSeconds + 0.25).FromSeconds();
            }