ln.skyscanner/checks/SkyCheckState.cs

85 lines
2.4 KiB
C#
Raw Normal View History

2019-04-05 00:59:04 +02:00
// /**
// * File: SkyCheckState.cs
// * Author: haraldwolff
// *
// * This file and it's content is copyrighted by the Author and / or copyright holder.
// * Any use wihtout proper permission is illegal and may lead to legal actions.
// *
// *
// **/
using System;
using ln.skyscanner.entities;
2019-04-06 09:36:43 +02:00
using ln.types.odb;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
2019-04-08 08:47:12 +02:00
using System.Linq;
using ln.types.odb.attributes;
2019-04-08 13:06:06 +02:00
using System.Collections.Generic;
2019-04-05 00:59:04 +02:00
namespace ln.skyscanner.checks
{
2019-04-06 09:36:43 +02:00
[JsonConverter(typeof(StringEnumConverter))]
2019-04-05 00:59:04 +02:00
public enum CheckState { OK, WARN, CRITICAL, FAIL, ERROR }
2019-04-08 13:06:06 +02:00
public struct CheckStateChange
{
public CheckState NewState;
public DateTime Timestamp;
public CheckStateChange(CheckState checkState)
{
NewState = checkState;
Timestamp = DateTime.Now;
}
}
2019-04-05 00:59:04 +02:00
public class SkyCheckState
{
2019-04-06 09:36:43 +02:00
[DocumentID]
public Guid ID = Guid.NewGuid();
2019-04-05 00:59:04 +02:00
public readonly String CheckName;
public readonly String UniqueNodeIdentifier;
2019-04-08 13:06:06 +02:00
public String[] PerformanceValues => performanceValues.ToArray();
List<String> performanceValues = new List<String>();
2019-04-08 08:47:12 +02:00
2019-04-05 00:59:04 +02:00
public DateTime LastCheckTime { get; set; }
public double WarnLower { get; set; } = Double.MinValue;
public double WarnUpper { get; set; } = Double.MaxValue;
public double CritLower { get; set; } = Double.MinValue;
public double CritUpper { get; set; } = Double.MaxValue;
2019-04-08 13:06:06 +02:00
public CheckState CheckState { get => currentCheckState; set { if (currentCheckState != value) history.Add(new CheckStateChange(value)); currentCheckState = value; } }
CheckState currentCheckState;
public CheckStateChange[] History => history.ToArray();
List<CheckStateChange> history = new List<CheckStateChange>();
2019-04-06 09:36:43 +02:00
2019-04-05 00:59:04 +02:00
protected SkyCheckState()
{
}
public SkyCheckState(SkyCheck skyCheck,Node node)
{
CheckName = skyCheck.Name;
UniqueNodeIdentifier = node.UniqueIdentity;
}
2019-04-08 13:06:06 +02:00
public void EnsurePerformanceValue(String perfName)
{
if (performanceValues == null)
performanceValues = new List<string>();
if (!performanceValues.Contains(perfName))
performanceValues.Add(perfName);
}
public class PerformanceValue
{
}
2019-04-05 00:59:04 +02:00
}
}