From 0a434b732f8cb09367c46d7d2ed594463fe2056b Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 28 May 2020 23:21:20 +0000 Subject: [PATCH] --- .../generator/CoreJobMetricsSnapshot.cs | 31 +++++++++---------- server/AyaNova/models/AyContext.cs | 2 ++ server/AyaNova/models/MetricMM.cs | 2 +- server/AyaNova/util/AySchema.cs | 4 +++ server/AyaNova/util/FileUtil.cs | 8 ++--- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/server/AyaNova/generator/CoreJobMetricsSnapshot.cs b/server/AyaNova/generator/CoreJobMetricsSnapshot.cs index b3cc2776..d977b100 100644 --- a/server/AyaNova/generator/CoreJobMetricsSnapshot.cs +++ b/server/AyaNova/generator/CoreJobMetricsSnapshot.cs @@ -24,20 +24,21 @@ namespace AyaNova.Biz private static double _cpu = 0; #if(DEBUG) - private static TimeSpan tsOneMinute = new TimeSpan(0, 1, 0); + private static TimeSpan tsOneMinute = new TimeSpan(0, 0, 10); + private static TimeSpan tsOneHour = new TimeSpan(0, 1, 0); + private static TimeSpan ts24Hours = new TimeSpan(0, 1, 0); #else private static TimeSpan tsOneMinute = new TimeSpan(0, 1, 0); -#endif private static TimeSpan tsOneHour = new TimeSpan(1, 0, 0); private static TimeSpan ts24Hours = new TimeSpan(24, 0, 0); - +#endif //////////////////////////////////////////////////////////////////////////////////////////////// // DoAsync // public static void DoJob() { - + //Nothing is gathered less than one minute frequency if (!DateUtil.IsAfterDuration(_lastSnapshot, tsOneMinute)) return; @@ -143,17 +144,18 @@ namespace AyaNova.Biz if (DateUtil.IsAfterDuration(_lastSnapshot, ts24Hours)) { //FILES ON DISK - // log.LogTrace("Files on disk information"); - // var UtilFilesInfo = FileUtil.GetUtilityFolderSizeInfo(); - // var UserFilesInfo = FileUtil.GetAttachmentFolderSizeInfo(); + var UtilFilesInfo = FileUtil.GetUtilityFolderSizeInfo(); + var AttachmentFilesInfo = FileUtil.GetAttachmentFolderSizeInfo(); + using (AyContext ct = ServiceProviderProvider.DBContext) + { + //write to db + MetricDD dd = new MetricDD(AttachmentFilesInfo.SizeWithChildren, AttachmentFilesInfo.FileCountWithChildren, UtilFilesInfo.SizeWithChildren, UtilFilesInfo.FileCountWithChildren); + ct.MetricDD.Add(dd); + ct.SaveChanges(); + } + - // var mtag = new MetricTags("File type", "Business object files"); - // metrics.Measure.Gauge.SetValue(MetricsRegistry.FileCountGauge, mtag, UserFilesInfo.FileCountWithChildren); - // metrics.Measure.Gauge.SetValue(MetricsRegistry.FileSizeGauge, mtag, UserFilesInfo.SizeWithChildren); - // mtag = new MetricTags("File type", "OPS files"); - // metrics.Measure.Gauge.SetValue(MetricsRegistry.FileCountGauge, mtag, UtilFilesInfo.FileCountWithChildren); - // metrics.Measure.Gauge.SetValue(MetricsRegistry.FileSizeGauge, mtag, UtilFilesInfo.SizeWithChildren); ///////////////////////////////// //CLEAR OLD ENTRIES @@ -170,7 +172,6 @@ namespace AyaNova.Biz _lastSnapshot = now; - } @@ -180,7 +181,5 @@ namespace AyaNova.Biz ///////////////////////////////////////////////////////////////////// }//eoc - - }//eons diff --git a/server/AyaNova/models/AyContext.cs b/server/AyaNova/models/AyContext.cs index a94f271e..32bed4ff 100644 --- a/server/AyaNova/models/AyContext.cs +++ b/server/AyaNova/models/AyContext.cs @@ -6,6 +6,8 @@ namespace AyaNova.Models public partial class AyContext : DbContext { public virtual DbSet MetricMM { get; set; } + public virtual DbSet MetricHH { get; set; } + public virtual DbSet MetricDD { get; set; } public virtual DbSet User { get; set; } public virtual DbSet UserOptions { get; set; } public virtual DbSet Widget { get; set; } diff --git a/server/AyaNova/models/MetricMM.cs b/server/AyaNova/models/MetricMM.cs index 8093d43c..a87d508c 100644 --- a/server/AyaNova/models/MetricMM.cs +++ b/server/AyaNova/models/MetricMM.cs @@ -20,7 +20,7 @@ namespace AyaNova.Models public int Gen2 { get; set; } public double CPU { get; set; } - //ef core requires this for some reason + //ef core requires this public MetricMM() { } public MetricMM(long allocated, long workingSet, long privateBytes, int gen0, int gen1, int gen2, double cpu) diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index a56e74f0..17b6b80b 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -249,6 +249,10 @@ namespace AyaNova.Util //METRICS TABLES //One minute metrics await ExecQueryAsync("CREATE TABLE ametricmm (t timestamp not null, allocated bigint,workingset bigint,privatebytes bigint,gen0 integer,gen1 integer,gen2 integer,cpu double precision)"); +//One hour metrics + await ExecQueryAsync("CREATE TABLE ametrichh (t timestamp not null, allocated bigint,)"); +//One day metrics + await ExecQueryAsync("CREATE TABLE ametricdd (t timestamp not null, allocated bigint,workingset bigint,privatebytes bigint,gen0 integer,gen1 integer,gen2 integer,cpu double precision)"); //SEARCH TABLES diff --git a/server/AyaNova/util/FileUtil.cs b/server/AyaNova/util/FileUtil.cs index 244a0964..9e131343 100644 --- a/server/AyaNova/util/FileUtil.cs +++ b/server/AyaNova/util/FileUtil.cs @@ -653,10 +653,10 @@ namespace AyaNova.Util public DirectoryInfo Path { get; set; } public long SizeWithChildren { get; set; } public long Size { get; set; } - public int DirectoryCount { get; set; } - public int DirectoryCountWithChildren { get; set; } - public int FileCount { get; set; } - public int FileCountWithChildren { get; set; } + public long DirectoryCount { get; set; } + public long DirectoryCountWithChildren { get; set; } + public long FileCount { get; set; } + public long FileCountWithChildren { get; set; } public List Children { get; set; } }