123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using System;
- using System.Text;
- namespace OpenSim.Framework.Monitoring
- {
- public class Check
- {
- public static readonly char[] DisallowedShortNameCharacters = { '.' };
-
-
-
- public string Category { get; private set; }
-
-
-
-
-
-
-
-
- public string Container { get; private set; }
-
-
-
-
-
-
- public Func<Check, bool> CheckFunc { get; private set; }
-
-
-
-
-
-
- public string LastFailureMessage { get; set; }
- public StatVerbosity Verbosity { get; private set; }
- public string ShortName { get; private set; }
- public string Name { get; private set; }
- public string Description { get; private set; }
- public Check(
- string shortName,
- string name,
- string description,
- string category,
- string container,
- Func<Check, bool> checkFunc,
- StatVerbosity verbosity)
- {
- if (ChecksManager.SubCommands.Contains(category))
- throw new Exception(
- string.Format("Alert cannot be in category '{0}' since this is reserved for a subcommand", category));
- foreach (char c in DisallowedShortNameCharacters)
- {
- if (shortName.IndexOf(c) != -1)
- throw new Exception(string.Format("Alert name {0} cannot contain character {1}", shortName, c));
- }
- ShortName = shortName;
- Name = name;
- Description = description;
- Category = category;
- Container = container;
- CheckFunc = checkFunc;
- Verbosity = verbosity;
- }
- public bool CheckIt()
- {
- return CheckFunc(this);
- }
- public virtual string ToConsoleString()
- {
- return string.Format(
- "{0}.{1}.{2} - {3}",
- Category,
- Container,
- ShortName,
- Description);
- }
- }
- }
|