AppWeb.PageStatusMonitor
0.2.11
dotnet add package AppWeb.PageStatusMonitor --version 0.2.11
NuGet\Install-Package AppWeb.PageStatusMonitor -Version 0.2.11
<PackageReference Include="AppWeb.PageStatusMonitor" Version="0.2.11" />
paket add AppWeb.PageStatusMonitor --version 0.2.11
#r "nuget: AppWeb.PageStatusMonitor, 0.2.11"
// Install AppWeb.PageStatusMonitor as a Cake Addin #addin nuget:?package=AppWeb.PageStatusMonitor&version=0.2.11 // Install AppWeb.PageStatusMonitor as a Cake Tool #tool nuget:?package=AppWeb.PageStatusMonitor&version=0.2.11
AppWeb.PageStatusMonitor
.Net Standard package and application for monitoring the status of your home page. Sends warnings and status updates through email/sms/telegram or your prefferred way when something is wrong.
Project url: https://appweb.se/en/packages/page-status-monitor
Installation
The package can be installed through nuget https://www.nuget.org/packages/AppWeb.PageStatusMonitor/
Install-Package AppWeb.PageStatusMonitor
Most simple example usage of monitor service
using AppWeb.PageStatusMonitor.Interfaces;
using AppWeb.PageStatusMonitor.Models;
using AppWeb.PageStatusMonitor.Services;
...
// Create monitor service
IMonitorService monitorService = new MonitorService();
// Run single check
var checkResult = monitorService.Check(new MonitorItem(new Uri("https://appweb.se")));
// Add your action on the result
if(checkResult.Successful)
{
var responseTime = checkResult.Milliseconds;
...
}
else{
...
}
...
The code above is the most simple way of using this package and running simple checks.
Different supported check types
Monitor items can be configured to chech either a URI och a IPAdress and checking if either a Get request or a Ping is successful. More advanced use cases will be supported in the future.
using AppWeb.PageStatusMonitor.Enums;
using AppWeb.PageStatusMonitor.Models;
...
// URI, when no CheckType is provided it will perform HttpGet by default
var item1 = new MonitorItem(new Uri("https://appweb.se"));
// URI to be checked with ping
var item2 = new MonitorItem(new Uri("https://appweb.se"), CheckType.Ping);
// IPAddress to explicity be checked with Get-request
var item3 = new MonitorItem(IPAddress.Parse("127.0.0.1"), CheckType.HttpGet);
// IPAdddress to be checked with ping
var item4 = new MonitorItem(IPAddress.Parse("127.0.0.1"), CheckType.Ping);
...
Example configuration for more advanced usage
{
"AppSettings": {
"EmailConfiguration": {
"FromEmail": "<your-email>",
"FromName": "<your-name>",
"ToEmail": "<to-email>",
"ToName": "<to-name>",
"SmtpHost": "<smtp-host>",
"SmtpUsername": "<smtp-username>",
"SmtpPassword": "<smtp-password>",
"UseSSL": true
},
"MonitorItems": [
{
"CheckUri": "https://www.appweb.se",
"CheckType": "HttpGet"
},
{
"CheckIPAddress": "127.0.0.1",
"CheckType": "Ping"
},
{
"CheckType": "HttpGet",
"CheckUri": "https://www.shouldNotExist1337orWhat.se"
}
]
}
}
Advanced example usage code
The following is from the ExampleConsoleApp provided in the solution
using System;
using System.IO;
using Microsoft.Extensions.Configuration;
using AppWeb.PageStatusMonitor.Actions;
using AppWeb.PageStatusMonitor.Configurations;
using AppWeb.PageStatusMonitor.Interfaces;
using AppWeb.PageStatusMonitor.Models;
using AppWeb.PageStatusMonitor.Services;
namespace AppWeb.PageStatusMonitor.ExampleConsoleApp
{
public class Program
{
public IMonitorService MonitorService;
public IEmailService EmailService;
public MonitorConfiguration MonitorConfiguration;
public Program()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
IConfigurationRoot configuration = builder.Build();
var appSettings = configuration.GetSection("AppSettings").Get<AppSettings>();
// Actions to be run after each check result
Action<MonitorResultItem> onCheckCompleteAction = (monitorResultItem) =>
{
// Console write status
ConsoleActions.WriteCheckStatus(monitorResultItem);
// Email if check fails
EmailActions.SendEmailOnFail(monitorResultItem, EmailService);
};
MonitorService = new MonitorService(new HttpService());
EmailService = new EmailService(appSettings.EmailConfiguration);
MonitorConfiguration = new MonitorConfiguration(appSettings.MonitorItems, onCheckCompleteAction);
}
static void Main(string[] args)
{
Console.WriteLine("Started");
Program program = new Program();
var runResult = program.MonitorService
.RunChecks(program.MonitorConfiguration); // Runs the check
// Optional extentions:
//.FilterOnlySuccessful() // filter so we only get successful checks
//.FilterOnlyFailed() // filter so we only get failed checks
//.FilterLongExecutionTime(500) // filter so we just get checks with long excution time
//.Then(ConsoleActions.WriteSuccessfulSummary) // console write summary of successful checks
//.Then(ConsoleActions.WriteFailedSummary) // console write summary of failed checks
Console.WriteLine();
Console.WriteLine("Done, press any key to close");
Console.ReadKey();
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.2.11 | 115 | 6/20/2024 |
0.2.10 | 3,884 | 10/22/2019 |
0.2.9 | 1,059 | 10/22/2019 |
0.2.8 | 1,017 | 10/21/2019 |
0.2.7 | 1,015 | 9/20/2019 |
0.2.6 | 1,178 | 12/21/2018 |
0.2.5 | 1,096 | 12/21/2018 |
0.2.4 | 1,175 | 12/20/2018 |
0.2.3 | 1,136 | 12/12/2018 |
0.2.2 | 1,271 | 12/11/2018 |
0.2.1 | 1,244 | 12/6/2018 |
0.2.0 | 1,211 | 11/27/2018 |
0.1.0 | 1,226 | 10/30/2018 |
Nuget packaging adjustments