Skip to content

@Nagios

Remie Bolte edited this page Jun 26, 2018 · 9 revisions

@Nagios(configuration: Nagios, cgi?: Cgi, resource?: Resource)

The Nagios decorator tells the command-line interface that this is the entry point for the Nagios configuration. It will compile the class to a nagios.cfg file in the output directory.

If provided, the cgi and resources parameters will result in a cgi.cfg and resources.cfg file to be placed in the output directory. The resources.cfg file will be referenced from the resource_file main configuration file option.

Parameters

configuration: Nagios a JSON object with any of the options in the main configuration file.

cgi?: Cgi a JSON object with any of the options in the CGI file (optional)

resource?: Resource a JSON object with that can be used to specify $USERn$ macro definitions. It is highly recommended to use environment variables to protect sensitive information (you can use process.env in the JSON object) (optional)

Please note: the configuration JSON object on each decorator will be merged with any properties that are specified on the class which is annotated by the decorator.

Example

Given that the nagios.cfg, cgi.cfg and resources file together make up for a lot of properties, it is easiest to split them up in different files. In this example, the nagios, cgi and resources objects are imported from Typescript files which allows interface-based auto complete in the editor. However, it is also possible to import them as basic JSON files.

// Nagios configuration, CGI & Resources
import { cgi } from './cgi.cfg';
import { nagios as cfg } from './nagios.cfg';
import { resources } from './resources.cfg';

@Nagios(cfg, cgi, resources)
export default class DefaultNagiosConfiguration extends NagiosCfg {}

It is important that the Nagios entry point class is exported as the module default.

Clone this wiki locally