Skip to content

ForNeVeR/nightwatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

162 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nightwatch Status Ventis

Nightwatch is a monitoring service intended to monitor daily and nightly activities and notify the administrator if something wrong happens.

Packages

Package NuGet
Nightwatch Nightwatch on nuget.org
Nightwatch.Core Nightwatch on nuget.org
Nightwatch.Notifications Nightwatch on nuget.org
Nightwatch.Resources Nightwatch on nuget.org
Nightwatch.Tool Nightwatch on nuget.org

Configure

Nightwatch could be configured by placing the nightwatch.yml file in the current directory. You may also override the configuration file path by using the command-line arguments, see the Run section of this document.

nightwatch.yml has the following form:

resource-directory: "some/path"
notification-directory: "notifications/path"
log-file: "logs/nightwatch.log"  # optional

Nightwatch searches the resource directory for the configuration files. At start, it will recursively read all the *.yml files in the resource directory, and set them up as periodic tasks. Each configuration file describes a Resource.

Similarly, Nightwatch reads all *.yml files from the notification directory to configure Notification providers. When a resource check fails or recovers, Nightwatch sends notifications via the providers listed in that resource's notifications section, not via all configured providers.

See Resource Documentation for details on available resource types (Shell, HTTP, HTTPS Certificate).

See Notification Documentation for details on available notification providers (Telegram).

Logging Configuration

By default, Nightwatch logs to the console. When running as a Windows service or in environments where console output is not accessible, you can redirect logs to a file:

log-file: "logs/nightwatch.log"

The path can be relative (resolved from the configuration file's directory) or absolute. When this option is not set or empty, logs are written to the console.

Usage

There are two ways to use Nightwatch: install it and run it in service mode, or install it as a package into an F# project and build your own monitoring service based on its API.

Installation in Service Mode

Install .NET SDK 10.0 or later.

Then, install Nightwatch as a global tool:

$ dotnet tool install --global FVNever.Nightwatch.Tool

After installation:

$ nightwatch [--config ./some/path.yml] [--service]

To stop the program, press Ctrl-C.

Add --config ./some/path.yml option to set the configuration file path (nightwatch.yml in the current directory is the default).

Add --service to run in a Windows service mode.

To install the service on Windows, execute the following commands in your shell:

$ sc.exe Nightwatch binpath= "D:\Path\To\nightwatch.exe --config D:\Path\To\nightwatch.yml --service" start= auto
$ sc.exe start Nightwatch

(note the space and quote placement, that's important)

Note: When running as a Windows service, logs are not visible in a console. It is recommended to configure file logging in your nightwatch.yml:

log-file: "D:\\Path\\To\\logs\\nightwatch.log"

Make sure the service account has write permissions to the log directory.

Installation as Package

Install the package FVNever.Nightwatch into a .NET project or an fsx file:

#r "nuget: FVNever.Nightwatch"
exit <| Nightwatch.EntryPoint.FsiMain(fsi.CommandLineArgs, None, None)
// you may override the resources or notification registries via the last two parameters

Read more in the API reference.

Documentation

License

The project is distributed under the terms of the MIT license.

The license indication in the project's sources is compliant with the REUSE specification v3.3.