Skip to content

PythonScript

Loads and processes internal Python scripts

Enable module

To enable this module and allow using the commands you need to add PythonScript = enabled to the [/modules] section in nsclient.ini:

[/modules]
PythonScript = enabled

Configuration

Path / Section Description
/settings/default Default values
/settings/python
/settings/python/scripts Python scripts

Default values

Default values used in other config sections.

Key Default Value Description
allowed hosts 127.0.0.1 Allowed hosts
bind to BIND TO ADDRESS
cache allowed hosts true Cache list of allowed hosts
encoding NRPE PAYLOAD ENCODING
inbox inbox INBOX
password Password
script root Script root
socket queue size 0 LISTEN QUEUE
thread pool 10 THREAD POOL
timeout 30 TIMEOUT
timezone local Timezone
# Default values used in other config sections.
[/settings/default]
allowed hosts=127.0.0.1
cache allowed hosts=true
inbox=inbox
socket queue size=0
thread pool=10
timeout=30
timezone=local

Allowed hosts

A comma separated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.

Key Description
Path: /settings/default
Key: allowed hosts
Default value: 127.0.0.1

Sample:

[/settings/default]
# Allowed hosts
allowed hosts=127.0.0.1

BIND TO ADDRESS

Allows you to bind server to a specific local address. This has to be a dotted ip address not a host name. Leaving this blank will bind to all available IP addresses.

Key Description
Path: /settings/default
Key: bind to
Default value: N/A

Sample:

[/settings/default]
# BIND TO ADDRESS
bind to=

Cache list of allowed hosts

If host names (DNS entries) should be cached, improves speed and security somewhat but won’t allow you to have dynamic IPs for your Nagios server.

Key Description
Path: /settings/default
Key: cache allowed hosts
Default value: true

Sample:

[/settings/default]
# Cache list of allowed hosts
cache allowed hosts=true

NRPE PAYLOAD ENCODING

Key Description
Path: /settings/default
Key: encoding
Advanced: Yes (means it is not commonly used)
Default value: N/A

Sample:

[/settings/default]
# NRPE PAYLOAD ENCODING
encoding=

INBOX

The default channel to post incoming messages on

Key Description
Path: /settings/default
Key: inbox
Default value: inbox

Sample:

[/settings/default]
# INBOX
inbox=inbox

Password

Password an inbound caller has to present. Stored hashed (pbkdf2-sha256$…) when written by `nscp web install` or `nscp web password –set`; a clear-text value written by hand is still accepted, and is hashed in place when re-set. This is a password to verify against, not key material: NSCA encrypts with its shared secret instead of verifying it, so it keeps its own key under /settings/NSCA/server (or the NSCAClient default target) and never reads this one.

Key Description
Path: /settings/default
Key: password
Default value: N/A

Sample:

[/settings/default]
# Password
password=

Script root

The folder this module’s scripts live in: ${scripts} by default (empty, or `default`). `fleet` is ${fleet-folder}/scripts, where the fleet sync stages a bundle’s `scripts/` entries - a bundle that ships scripts sets this to `fleet` and refers to them as `scripts\`. `shared` is ${shared-path}/scripts; any other value is a folder (${…} tokens expanded). Python and Lua scripts live in its `python` and `lua` sub-folders. An external script is started in the folder above it, with a relative command such as `scripts\check.bat` resolved against that folder - the rule the default layout has always followed, so a scripts folder moved elsewhere runs unchanged, scripts that call each other by relative path included. Set it under [/settings/default] to apply to every script module at once. SECURITY: whoever can write to this folder can change what the service runs. It is also what ext-scr show/delete are confined to and where ext-scr add –import copies to; ext-scr add –script is not bounded by it (an administrator-only action, equivalent to editing the configuration directly).

Key Description
Path: /settings/default
Key: script root
Default value: N/A

Sample:

[/settings/default]
# Script root
script root=

Script root

The folder this module’s scripts live in: ${scripts} by default (empty, or `default`). `fleet` is ${fleet-folder}/scripts, where the fleet sync stages a bundle’s `scripts/` entries - a bundle that ships scripts sets this to `fleet` and refers to them as `scripts\`. `shared` is ${shared-path}/scripts; any other value is a folder (${…} tokens expanded). Python and Lua scripts live in its `python` and `lua` sub-folders. An external script is started in the folder above it, with a relative command such as `scripts\check.bat` resolved against that folder - the rule the default layout has always followed, so a scripts folder moved elsewhere runs unchanged, scripts that call each other by relative path included. Set it under [/settings/default] to apply to every script module at once. SECURITY: whoever can write to this folder can change what the service runs.

Key Description
Path: /settings/default
Key: script root
Default value: N/A

Sample:

[/settings/default]
# Script root
script root=

LISTEN QUEUE

Number of sockets to queue before starting to refuse new incoming connections. This can be used to tweak the amount of simultaneous sockets that the server accepts.

Key Description
Path: /settings/default
Key: socket queue size
Advanced: Yes (means it is not commonly used)
Default value: 0

Sample:

[/settings/default]
# LISTEN QUEUE
socket queue size=0

THREAD POOL

Key Description
Path: /settings/default
Key: thread pool
Advanced: Yes (means it is not commonly used)
Default value: 10

Sample:

[/settings/default]
# THREAD POOL
thread pool=10

TIMEOUT

Timeout (in seconds) when reading packets on incoming sockets. If the data has not arrived within this time we will bail out.

Key Description
Path: /settings/default
Key: timeout
Default value: 30

Sample:

[/settings/default]
# TIMEOUT
timeout=30

Timezone

Timezone used to render dates such as boot time. Accepts ‘local’ (default), ‘utc’, or any POSIX TZ string parseable by Boost.Date_time (e.g. ‘MST-07’ or ‘EST-05EDT,M3.2.0,M11.1.0’).

Key Description
Path: /settings/default
Key: timezone
Advanced: Yes (means it is not commonly used)
Default value: local

Sample:

[/settings/default]
# Timezone
timezone=local

/settings/python

Key Default Value Description
python cache Python cache
python lib libpython3.12.so.1.0 Python lib (Linux only)
script root Script root
# 
[/settings/python]
python lib=libpython3.12.so.1.0  # Linux only

Python cache

Override python cache folder.

Key Description
Path: /settings/python
Key: python cache
Default value: N/A

Sample:

[/settings/python]
# Python cache
python cache=

Python lib

The python DLL to load

Key Description
Path: /settings/python
Key: python lib
Platform: Linux only
Default value: libpython3.12.so.1.0

Sample:

[/settings/python]
# Python lib
python lib=libpython3.12.so.1.0

Script root

The folder this module’s scripts live in: ${scripts} by default (empty, or `default`). `fleet` is ${fleet-folder}/scripts, where the fleet sync stages a bundle’s `scripts/` entries - a bundle that ships scripts sets this to `fleet` and refers to them as `scripts\`. `shared` is ${shared-path}/scripts; any other value is a folder (${…} tokens expanded). Python and Lua scripts live in its `python` and `lua` sub-folders. An external script is started in the folder above it, with a relative command such as `scripts\check.bat` resolved against that folder - the rule the default layout has always followed, so a scripts folder moved elsewhere runs unchanged, scripts that call each other by relative path included. Set it under [/settings/default] to apply to every script module at once. SECURITY: whoever can write to this folder can change what the service runs.

Key Description
Path: /settings/python
Key: script root
Default value: N/A

Sample:

[/settings/python]
# Script root
script root=

Python scripts

A list of scripts available to run from the PythonScript module.

This is a section of objects. This means that you will create objects below this point by adding sections which all look the same.