Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                var    nameValueCollection = (NameValueCollection)ConfigurationManager.GetSection("rrdbfileserver");
                string url = nameValueCollection["url"];

                rrdDbAccessInterface = new ServerAccessor(url);//"tcp://server:8100/GetRrdDbAdapter");
                //string channelName = context.Request.QueryString["c"];
                DateTime start = new DateTime(2005, 12, 19);
                DateTime end   = new DateTime(2006, 12, 12);
                //\Users\miknil\Documents\Visual Studio 2008\Projects\rrd4n\RRDConfigTool\
                string        databaseName = "car_day.rra";
                StringBuilder sb           = new StringBuilder();
                sb.AppendFormat("- --start \"{0}\" --end \"{1}\"", start.ToShortDateString(), end.ToShortDateString());
                sb.Append(" --imgformat PNG");
                sb.AppendFormat(" DEF:myruntime=\"{0}\":milage:AVERAGE", databaseName);
                sb.Append(" CDEF:mil=myruntime,86400,* LINE2:mil#FF0000 -w 800 -h 400 CDEF:km=myruntime,1000,*");
                sb.Append(" SDEF:value_sum=km,TOTAL  GPRINT:myruntime:TOTAL:\"usage {0}\"");
                GraphParser parser   = new GraphParser(sb.ToString());
                RrdGraphDef graphDef = parser.CreateGraphDef();

                RrdGraph     graph_1 = new RrdGraph(graphDef, rrdDbAccessInterface);
                RrdGraphInfo info    = graph_1.getRrdGraphInfo();
                MemoryStream ms      = new MemoryStream(info.getBytes());

                context.Response.ContentType = "image/png";
                context.Response.BinaryWrite(ms.ToArray());
            }
            catch (Exception ex)
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write(ex.Message);
            }
        }
Example #2
0
        public void ShowGraph(RrdGraphDef graphDef)
        {
            RrdGraph     graph_1 = new RrdGraph(graphDef, dbAccess);
            RrdGraphInfo info    = graph_1.getRrdGraphInfo();

            if (info.getByteCount() == 0)
            {
                return;
            }
            MemoryStream ms = new MemoryStream(info.getBytes());

            view.SetImge(ms);
        }
