Exemple #1
0
	internal override void requestData(DataProcessor dproc) {
		if (backend == null) {
			dproc.AddDatasource(name, rrdPath, dsName, consolFun);
		}
		else {
			dproc.AddDatasource(name, rrdPath, dsName, consolFun, backend);
		}
	}
Exemple #2
0
		public void TestDataProcessor()
		{
			DateTime start = new DateTime(2012, 08, 22);

			RrdDef def = new RrdDef(SAMPLE, start.GetTimestamp(), 60);
			def.AddDatasource("speed",DataSourceType.COUNTER,120,double.NaN,double.NaN); // Step : every minute
			def.AddArchive(ConsolidationFunction.AVERAGE, 0, 5, 12 * 24 * 30);   // Archive average every 5 minutes during 30 days
			def.AddArchive(ConsolidationFunction.AVERAGE, 0, 5 * 12, 24 * 30);   // Archive average every hour during 30 days

			start = start.AddSeconds(40);
			using (RrdDb db = RrdDb.Create(def))
			{
				Sample sample = db.CreateSample();
				for (int i = 1; i < 60 * 24 * 3; i++) // add 3 days of samples
				{
					sample.Set(start.AddMinutes(i), 100 * i);
					sample.Update();
				}
			}

			DataProcessor dataProcessor = new DataProcessor(start.AddHours(3), start.AddHours(13));
			dataProcessor.FetchRequestResolution = 3600;
			dataProcessor.AddDatasource("speed", SAMPLE, "speed", ConsolidationFunction.AVERAGE);
			dataProcessor.AddDatasource("speedByHour", "speed, STEP, *");

			dataProcessor.ProcessData();

			double[] vals = dataProcessor.GetValues("speedByHour");
			Assert.AreEqual(12, vals.Length);
			for (int i = 0; i < vals.Length; i++)
			{
				Assert.AreEqual(6000,((int)vals[i]));
			}
		}
Exemple #3
0
	internal override void requestData(DataProcessor dproc)
	{
		dproc.AddDatasource(name, defName, consolFun);
	}
Exemple #4
0
	internal override void requestData(DataProcessor dproc) {
		dproc.AddDatasource(name, plottable);
	}
Exemple #5
0
		private DataProcessor CreateDataProcessor(String rpnExpression)
		{
			var dataProcessor = new DataProcessor(request.FetchStart, request.FetchEnd);
			foreach (String dsName in dsNames)
			{
				dataProcessor.AddDatasource(dsName, this);
			}
			if (rpnExpression != null)
			{
				dataProcessor.AddDatasource(RPN_SOURCE_NAME, rpnExpression);
				try
				{
					dataProcessor.ProcessData();
				}
				catch (IOException ioe)
				{
					// highly unlikely, since all datasources have already calculated values
					throw new InvalidOperationException("Impossible error: " + ioe);
				}
			}
			return dataProcessor;
		}