Beispiel #1
0
        /// <summary>
        /// Parse query result for a single value.
        /// </summary>
        /// <param name="scriptInstance">script reference</param>
        /// <param name="attributeNames">attribute</param>
        /// <param name="queryOutput">Output</param>
        private static void SingleValueHandler
            (WindowsOracleInstanceRealTimeScript scriptInstance, String attributeName, String queryOutput)
        {
            string        value   = null;
            StringBuilder logData = new StringBuilder();

            //
            // Never compile a regular expression is not assigned to
            // a static reference.  Otherwise you will leak an Assembly.
            Regex r = new Regex(@"^<BDNA>" + attributeName + @"<BDNA>(.*?)<BDNA>$");

            foreach (String line in queryOutput.Split('\n', '\r'))
            {
                if (r.IsMatch(line))
                {
                    value = matchFirstGroup(line, r);
                    logData.AppendFormat("{0}: {1}\n", attributeName, value);
                    break;
                }
            }
            Lib.Logger.TraceEvent(TraceEventType.Verbose,
                                  0,
                                  "Task Id {0}: Parse query results for attribute {1}:\n{2}",
                                  scriptInstance.m_taskId,
                                  attributeName,
                                  logData.ToString());
            if (!String.IsNullOrEmpty(value))
            {
                scriptInstance.BuildDataRow(attributeName, value);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Parse query result for tablespace size value.
        /// </summary>
        /// <param name="scriptInstance">script reference</param>
        /// <param name="attributeNames">attribute</param>
        /// <param name="queryOutput">Output</param>
        private static void TableSpaceSizesQueryHandler
            (WindowsOracleInstanceRealTimeScript scriptInstance, String attributeName, String queryOutput)
        {
            Regex         r       = new Regex(@"^<BDNA>TSSizes<BDNA>(.*?)<BDNA>(.*?)<BDNA>$");
            StringBuilder result  = new StringBuilder();
            StringBuilder logData = new StringBuilder();

            foreach (String line in queryOutput.Split('\n', '\r'))
            {
                if (r.IsMatch(line))
                {
                    Match match = r.Match(line);
                    if (match.Length > 1)
                    {
                        String tablespaceName = match.Groups[1].ToString();
                        String tablespaceSize = match.Groups[2].ToString();
                        if (result.Length > 0)
                        {
                            result.Append(BdnaDelimiters.DELIMITER_TAG);
                        }
                        result.Append(tablespaceName).Append(BdnaDelimiters.DELIMITER_TAG).Append(tablespaceSize);
                        logData.AppendFormat("{0}: {1}:{2}\n", attributeName, tablespaceSize, tablespaceSize);
                    }
                }
            }
            Lib.Logger.TraceEvent(TraceEventType.Verbose,
                                  0,
                                  "Task Id {0}: Parse query results for attribute {1}:\n{2}",
                                  scriptInstance.m_taskId,
                                  attributeName,
                                  logData.ToString());
            if (result.Length > 0)
            {
                scriptInstance.BuildDataRow(attributeName, result.ToString());
            }
        }