Example #3
0
            private void UpdateImageOne(CoCEnum.EventNotify id, CoCEnum.RrdGrapPeriod pr, CultureInfo ci)
            {
                string path1Db = String.Empty,
                       path2Db = String.Empty,
                       pathImg = String.Empty;

                switch (id)
                {
                case CoCEnum.EventNotify.MemberChangeDonationReceive:
                {
                    return;
                }

                case CoCEnum.EventNotify.ClanChangeWarWin:
                {
                    if (pr == CoCEnum.RrdGrapPeriod.Day)
                    {
                        return;
                    }
                    break;
                }

                case CoCEnum.EventNotify.MemberChangeDonationSend:
                {
                    path2Db = CoCRrdUtil.getRrdDbPath(CoCEnum.EventNotify.MemberChangeDonationReceive, this._parent._rootpath);
                    if ((string.IsNullOrWhiteSpace(path2Db)) || (!File.Exists(path2Db)))
                    {
                        return;
                    }
                    break;
                }
                }

                path1Db = CoCRrdUtil.getRrdDbPath(id, this._parent._rootpath);
                if ((string.IsNullOrWhiteSpace(path1Db)) || (!File.Exists(path1Db)))
                {
                    return;
                }
                pathImg = CoCRrdUtil.getRrdFileImgPath(id, pr, this._parent._rootpath, this._parent._assetspath);
                if (string.IsNullOrWhiteSpace(pathImg))
                {
                    return;
                }

                long     dtstart, dtend;
                TimeSpan tsoffset = TimeSpan.MinValue;

                switch (pr)
                {
                case CoCEnum.RrdGrapPeriod.Day:
                {
                    tsoffset = new TimeSpan(1, 0, 0, 0, 0);
                    break;
                }

                case CoCEnum.RrdGrapPeriod.Week:
                {
                    tsoffset = new TimeSpan(7, 0, 0, 0, 0);
                    break;
                }

                case CoCEnum.RrdGrapPeriod.Month:
                {
                    tsoffset = new TimeSpan(30, 0, 0, 0, 0);
                    break;
                }

                case CoCEnum.RrdGrapPeriod.Year:
                {
                    tsoffset = new TimeSpan(365, 0, 0, 0, 0);
                    break;
                }
                }

                dtstart = CoCRrdUtil.getUnixTimeStamp(DateTime.Now.Subtract(tsoffset));
                dtend   = CoCRrdUtil.getUnixTimeStamp(DateTime.Now);

                RrdGraphDef graphDef = null;

                try
                {
                    graphDef = new RrdGraphDef();
                    graphDef.SetTimePeriod(dtstart, dtend);
                    graphDef.ShowSignature = false;
                    graphDef.AntiAliasing  = true;
                    graphDef.SetImageBorder(Color.White, 0);
                    graphDef.VerticalLabel = (string)Properties.Resources.ResourceManager.GetString("fmtRrd" + id.ToString() + "Vlabel", ci);

                    switch (id)
                    {
                    case CoCEnum.EventNotify.MemberChangeDonationSend:
                    {
                        graphDef.Title = string.Format(
                            "{0} / {1} ({2})",
                            (string)Properties.Resources.ResourceManager.GetString("fmtRrdMemberChangeDonationSendTitle", ci),
                            (string)Properties.Resources.ResourceManager.GetString("fmtRrdMemberChangeDonationReceiveTitle", ci),
                            (string)Properties.Resources.ResourceManager.GetString("RrdPeriodName" + pr.ToString(), ci)
                            );
                        graphDef.BackgroundResource = Properties.Resources.RrdBgMemberChangeDonationSend;
                        graphDef.Datasource("ida", path1Db, "a", "AVERAGE");
                        graphDef.Datasource("idb", path2Db, "a", "AVERAGE");
                        graphDef.Line("ida", SysDraw.Color.Lime, (string)Properties.Resources.ResourceManager.GetString("fmtRrdMemberChangeDonationSendTitle", ci), 4);
                        graphDef.Line("idb", SysDraw.Color.Red, (string)Properties.Resources.ResourceManager.GetString("fmtRrdMemberChangeDonationReceiveTitle", ci), 2);
                        graphDef.Gprint("ida", "MAX", (string)Properties.Resources.ResourceManager.GetString("fmtRrdMemberChangeDonationSendMax", ci));
                        //graphDef.Gprint("ida", "MIN", (string)Properties.Resources.ResourceManager.GetString("fmtRrdMemberChangeDonationSendMin", ci));
                        graphDef.Gprint("idb", "MAX", (string)Properties.Resources.ResourceManager.GetString("fmtRrdMemberChangeDonationReceiveMax", ci));
                        //graphDef.Gprint("idb", "MIN", (string)Properties.Resources.ResourceManager.GetString("fmtRrdMemberChangeDonationReceiveMin, ci"));
                        break;
                    }

                    case CoCEnum.EventNotify.ClanChangePoints:
                    {
                        graphDef.Title = string.Format(
                            "{0} ({1})",
                            (string)Properties.Resources.ResourceManager.GetString("fmtRrd" + id.ToString() + "Title", ci),
                            (string)Properties.Resources.ResourceManager.GetString("RrdPeriodName" + pr.ToString(), ci)
                            );
                        graphDef.BackgroundResource = Properties.Resources.RrdBgClanChangePoints;
                        graphDef.Datasource("ida", path1Db, "a", "AVERAGE");
                        graphDef.Line("ida", SysDraw.Color.Red, (string)Properties.Resources.ResourceManager.GetString("fmtRrd" + id.ToString() + "Title", ci), 2);
                        graphDef.Gprint("ida", "MAX", (string)Properties.Resources.ResourceManager.GetString("fmtRrd" + id.ToString() + "Max", ci));
                        graphDef.Gprint("ida", "MIN", (string)Properties.Resources.ResourceManager.GetString("fmtRrd" + id.ToString() + "Min", ci));
                        break;
                    }

                    case CoCEnum.EventNotify.ClanChangeWarWin:
                    {
                        graphDef.Title = string.Format(
                            "{0} ({1})",
                            (string)Properties.Resources.ResourceManager.GetString("fmtRrd" + id.ToString() + "Title", ci),
                            (string)Properties.Resources.ResourceManager.GetString("RrdPeriodName" + pr.ToString(), ci)
                            );
                        graphDef.BackgroundResource = Properties.Resources.RrdBgClanChangeWarWin;
                        graphDef.Datasource("ida", path1Db, "a", "AVERAGE");
                        graphDef.Line("ida", SysDraw.Color.Red, (string)Properties.Resources.ResourceManager.GetString("fmtRrd" + id.ToString() + "Title", ci), 2);
                        graphDef.Gprint("ida", "MAX", (string)Properties.Resources.ResourceManager.GetString("fmtRrd" + id.ToString() + "Max", ci));
                        graphDef.Gprint("ida", "MIN", (string)Properties.Resources.ResourceManager.GetString("fmtRrd" + id.ToString() + "Min", ci));
                        break;
                    }

                    default:
                    {
                        return;
                    }
                    }

                    RrdGraph graph = new RrdGraph(graphDef);
                    graph.SaveAsPNG(pathImg, 760, 200);
                }
                catch (Exception e)
                {
                    if (this._parent.isLogEnable)
                    {
                        this._parent._ilog.LogError(e.Message);
                    }
                }
            }
