check_trassir

Nagios/Icinga plugin for checking Trassir server health and channel archive via Trassir API

check_trassir

This plugin checks the health and archive status of a Trassir NVR system via its public API. It supports both server health mode and channel archive analysis mode, compatible with Nagios and Icinga2.

check_trassir-1.1


Execution modes

Channel Archive Check:

check_trassir performs channel check

> channel mode usage example:

./check_trassir.php --host 10.0.1.1 --port 8080 --username username --password secret_password --channel Camera-1 --hours 8 --timezone 3

Server Health Check:

check_trassir performs channel check

> server mode usage example:

./check_trassir.php --host 10.0.1.1 --port 8080 --username username --password secret_password

> NOTE: Use the --channel argument to switch between modes. If omitted, plugin runs in server mode. Use '--debug 1' to get detailed API output.


Dependencies

This plugin is written in PHP and requires the following:

  • PHP 5.3+
  • PHP cURL Extension
  • OpenSSL support in PHP

Install on Debian/Ubuntu:

sudo apt update
sudo apt install -y php php-curl php-openssl

Install on RHEL/CentOS:

sudo yum install -y php php-curl openssl

Plugin Installation

  1. Clone the repository to your home directory:

    cd ~
    git clone https://github.com/xyhtac/check_trassir.git
  2. Copy the plugin script to the Nagios plugins directory (usually /usr/lib/nagios/plugins/):

    sudo cp ~/check_trassir/check_trassir.php /usr/lib/nagios/plugins/
    sudo chmod 755 /usr/lib/nagios/plugins/check_trassir.php
  3. Ensure the script is executable and accessible by Nagios/Icinga.

    sudo chmod 755 /usr/lib/nagios/plugins/check_trassir.php
    sudo chown icinga:icinga /usr/lib/nagios/plugins/check_trassir.php

Icinga2 Configuration

You can either paste the following definitions into services.conf and commands.conf, or place them in a dedicated file like conf.d/trassir-checker.conf

Archive channel checker definition

add to your services.conf

apply Service "check-trassir-archive" {
  import "generic-service"
  check_interval = 30m
  retry_interval = 3m
  check_timeout = 1m
  vars.server_host = get_host(host.vars.server)
  vars.host = vars.server_host.address
  vars.port = vars.server_host.vars.trassir["port"]
  vars.timezone = vars.server_host.vars.trassir["timezone"]
  vars.username = vars.server_host.vars.trassir["username"]
  vars.password = vars.server_host.vars.trassir["password"]
  vars.trassir_archive_checker = true
  vars.channel = host.vars.trassir["channel"]
  vars.hours = ""
  if (host.vars.trassir["hours"] != null && host.vars.trassir["hours"] != "") {
    vars.hours = host.vars.trassir["hours"]
  } else {
    vars.hours = "24"
  }
  enable_perfdata = true
  check_command = "check_trassir"
  assign where host.vars.trassir["channel"] && host.vars.server
}

apply Dependency "mute-check-trassir-archive-if-server-down" to Service {
  disable_checks = true
  disable_notifications = true
  parent_host_name = host.vars.server
  assign where host.vars.trassir["channel"] && host.vars.server
}

Server checker definition

add to your services.conf

apply Service "check-trassir-server" {
  import "generic-service"
  check_interval = 10m
  retry_interval = 3m
  check_timeout = 1m
  vars.host = host.address
  vars.port = host.vars.trassir["port"]
  vars.timezone = host.vars.trassir["timezone"]
  vars.username = host.vars.trassir["username"]
  vars.password = host.vars.trassir["password"]
  vars.trassir_server_checker = true
  enable_perfdata = true
  check_command = "check_trassir"
  assign where host.vars.trassir["username"] && host.vars.trassir["password"]
}

Command Definition

add to your commands.conf

object CheckCommand "check_trassir" {
  import "plugin-check-command"
  command = [ PluginDir + "/check_trassir.php" ]
  arguments = {
    "--hours" = "$hours$"
    "--host" = "$host$"
    "--port" = "$port$"
    "--username" = "$username$"
    "--password" = "$password$"
    "--channel" = "$channel$"
    "--timezone" = "$timezone$"
    "--delay" = "$delay$"
  }
  vars.enable_perfdata = true
}

Once the necessary Service and CheckCommand definitions are in place (see above), monitoring is enabled through host variables.

Server Host Configuration

Add Trassir credentials and connection details to the DVR host object:

object Host "TS7" {
  import "generic-host"
  address = "10.0.1.1"
  vars.trassir["username"] = "username"
  vars.trassir["password"] = "secret_password"
  vars.trassir["port"] = "8080"
  vars.trassir["timezone"] = "3"
}

Camera Host Configuration

Link the camera to the server using the vars.server variable and define channel parameters:

object Host "Cam 1.12" {
  import "iot-host"
  address = "10.0.1.12"
  vars.server = "TS7"  // Link to Server hostname
  vars.trassir["channel"] = "1.12"
  vars.trassir["hours"] = "8"
}

> NOTE: variable channel refers to the channel name substring used in Trassir, the plugin will select the matching archive timeline based on partial match (includes), not strict equality. The hours variable sets how far in the past to search for archive activity. If no activity is detected within that period, a warning is triggered.

How It Works

  • Trassir server check is automatically assigned to DVR hosts where login credentials are set.
  • Archive channel check is automatically created for any camera host that defines vars.server and vars.trassir["channel"].
  • All variables from the DVR host are inherited via the vars.server reference.

No manual service assignment is needed - Icinga handles service linkage dynamically based on these variables.

Don't forget to restart Icinga2:

sudo systemctl restart icinga2

License

This repository is distributed under the Apache License 2.0.
See the LICENSE file for full terms and conditions.


Disclaimer

This plugin is developed independently and is based on the publicly available Trassir API SDK, as documented at: https://trassir.com/software-updates/manual/sdk.html

Please be aware of:

  • The Trassir API SDK is subject to change without prior notice by its maintainers. This may impact the compatibility or functionality of this plugin in the future.
  • This project is not affiliated with, endorsed by, or officially supported by DSSL or Trassir.
  • "Trassir" and its associated logos and trademarks are the intellectual property of DSSL (https://www.dssl.ru/). All rights to those names and marks are reserved by their respective owners.
  • The authors of this plugin make no guarantees regarding its fitness for any particular purpose and are not liable for any damages resulting from its use.

Bugs and feature requests

Please report bugs here on Github. Guidelines for bug reports:

  1. Use the GitHub issue search — check if the issue has already been reported.
  2. Check if the issue has been fixed — try to reproduce it using the latest master or development branch in the repository.
  3. Isolate the problem — create a reduced test case and a live example.

A good bug report shouldn't leave others needing to chase you up for more information. Please try to be as detailed as possible in your report. Feature requests are welcome. Please look for existing ones and use GitHub's "reactions" feature to vote.