Install the Check MK agent on a QNAP NAS

From Levy

Revision as of 09:46, 11 January 2022 by Louis (talk | contribs) (Instructions for installing the Check_MK agent on a QNAP NAS)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Introduction

This page describes how to install the Check_MK agent on QNAP NAS. Though you can use SNMP for monitoring it, installing the agent alongside will give you more information about the the NAS status. This procedure is for NAS running QTS 4.3.3 or higher.

Installing xinetd

The first thing we need to do is install xinetd on the NAS. Login to the NAS as the admin user using ssh. Then run the following commands:

bash
/opt/bin/opkg update
/opt/bin/opkg install xinetd

Installing the Check_MK agent

Now that xinetd is installed we can install the Check_MK agent. Do this by copying check_mk_agent.linux from your Check_MK server to /opt/bin/check_mk_agent on the NAS.

Create the file /opt/etc/xinetd.d/check_mk with this content:

# +------------------------------------------------------------------+
# |             ____ _               _        __  __ _  __           |
# |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
# |           | |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /            |
# |           | |___| | | |  __/ (__|   <    | |  | | . \            |
# |            \____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\           |
# |                                                                  |
# | Copyright Mathias Kettner 2014             mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software;  you can redistribute it and/or modify it
# under the  terms of the  GNU General Public License  as published by
# the Free Software Foundation in version 2.  check_mk is  distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY;  with-
# out even the implied warranty of  MERCHANTABILITY  or  FITNESS FOR A
# PARTICULAR PURPOSE. See the  GNU General Public License for more de-
# tails. You should have  received  a copy of the  GNU  General Public
# License along with GNU Make; see the file  COPYING.  If  not,  write
# to the Free Software Foundation, Inc., 51 Franklin St,  Fifth Floor,
# Boston, MA 02110-1301 USA.

service check_mk
{
        type           = UNLISTED
        port           = 6556
        socket_type    = stream
        protocol       = tcp
        wait           = no
        user           = admin
        server         = /opt/bin/check_mk_agent

        # listen on IPv4 AND IPv6 when available on this host
        #flags          = IPv6

        # If you use fully redundant monitoring and poll the client
        # from more then one monitoring servers in parallel you might
        # want to use the agent cache wrapper:
        #server         = /usr/bin/check_mk_caching_agent

        # configure the IP address(es) of your Nagios server here:
        #only_from      = 127.0.0.1 10.0.20.1 10.0.20.2

        # Don't be too verbose. Don't log every check. This might be
        # commented out for debugging. If this option is commented out
        # the default options will be used for this service.
        log_on_success =

        disable        = no
}

And then run these commands:

chmod +x /opt/bin/check_mk_agent
mkdir /opt/etc/check_mk
mkdir -p /opt/var/check_mk_agent/spool
mkdir -p /opt/lib/check_mk_agent/plugins
sed -i -e 's/usr\/lib/opt\/lib/' /opt/bin/check_mk_agent
sed -i -e 's/etc\/check/opt\/etc\/check/' /opt/bin/check_mk_agent
sed -i -e 's/var\/lib/opt\/var/' /opt/bin/check_mk_agent

Starting xinetd at boot

Starting from QTS 4.3.3 it's required to enable the autorun.sh processing in the Control Panel -> Hardware -> General: Run user defined startup processes (autorun.sh).

Now we mount the configuration flash partition:

mount $(/sbin/hal_app --get_boot_pd port_id=0)6 /tmp/config

Create/Edit /tmp/config/autorun.sh.

vi /tmp/config/autorun.sh

To start xinetd at boot time you need at least these lines in the file:

#!/bin/sh
/opt/sbin/xinetd

Ensure that /tmp/config/autorun.sh is executable

chmod +x /tmp/config/autorun.sh

Finally unmount the mounted flash partition:

umount /tmp/config

Reboot the NAS and verify that you can contact it from your Check_MK server on port 6556:

nc -v <your NAS IP> 6556

Configuration in Check_MK

When adding the NAS to Check_MK make sure to use both the Check_MK agent and SNMP. This will give you the most details about your NAS. For this you need to enable SNMP on the NAS under Network & File Services -> SNMP

CheckMK monitor QNAP NAS.jpg