This commit is contained in:
@@ -20,20 +20,17 @@ namespace AyaNova.Biz
|
||||
private static Process _process = Process.GetCurrentProcess();
|
||||
|
||||
private static TimeSpan _oldCPUTime = TimeSpan.Zero;
|
||||
private static DateTime _lastMMSnapshot = DateTime.UtcNow;
|
||||
private static DateTime _lastHHSnapshot = DateTime.UtcNow;
|
||||
private static DateTime _lastMMSnapshot = DateTime.UtcNow;
|
||||
private static DateTime _lastDDSnapshot = DateTime.UtcNow;
|
||||
|
||||
// private static DateTime _lastRpsTime = DateTime.UtcNow;
|
||||
private static double _cpu = 0;
|
||||
|
||||
#if(DEBUG)
|
||||
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);
|
||||
private static TimeSpan tsOneMinute = new TimeSpan(0, 1, 0);
|
||||
private static TimeSpan ts24Hours = new TimeSpan(24, 0, 0);
|
||||
#else
|
||||
private static TimeSpan tsOneMinute = new TimeSpan(0, 1, 0);
|
||||
private static TimeSpan tsOneHour = new TimeSpan(1, 0, 0);
|
||||
private static TimeSpan tsOneMinute = new TimeSpan(0, 1, 0);
|
||||
private static TimeSpan ts24Hours = new TimeSpan(24, 0, 0);
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -71,15 +68,7 @@ namespace AyaNova.Biz
|
||||
// cannot be shared with other processes.
|
||||
var PrivateBytes = _process.PrivateMemorySize64;//bigint
|
||||
|
||||
// The number of generation 0 collections
|
||||
var Gen0 = GC.CollectionCount(0);//integer
|
||||
|
||||
// The number of generation 1 collections
|
||||
var Gen1 = GC.CollectionCount(1);//integer
|
||||
|
||||
// The number of generation 2 collections
|
||||
var Gen2 = GC.CollectionCount(2);//integer
|
||||
|
||||
|
||||
//NOTE: CPU percentage is *our* process cpu percentage over timeframe of last captured avg
|
||||
//So it does *not* show the entire server cpu load, only for RAVEN.
|
||||
//Overall, server stats need to be captured / viewed independently (digital ocean control panel for example or windows task manager)
|
||||
@@ -93,59 +82,15 @@ namespace AyaNova.Biz
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
//write to db
|
||||
MetricMM mm = new MetricMM(Allocated, WorkingSet, PrivateBytes, Gen0, Gen1, Gen2, CPU);
|
||||
MetricMM mm = new MetricMM(Allocated, WorkingSet, PrivateBytes, CPU);
|
||||
ct.MetricMM.Add(mm);
|
||||
ct.SaveChanges();
|
||||
//System.Diagnostics.Debug.WriteLine("MM SAVED");
|
||||
}
|
||||
_lastMMSnapshot = now;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
//EVERY HOUR SNAPS
|
||||
//
|
||||
if (DateUtil.IsAfterDuration(_lastHHSnapshot, tsOneHour))
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
log.LogTrace("HH metrics snapshot");
|
||||
//RECORDS IN TABLE
|
||||
// //Only do this once per hour
|
||||
// log.LogTrace("Counting table records");
|
||||
|
||||
|
||||
// //Get a count of important tables in db
|
||||
// List<string> allTableNames = await DbUtil.GetAllTablenamesAsync();
|
||||
|
||||
// //Skip some tables as they are internal and / or only ever have one record
|
||||
// List<string> skipTableNames = new List<string>();
|
||||
// skipTableNames.Add("alicense");
|
||||
// skipTableNames.Add("aschemaversion");
|
||||
|
||||
// foreach (string table in allTableNames)
|
||||
// {
|
||||
// if (!skipTableNames.Contains(table))
|
||||
// {
|
||||
// //var tags = new MetricTags("TableTagKey", table);
|
||||
// // metrics.Measure.Gauge.SetValue(MetricsRegistry.DBRecordsGauge, tags, await DbUtil.CountOfRecordsAsync(table));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//JOB COUNTS (DEAD, RUNNING, COMPLETED, SLEEPING)
|
||||
|
||||
// foreach (JobStatus stat in Enum.GetValues(typeof(JobStatus)))
|
||||
// {
|
||||
// // var jobtag = new MetricTags("JobStatus", stat.ToString());
|
||||
// // metrics.Measure.Gauge.SetValue(MetricsRegistry.JobsGauge, jobtag, await JobsBiz.GetCountForJobStatusAsync(ct, stat));
|
||||
// }
|
||||
_lastHHSnapshot = now;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
//ONCE A DAY SNAPS AND CLEANUP
|
||||
@@ -162,8 +107,6 @@ namespace AyaNova.Biz
|
||||
var UtilityFilesAvailableSpace = FileUtil.UtilityFilesDriveAvailableSpace();
|
||||
var AttachmentFilesAvailableSpace = FileUtil.AttachmentFilesDriveAvailableSpace();
|
||||
|
||||
|
||||
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
//DB total size
|
||||
@@ -204,7 +147,7 @@ namespace AyaNova.Biz
|
||||
DateTime ClearDate = DateTime.UtcNow - tsDataRetention;
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
// ct.Database.ExecuteSqlInterpolated($"delete from ametricmm where t < {ClearDate.ToUniversalTime()}");
|
||||
ct.Database.ExecuteSqlInterpolated($"delete from ametricmm where t < {ClearDate.ToUniversalTime()}");
|
||||
}
|
||||
_lastDDSnapshot = now;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user