Esempio n. 1
0
        private string ExportMonitorStateEntryToSCV(MonitorState ms)
        {
            StringBuilder sb = new StringBuilder();

            if (ms != null)
            {
                sb.Append(ms.Timestamp.ToString("yyyy-MM-dd HH:mm:ss") + ",");
                sb.AppendFormat("\"{0}\",", Path.Replace("\"", "\"\"" + "\","));

                string displayValue     = ms.ReadPrimaryOrFirstUIValue(false);
                string displayValueUnit = ms.ReadFirstValueUnit();
                if (displayValue.IsNumber())
                {
                    sb.AppendFormat("{0},", displayValue);
                }
                else if (displayValue.Trim().Length > 0)
                {
                    sb.AppendFormat("\"{0}\",", displayValue.Replace("\"", "\"\""));
                }
                else
                {
                    sb.Append(",");
                }
                if (displayValueUnit.Trim().Length > 0)
                {
                    sb.AppendFormat("\"{0}\",", displayValueUnit.Replace("\"", "\"\""));
                }
                else
                {
                    sb.Append(",");
                }

                sb.AppendFormat("{0},", ms.State);
                sb.AppendFormat("{0},", ms.CallDurationMS);


                if (ms.ChildStates == null || ms.ChildStates.Count == 0)
                {
                    sb.AppendFormat("{0},", 0);
                }
                else
                {
                    int childStateCount = ms.ChildStates.ChildStateCount();
                    //if (childStateCount > 0)
                    //    childStateCount--;
                    sb.AppendFormat("{0},", childStateCount);
                }
                int[] stateMetrics = ms.GetStateMetrics();
                sb.AppendFormat("{0},", stateMetrics[0]);
                sb.AppendFormat("{0},", stateMetrics[1]);
                sb.AppendFormat("{0},", stateMetrics[2]);

                sb.AppendFormat("{0}", ms.AlertsRaised.Count);

                //sb.AppendFormat("{0},", ms.ExecutedOnHostComputer);
                //sb.AppendFormat("{0}", ms.RanAs);
                sb.AppendLine();
            }
            return(sb.ToString());
        }
Esempio n. 2
0
        private MonitorState FormatMonitorState(CollectorHost ch, MonitorState ms)
        {
            MonitorState displayMS     = ms.Clone();
            string       collectorPath = GetCollectorPath(ch);

            //foreach (CollectorHost pch in HostingMonitorPack.GetParentCollectorHostTree(ch))
            //{
            //    collectorPath = pch.Name + "/" + collectorPath;
            //}
            //displayMS.ForAgent = collectorPath + ch.Name;
            displayMS.ForAgent     = collectorPath; // ch.ApplyConfigVarsOnString(collectorPath);
            displayMS.CurrentValue = ms.ReadPrimaryOrFirstUIValue();
            displayMS.RawDetails   = ms.ReadAllRawDetails();
            return(displayMS);
        }