86 lines
2.4 KiB
C#
86 lines
2.4 KiB
C#
// /**
|
|
// * 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;
|
|
using ln.types.odb;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
using System.Linq;
|
|
using ln.types.odb.attributes;
|
|
using System.Collections.Generic;
|
|
namespace ln.skyscanner.checks
|
|
{
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
public enum CheckState { OK, WARN, CRITICAL, FAIL, ERROR }
|
|
|
|
public struct CheckStateChange
|
|
{
|
|
public CheckState NewState;
|
|
public DateTime Timestamp;
|
|
|
|
public CheckStateChange(CheckState checkState)
|
|
{
|
|
NewState = checkState;
|
|
Timestamp = DateTime.Now;
|
|
}
|
|
}
|
|
|
|
public class SkyCheckState
|
|
{
|
|
[DocumentID]
|
|
public Guid ID = Guid.NewGuid();
|
|
|
|
public readonly String CheckName;
|
|
[ByReference]
|
|
public readonly Node Node;
|
|
|
|
public String[] PerformanceValues => performanceValues.ToArray();
|
|
List<String> performanceValues = new List<String>();
|
|
|
|
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;
|
|
|
|
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>();
|
|
|
|
protected SkyCheckState()
|
|
{
|
|
}
|
|
public SkyCheckState(SkyCheck skyCheck,Node node)
|
|
{
|
|
CheckName = skyCheck.Name;
|
|
Node = node;
|
|
}
|
|
|
|
public void EnsurePerformanceValue(String perfName)
|
|
{
|
|
if (performanceValues == null)
|
|
performanceValues = new List<string>();
|
|
|
|
if (!performanceValues.Contains(perfName))
|
|
performanceValues.Add(perfName);
|
|
}
|
|
|
|
|
|
public class PerformanceValue
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
}
|