Esempio n. 1
0
        public override void GetStats(string fileName)
        {
            string query = String.Format("select distinct s-computername as ComputerName FROM {0}", fileName);
            LogRecordSet recordSet = null;
            try
            {
                
                LogQuery logQuery = new LogQuery();
                IISLogInputFormat iisInputFormat = new IISLogInputFormat();
                recordSet = logQuery.Execute(query, iisInputFormat);
                _machineName = recordSet.getRecord().getValue("ComputerName").ToString();

                outputlog = String.Format("{0}\\{1}_{2}_{3}_{4}", _directory, _machineName, logType, _fileprefix, ConfigurationManager.AppSettings["OutputFilename"]);
                ResetOutputFile();

                if (!File.Exists(fileName))
                {
                    throw new Exception("File not found");
                }
            }
            finally
            {
                if (recordSet != null)
                {
                    recordSet.close();
                    recordSet = null;
                }
            }

            //get ripley stats
            query = string.Format("SELECT STRCAT(  TO_STRING(date, 'yyyy-MM-dd '), TO_STRING( QUANTIZE( time, 3600 ), 'hh:mm:ss')  ) AS DateTime, " +
                        " s-computername as ComputerName, "  +
                        " cs-method as Method, " +
                        " sc-status as Status, " +
                        " TO_UPPERCASE(STRCAT( cs-uri-stem,  STRCAT('?', SUBSTR(cs-uri-query, 0, INDEX_OF(cs-uri-query,'?') ) ) ))  as URL," +
                        " count(*) as Count, " +
                        " MAX(time-taken) as Max, MIN(time-taken) as Min, AVG(time-taken) as Avg, " +
                        " TO_UPPERCASE(EXTRACT_VALUE(cs-uri-query, '_si')) as Site" +
                        " FROM {0} " +
                        " where TO_UPPERCASE(EXTRACT_EXTENSION( cs-uri-stem ))='DLL'" +
                        " group by DateTime, URL, Method, ComputerName, Site, Status", fileName);
            ProcessRecordset(query, fileName);


            query = string.Format("SELECT STRCAT(  TO_STRING(date, 'yyyy-MM-dd '), TO_STRING(QUANTIZE( time, 3600 ), 'hh:mm:ss')  ) AS DateTime, " +
                        " s-computername as ComputerName, " +
                        " cs-method as Method, " +
                        " sc-status as Status, " +
                        " TO_UPPERCASE( SUBSTR(cs-uri-stem, LAST_INDEX_OF(cs-uri-stem, '/')))  as URL, " +
                        " count(*) as Count, " +
                        " MAX(time-taken) as Max, MIN(time-taken) as Min, AVG(time-taken) as Avg, " +
                        " TO_UPPERCASE(EXTRACT_VALUE(cs-uri-query, '_si')) as Site" +
                        " FROM {0} " +
                        " where TO_UPPERCASE(EXTRACT_EXTENSION( cs-uri-stem ))='ASPX'" +
                        " group by DateTime, URL, Method, ComputerName, Site, Status", fileName);
            ProcessRecordset(query, fileName);
        }
Esempio n. 2
0
        protected override void ProcessRecordset(string query, string fileName)
        {
            using (StreamWriter stream = new StreamWriter(outputlog, true))
            {
                LogQuery logQuery = new LogQuery();
                
                COMTSVInputContextClassClass tsvInputFormat = new COMTSVInputContextClassClass();
                LogRecordSet recordSet = logQuery.Execute(query, tsvInputFormat);

                if (newOutput)
                {
                    stream.Write(String.Format("Date{0}Machine{1}Type{2}Instance{3}Counter{4}Value",delimiter,delimiter,delimiter,delimiter,delimiter));
                    stream.Write(stream.NewLine);
                    newOutput = false;
                }

                string[] counterTitles = new string[recordSet.getColumnCount()-3];
                int j = 0;
                for (int i = 3; i < recordSet.getColumnCount()-4; i++)
                {
                    string machine = "", type = "", instance = "", counter = "";
                    if(ParseCounter(recordSet.getColumnName(i), ref machine, ref type, ref instance, ref counter))
                    {
                        counterTitles[j] = String.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}",
                            "{0}", delimiter, machine, delimiter, type, delimiter, instance, delimiter, counter, delimiter, "{1}");
                    }
                    j++;
                }

                //read log file
                while (!recordSet.atEnd())
                {
                    j = 0;
                    for (int i = 3; i < recordSet.getColumnCount()-4; i++)
                    {
                        if (!String.IsNullOrEmpty(recordSet.getRecord().getValue(i).ToString().Replace("\"", "").Trim()))
                        {
                            DateTime date = DateTime.Parse(recordSet.getRecord().getValue(2).ToString().Replace("\"", ""));
                            string dateStr = date.ToString("yyyy-MM-dd hh:mm:ss");
                            string value = recordSet.getRecord().getValue(i).ToString().Replace("\"", "");
                            stream.WriteLine(String.Format(counterTitles[j], dateStr, value));
                            
                        }
                        j++;
                    }
                    
                    recordSet.moveNext();
                }
                stream.Flush();
                
            }
            ImportToDatabase();
        }
Esempio n. 3
0
        protected override void ProcessRecordset(string query, string fileName)
        {
            using (StreamWriter stream = new StreamWriter(outputlog, true))
            {
                LogQuery logQuery = new LogQuery();
                IISLogInputFormat iisInputFormat = new IISLogInputFormat();
                LogRecordSet recordSet = logQuery.Execute(query, iisInputFormat);

                if (newOutput)
                {
                    for (int i = 0; i < recordSet.getColumnCount(); i++)
                    {
                        stream.Write(recordSet.getColumnName(i) + delimiter);
                    }
                    newOutput = false;
                    stream.Write(stream.NewLine);
                }
                //read log file
                while (!recordSet.atEnd())
                {
                    DateTime logDate = DateTime.Parse(recordSet.getRecord().getValue("DateTime").ToString());
                    stream.WriteLine(recordSet.getRecord().toNativeString(delimiter));
                    stream.Flush();
                    ImportToDatabase(recordSet.getRecord(), logDate);
                    recordSet.moveNext();
                }
                recordSet.close();
                recordSet = null;
            }

        }