Example #4
0
        static void Main(string[] args)
        {
            DateTime EPOC = new DateTime(1970, 01, 1);
            long     startTimeInSeconds = 920804400;
            DateTime startTime          = EPOC.AddSeconds(startTimeInSeconds);
            long     endTimeInSeconds   = 920808000;
            string   rrdPath            = @"net_test.rrd";
            String   imgPath            = @"net_test.png";

            Console.WriteLine("== Starting demo");

            RrdDb        rrdDb;
            FetchRequest request;
            FetchData    fetchData;


            //List<FetchedData> unified = ReadAndUnifyData(@"C:\Development\CS_Project\rrd4n\RrDbTest\el.csv",
            //                                             new TimeSpan(0, 10, 0));

            bool createDb = true;

            if (createDb)
            {
                rrdDb = BuildRRd(rrdPath, startTime);
                Console.WriteLine(rrdDb.dump());
                rrdDb.close();
                //rrdDb = new RrdDb(rrdPath, false);

                int[] values = new int[] {
                    12345, 12357, 12363, 12363, 12363, 12373, 12383, 12393, 12399, 12405, 12411, 12415, 12420, 12422, 12423
                };

                //rrdtool update net_test.rrd 920804700:12345 920805000:12357 920805300:12363
                //rrdtool update net_test.rrd 920805600:12363 920805900:12363 920806200:12373
                //rrdtool update net_test.rrd 920806500:12383 920806800:12393 920807100:12399
                //rrdtool update net_test.rrd 920807400:12405 920807700:12411 920808000:12415
                //rrdtool update net_test.rrd 920808300:12420 920808600:12422 920808900:12423

                for (int i = 0; i < 15; i++)
                {
                    UpdateRRd(rrdPath, 920804700 + (i * 300), "speed", values[i]);
                }
                //rrdDb.close();

                // Read back test
                rrdDb = new RrdDb(rrdPath, true);
                Console.WriteLine("File reopen in read-only mode");
                Console.WriteLine("== Last update time was: " + rrdDb.getLastUpdateTime());
                Console.WriteLine("== Last info was: " + rrdDb.getInfo());

                // fetch data
                Console.WriteLine("== Fetching data");
                request = rrdDb.createFetchRequest(new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE), startTimeInSeconds, endTimeInSeconds);
                Console.WriteLine(request.dump());
                fetchData = rrdDb.fetchData(request);
                Console.WriteLine("== Data fetched. " + fetchData.getRowCount() + " points obtained");
                Console.WriteLine(fetchData.toString());
                Console.WriteLine("== Fetch completed");
            }


            DateTime startDateTime = rrd4n.Common.Util.getDate(920804400);
            DateTime endDateTime   = rrd4n.Common.Util.getDate(920808000);

            GraphParser parser = new GraphParser("net_speed_1.png --start \"" + startDateTime.ToString() + "\" --end \"" + endDateTime.ToString() + "\" --imgformat PNG DEF:myspeed=" + rrdPath + ":speed:AVERAGE LINE2:myspeed#FF0000");
            RrdGraphDef gDef_1 = parser.CreateGraphDef();

            RrdDbAccessInterface rrdDbAccess = container["databaseaccessor.local"] as RrdDbAccessInterface;
            RrdGraph             graph_1     = new RrdGraph(gDef_1, rrdDbAccess);

            // Create graph
            // rrdtool graph net_speed.png --start 920804400 --end 920808000
            //  DEF:myspeed=net_test.rrd:speed:AVERAGE
            //  LINE2:myspeed#FF0000
            //  --font "DEFAULT:0:C:\Windows\fonts\cour.ttf"
            Console.WriteLine("Creating graph ");
            RrdGraphDef gDef = new RrdGraphDef();

            gDef.setWidth(IMG_WIDTH);
            gDef.setHeight(IMG_HEIGHT);
            gDef.setFilename(imgPath);
            gDef.setStartTime(startTimeInSeconds);
            gDef.setEndTime(endTimeInSeconds);
            gDef.setTitle("Speed");
            //            gDef.setVerticalLabel("temperature");
            gDef.datasource("myspeed", rrdPath, "speed", new rrd4n.Common.ConsolFun(rrd4n.Common.ConsolFun.ConsolFunTypes.AVERAGE));
            gDef.line("myspeed", Color.Red, "My sPeedj", 2);
            gDef.hrule(0.02, Color.Red, "Maximum 200", 3);

            //            gDef.print("shade", new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE), "avgShade = %.3f%S\\r");
            //            gDef.setImageInfo("<img src='%s' width='%d' height = '%d'>");
            gDef.setPoolUsed(false);
            gDef.setImageFormat("png");
            //Console.WriteLine("Rendering graph " + rrd4n.Common.Util.getLapTime());
            // create graph finally
            RrdGraph graph = new RrdGraph(gDef, rrdDbAccess);

            // Create bar chart test graph
            //rrdtool graph speed3.png --start 920804400 --end 920808000 --vertical-label km/h DEF:myspeed=test.rrd:speed:AVERAGE "CDEF:kmh=myspeed,3600,*" CDEF:fast=kmh,100,GT,kmh,0,IF CDEF:good=kmh,100,GT,0,kmh,IF HRULE:100#0000FF:"Maximum allowed" AREA:good#00FF00:"Good speed" AREA:fast#FF0000:"Too fast" --font "DEFAULT:0:C:\Windows\fonts\cour.ttf"
            imgPath = @"net_test_bar.png";

            Console.WriteLine("Creating bar graph ");
            gDef = new RrdGraphDef();
            gDef.setWidth(IMG_WIDTH);
            gDef.setHeight(IMG_HEIGHT);
            gDef.setFilename(imgPath);
            gDef.setStartTime(startTimeInSeconds);
            gDef.setEndTime(endTimeInSeconds + 900);
            gDef.setTitle("Speed");
            gDef.setVerticalLabel("km/h");
            //DEF:myspeed=test.rrd:speed:AVERAGE
            gDef.datasource("myspeed", rrdPath, "speed", new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE));
            //"CDEF:kmh=myspeed,3600,*"
            gDef.datasource("kmh", "myspeed,3600,*");
            //CDEF:fast=kmh,100,GT,kmh,0,IF
            gDef.datasource("fast", "kmh,100,GT,kmh,0,IF");
            //CDEF:good=kmh,100,GT,0,kmh,IF HRULE:100#0000FF:"Maximum allowed" AREA:good#00FF00:"Good speed" AREA:fast#FF0000:"Too fast"
            gDef.datasource("good", "kmh,100,GT,0,kmh,IF");
            //HRULE:100#0000FF:"Maximum allowed"
            gDef.hrule(100, Color.Red, "Maximum allowed", 3);
            gDef.hrule(200, Color.Red, "Maximum 200", 3);
            // AREA:good#00FF00:"Good speed"
            gDef.area("good", Color.Green, "Good speed");
            // AREA:fast#FF0000:"Too fast"
            gDef.area("fast", Color.Red, "Too fast");
            gDef.setPoolUsed(false);
            gDef.setImageFormat("png");
            //Console.WriteLine("Rendering graph " + Util.getLapTime());
            // create graph finally
            graph = new RrdGraph(gDef, rrdDbAccess);

            //rrdtool graph speed4.png --start 920804400 --end 920808000 --vertical-label km/h DEF:myspeed=test.rrd:speed:AVERAGE CDEF:nonans=myspeed,UN,0,myspeed,IF CDEF:kmh=nonans,3600,* CDEF:fast=kmh,100,GT,100,0,IF CDEF:over=kmh,100,GT,kmh,100,-,0,IF CDEF:good=kmh,100,GT,0,kmh,IF HRULE:100#0000FF:"Maximum allowed" AREA:good#00FF00:"Good speed" AREA:fast#550000:"Too fast"  STACK:over#FF0000:"Over speed" --font "DEFAULT:0:C:\Windows\fonts\cour.ttf"
            Console.WriteLine("Creating stack graph ");
            imgPath = @"net_test_stack.png";
            gDef    = new RrdGraphDef();
            gDef.setWidth(IMG_WIDTH);
            gDef.setHeight(IMG_HEIGHT);
            gDef.setFilename(imgPath);
            gDef.setStartTime(startTimeInSeconds + 300);
            gDef.setEndTime(endTimeInSeconds + 1200);
            gDef.setTitle("Speed");
            //--vertical-label km/h
            gDef.setVerticalLabel("km/h");
            // DEF:myspeed=test.rrd:speed:AVERAGE
            gDef.datasource("myspeed", rrdPath, "speed", new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE));
            // CDEF:nonans=myspeed,UN,0,myspeed,IF
            gDef.datasource("nonans", "myspeed,UN,0,myspeed,IF");
            //CDEF:kmh=nonans,3600,*
            gDef.datasource("kmh", "nonans,3600,*");
            //CDEF:fast=kmh,100,GT,100,0,IF
            gDef.datasource("fast", "kmh,100,GT,100,0,IF");
            //CDEF:over=kmh,100,GT,kmh,100,-,0,IF
            gDef.datasource("over", "kmh,100,GT,kmh,100,-,0,IF");
            //CDEF:good=kmh,100,GT,0,kmh,IF
            gDef.datasource("good", "kmh,100,GT,0,kmh,IF");
            //HRULE:100#0000FF:"Maximum allowed"
            gDef.hrule(100, Color.Blue, "Maximum allowed", 3);
            // AREA:good#00FF00:"Good speed"
            gDef.area("good", Color.Green, "Good speed");
            // AREA:fast#550000:"Too fast"
            gDef.area("fast", Color.Black, "Too fast");
            //STACK:over#FF0000:"Over speed"
            gDef.stack("over", Color.Red, "Over speed");

            gDef.setPoolUsed(false);
            gDef.setImageFormat("png");
            //Console.WriteLine("Rendering graph " + Util.getLapTime());
            // create graph finally
            graph = new RrdGraph(gDef, rrdDbAccess);



            long startMillis = DateTime.Now.Millisecond;

            return;
            //if (args.Length > 0)
            //{
            //   Console.WriteLine("Setting default backend factory to " + args[0]);
            //   RrdDb.setDefaultFactory(args[0]);
            //}
            //long start = START;
            //long end = END;
            ////rrdPath = Util.getRrd4nDemoPath(FILE + ".rrd");
            ////String xmlPath = Util.getRrd4nDemoPath(FILE + ".xml");
            ////String rrdRestoredPath = Util.getRrd4nDemoPath(FILE + "_restored.rrd");
            ////imgPath = Util.getRrd4nDemoPath(FILE + ".png");
            ////String logPath = Util.getRrd4nDemoPath(FILE + ".log");
            ////PrintWriter log = new PrintWriter(new BufferedOutputStream(new FileOutputStream(logPath, false)));
            //// creation
            ////Console.WriteLine("== Creating RRD file " + rrdPath);
            ////RrdDef rrdDef = new RrdDef(rrdPath, start - 1, 300);
            ////rrdDef.addDatasource("sun", new DsType(DsType.DsTypes.GAUGE), 600, 0, Double.NaN);
            ////rrdDef.addDatasource("shade", new DsType(DsType.DsTypes.GAUGE), 600, 0, Double.NaN);
            ////rrdDef.addArchive(new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE), 0.5, 1, 600);
            ////rrdDef.addArchive(new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE), 0.5, 6, 700);
            ////rrdDef.addArchive(new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE), 0.5, 24, 775);
            ////rrdDef.addArchive(new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE), 0.5, 288, 797);
            ////rrdDef.addArchive(new ConsolFun(ConsolFun.ConsolFunTypes.MAX), 0.5, 1, 600);
            ////rrdDef.addArchive(new ConsolFun(ConsolFun.ConsolFunTypes.MAX), 0.5, 6, 700);
            ////rrdDef.addArchive(new ConsolFun(ConsolFun.ConsolFunTypes.MAX), 0.5, 24, 775);
            ////rrdDef.addArchive(new ConsolFun(ConsolFun.ConsolFunTypes.MAX), 0.5, 288, 797);
            ////Console.WriteLine(rrdDef.dump());
            //////log.Console.WriteLine(rrdDef.dump());
            ////Console.WriteLine("Estimated file size: " + rrdDef.getEstimatedSize());
            ////RrdDb rrdDb = new RrdDb(rrdDef);
            ////Console.WriteLine("== RRD file created.");
            ////if (rrdDb.getRrdDef().equals(rrdDef))
            ////{
            ////    Console.WriteLine("Checking RRD file structure... OK");
            ////}
            ////else
            ////{
            ////    Console.WriteLine("Invalid RRD file created. This is a serious bug, bailing out");
            ////    return;
            ////}
            ////rrdDb.close();
            ////Console.WriteLine("== RRD file closed.");

            ////// update database
            ////GaugeSource sunSource = new GaugeSource(1200, 20);
            ////GaugeSource shadeSource = new GaugeSource(300, 10);
            ////Console.WriteLine("== Simulating one month of RRD file updates with step not larger than " +
            ////        MAX_STEP + " seconds (* denotes 1000 updates)");
            ////long t = start;
            ////int n = 0;
            ////rrdDb = new RrdDb(rrdPath);
            ////Sample sample = rrdDb.createSample();

            ////while (t <= end + 86400L)
            ////{
            ////    sample.setTime(t);
            ////    sample.setValue("sun", sunSource.getValue());
            ////    sample.setValue("shade", shadeSource.getValue());
            ////    //log.Console.WriteLine(sample.dump());
            ////    sample.update();
            ////    t += (long)(RANDOM.NextDouble() * MAX_STEP) + 1;
            ////    if (((++n) % 1000) == 0)
            ////    {
            ////        Console.Write("*");
            ////    }
            ////}

            ////rrdDb.close();

            ////Console.WriteLine("");
            ////Console.WriteLine("== Finished. RRD file updated " + n + " times");

            //// test read-only access!
            //rrdDb = new RrdDb(rrdPath, true);
            //Console.WriteLine("File reopen in read-only mode");
            //Console.WriteLine("== Last update time was: " + rrdDb.getLastUpdateTime());
            //Console.WriteLine("== Last info was: " + rrdDb.getInfo());

            //// fetch data
            //Console.WriteLine("== Fetching data for the whole month");
            //request = rrdDb.createFetchRequest(new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE), start, end);
            //Console.WriteLine(request.dump());
            ////  log.Console.WriteLine(request.dump());
            //fetchData = request.fetchData();
            //Console.WriteLine("== Data fetched. " + fetchData.getRowCount() + " points obtained");
            //Console.WriteLine(fetchData.toString());
            //Console.WriteLine("== Dumping fetched data to XML format");
            ////  Console.WriteLine(fetchData.exportXml());
            //Console.WriteLine("== Fetch completed");

            //// dump to XML file
            //Console.WriteLine("== Dumping RRD file to XML file " + xmlPath + " (can be restored with RRDTool)");
            ////  rrdDb.exportXml(xmlPath);
            //Console.WriteLine("== Creating RRD file " + rrdRestoredPath + " from XML file " + xmlPath);
            ////  RrdDb rrdRestoredDb = new RrdDb(rrdRestoredPath, xmlPath);

            //// close files
            //Console.WriteLine("== Closing both RRD files");
            //rrdDb.close();
            //Console.WriteLine("== First file closed");
            ////  rrdRestoredDb.close();
            //Console.WriteLine("== Second file closed");

            //// create graph
            //Console.WriteLine("Creating graph " + Util.getLapTime());
            //Console.WriteLine("== Creating graph from the second file");
            //gDef = new RrdGraphDef();
            //gDef.setWidth(IMG_WIDTH);
            //gDef.setHeight(IMG_HEIGHT);
            //gDef.setFilename(imgPath);
            //gDef.setStartTime(start);
            //gDef.setEndTime(end);
            //gDef.setTitle("Temperatures in May 2003");
            //gDef.setVerticalLabel("temperature");
            //gDef.datasource("sun", rrdPath/*rrdRestoredPath*/, "sun", new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE));
            //gDef.datasource("shade", rrdPath/*rrdRestoredPath*/, "shade", new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE));
            //gDef.datasource("median", "sun,shade,+,2,/");
            //gDef.datasource("diff", "sun,shade,-,ABS,-1,*");
            //gDef.datasource("sine", "TIME," + start + ",-," + (end - start) +
            //        ",/,2,PI,*,*,SIN,1000,*");
            //gDef.line("sun", Color.Green, "sun temp");
            //gDef.line("shade", Color.Blue, "shade temp");
            //gDef.line("median", Color.Magenta, "median value");
            //gDef.area("diff", Color.Yellow, "difference\\r");
            //gDef.line("diff", Color.Red, null);
            //gDef.line("sine", Color.Cyan, "sine function demo\\r");
            //gDef.hrule(2568, Color.Green, "hrule");
            //gDef.vrule((start + 2 * end) / 3, Color.Magenta, "vrule\\r");
            //gDef.gprint("sun", new ConsolFun(ConsolFun.ConsolFunTypes.MAX), "maxSun = %.3f%s");
            //gDef.gprint("sun", new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE), "avgSun = %.3f%S\\r");
            //gDef.gprint("shade", new ConsolFun(ConsolFun.ConsolFunTypes.MAX), "maxShade = %.3f%S");
            //gDef.gprint("shade", new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE), "avgShade = %.3f%S\\r");
            //gDef.print("sun", new ConsolFun(ConsolFun.ConsolFunTypes.MAX), "maxSun = %.3f%s");
            //gDef.print("sun", new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE), "avgSun = %.3f%S\\r");
            //gDef.print("shade", new ConsolFun(ConsolFun.ConsolFunTypes.MAX), "maxShade = %.3f%S");
            //gDef.print("shade", new ConsolFun(ConsolFun.ConsolFunTypes.AVERAGE), "avgShade = %.3f%S\\r");
            //gDef.setImageInfo("<img src='%s' width='%d' height = '%d'>");
            //gDef.setPoolUsed(false);
            //gDef.setImageFormat("png");
            //Console.WriteLine("Rendering graph " + Util.getLapTime());
            //// create graph finally
            //graph = new RrdGraph(gDef);

            //Console.WriteLine(graph.getRrdGraphInfo().dump());
            //Console.WriteLine("== Graph created " + Util.getLapTime());
            //// locks info
            ////Console.WriteLine("== Locks info ==");
            ////Console.WriteLine(RrdSafeFileBackend.getLockInfo());
            //// demo ends
            ////log.close();
            //Console.WriteLine("== Demo completed in " +
            //        ((DateTime.Now.Millisecond - startMillis) / 1000.0) + " sec");
        }