This commit is contained in:
@@ -49,37 +49,37 @@ namespace AyaNova.Api.Controllers
|
|||||||
serverState = apiServerState;
|
serverState = apiServerState;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #if (DEBUG)
|
// #if (DEBUG)
|
||||||
// [HttpGet("collect")]
|
// [HttpGet("collect")]
|
||||||
// [AllowAnonymous]
|
// [AllowAnonymous]
|
||||||
// public ActionResult GetCollect()
|
// public ActionResult GetCollect()
|
||||||
// {
|
// {
|
||||||
// GC.Collect();
|
// GC.Collect();
|
||||||
// GC.WaitForPendingFinalizers();
|
// GC.WaitForPendingFinalizers();
|
||||||
// GC.Collect();
|
// GC.Collect();
|
||||||
|
|
||||||
// return Ok();
|
// return Ok();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// [HttpGet("hammer")]
|
// [HttpGet("hammer")]
|
||||||
// [AllowAnonymous]
|
// [AllowAnonymous]
|
||||||
// public async Task<IActionResult> GetHammer()
|
// public async Task<IActionResult> GetHammer()
|
||||||
// {
|
// {
|
||||||
// //test allocation and cleanup
|
// //test allocation and cleanup
|
||||||
// for (int x = 0; x < 100000; x++)
|
// for (int x = 0; x < 100000; x++)
|
||||||
// {
|
// {
|
||||||
// using (AyContext ct = ServiceProviderProvider.DBContext)
|
// using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||||
// var v=await ct.Widget.Where(z=>z.Serial<100).ToListAsync();
|
// var v=await ct.Widget.Where(z=>z.Serial<100).ToListAsync();
|
||||||
// // int i = await ct.Database.ExecuteSqlRawAsync($"select * from aglobalbizsettings");
|
// // int i = await ct.Database.ExecuteSqlRawAsync($"select * from aglobalbizsettings");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// return Ok();
|
// return Ok();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get Memory and CPU server metrics for time period specified
|
/// Get Memory and CPU server metrics for time period specified
|
||||||
@@ -227,10 +227,19 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
//############# TOP TABLES KB
|
//############# TOP TABLES KB
|
||||||
|
int AllTableCount=0;
|
||||||
List<MetricNameLongValue> TopTables = new List<MetricNameLongValue>();
|
List<MetricNameLongValue> TopTables = new List<MetricNameLongValue>();
|
||||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
SELECT table_name, pg_total_relation_size(table_name) AS total_size
|
||||||
|
FROM ( SELECT ( table_schema || '.' || table_name )
|
||||||
|
AS table_name FROM information_schema.tables
|
||||||
|
where table_schema not in('pg_catalog','information_schema'))
|
||||||
|
AS all_tables
|
||||||
|
ORDER BY total_size DESC
|
||||||
|
*/
|
||||||
|
|
||||||
var cmd = @"SELECT
|
var cmd = @"SELECT
|
||||||
table_name,
|
table_name,
|
||||||
pg_total_relation_size(table_name) AS total_size
|
pg_total_relation_size(table_name) AS total_size
|
||||||
@@ -249,6 +258,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
while (dr.Read())
|
while (dr.Read())
|
||||||
{
|
{
|
||||||
|
AllTableCount++;
|
||||||
long tableSize = dr.GetInt64(1);
|
long tableSize = dr.GetInt64(1);
|
||||||
string tableName = dr.GetString(0);
|
string tableName = dr.GetString(0);
|
||||||
tableName = tableName.Replace("\"", "").Replace("public.a", "");
|
tableName = tableName.Replace("\"", "").Replace("public.a", "");
|
||||||
@@ -265,6 +275,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
//trim out tables less than 1kb (the math above sets anything less than 1kb to zero)
|
//trim out tables less than 1kb (the math above sets anything less than 1kb to zero)
|
||||||
TopTables = TopTables.Where(z => z.value > 48).ToList();//NOTE: empty tables seem to all be 48kb so that's why this is here
|
TopTables = TopTables.Where(z => z.value > 48).ToList();//NOTE: empty tables seem to all be 48kb so that's why this is here
|
||||||
|
int OtherTableCount=AllTableCount-TopTables.Count();
|
||||||
|
|
||||||
long DBTotalSize = 0;
|
long DBTotalSize = 0;
|
||||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||||
@@ -286,7 +297,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
ttSize += tt.value;
|
ttSize += tt.value;
|
||||||
}
|
}
|
||||||
TopTables.Add(new MetricNameLongValue() { name = "other", value = DBTotalSize - ttSize });
|
TopTables.Add(new MetricNameLongValue() { name = $"{OtherTableCount} others", value = DBTotalSize - ttSize });
|
||||||
|
|
||||||
var ret = new
|
var ret = new
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user