Skip to content

gonace/Cronitor

Repository files navigation

Cronitor API Client

Cronitor is a service for heartbeat-style monitoring of anything that can send an HTTP request. It's particularly well suited for monitoring cron jobs, Jenkins jobs, or any other scheduled task.

Nuget Nuget

Supported APIs

This .NET library provides a simple abstraction for the pinging of a Cronitor monitor. For a better understanding of the API this library talks to, please see the documentation, links below.

Install

You can download the cronitor client nuget. https://www.nuget.org/packages/Cronitor

Usage

For the full documentation please read our wiki, telemetry wiki!

NET Generic Host

If you're using .NET (former .NET Core) and utilizing the default hosting and startup pattern (Microsoft.Extensions.Hosting) you use Cronitor.Extensions.Hosting.

The easiest way to use the client is to run .Configure(), this will create a static instance (Cronitor) of the client that can be used throughout your application.

Examples

await Host.CreateDefaultBuilder()
    .UseCronitor("apiKey")
    .Build()
    .RunAsync();
await Host.CreateDefaultBuilder()
    .UseCronitor((context) => context.Configuration.GetValue<string>("Cronitor:ApiKey"))
    .Build()
    .RunAsync();

Simple

Examples

using Cronitor.Models;
using Cronitor.Requests;

Cronitor.Configure("apiKey")

var monitor = new Monitor();
var request = new CreateRequest(monitor);
var response = Cronitor.Monitors.Create(request);

Advanced

If you only need access to one (or a few) clients you're able to configure each client individually.

Examples

using Cronitor.Models;
using Cronitor.Requests;

public class SomeClass
{
    private readonly ITelemetriesClient _client;

    public SomeClass()
    {
        _client = new TelemetriesClient("apiKey");
    }

    public Monitor Create()
    {
        var monitor = new Monitor();
        var request = new CreateRequest(monitor);
        var response = Cronitor.Monitors.Create(request);

        return response;
    }

    public async Task<Monitor> CreateAsync()
    {
        var monitor = new Monitor();
        var request = new CreateRequest(monitor);
        var response = await Cronitor.Monitors.CreateAsync(request);

        return resposne;
    }
}

Development

Suggestions

  • Add support for Quartz.NET Jobs
  • Implement Timezone constant (if not too big of a hassle to maintain)
  • Implement cron expression-language (if found as needed?)
  • Implement Cronitor assertions-language (if found as needed?)

Contributing

Pull requests and features are happily considered! By participating in this project you agree to abide by the Code of Conduct.

To contribute

Fork, then clone the repo:

git clone [email protected]:your-username/Cronitor.git

Push to your fork and submit a pull request