mirror of
https://github.com/opnsense/plugins.git
synced 2026-05-28 04:34:15 -04:00
net-mgmt/nrpe3: New plugin (#1574)
This commit is contained in:
parent
8a6cfb8685
commit
8a62266268
22 changed files with 677 additions and 0 deletions
8
net-mgmt/nrpe3/Makefile
Normal file
8
net-mgmt/nrpe3/Makefile
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
PLUGIN_NAME= nrpe
|
||||
PLUGIN_VERSION= 0.1
|
||||
PLUGIN_COMMENT= Execute nagios plugins
|
||||
PLUGIN_DEPENDS= nrpe3
|
||||
PLUGIN_MAINTAINER= m.muenz@gmail.com
|
||||
PLUGIN_DEVEL= YES
|
||||
|
||||
.include "../../Mk/plugins.mk"
|
||||
9
net-mgmt/nrpe3/pkg-descr
Normal file
9
net-mgmt/nrpe3/pkg-descr
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
nrpe is used to execute Nagios plugins on remote hosts and report the results
|
||||
to the main Nagios server. From the Nagios homepage:
|
||||
|
||||
Allows you to execute "local" plugins (like check_disk, check_procs, etc.) on
|
||||
remote hosts. The check_nrpe plugin is called from Nagios and actually makes
|
||||
the plugin requests to the remote host. Requires that nrpe be running on the
|
||||
remote host (either as a standalone daemon or as a service under inetd).
|
||||
|
||||
WWW: http://www.nagios.org/
|
||||
55
net-mgmt/nrpe3/src/etc/inc/plugins.inc.d/nrpe.inc
Normal file
55
net-mgmt/nrpe3/src/etc/inc/plugins.inc.d/nrpe.inc
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2019 Michael Muenz <m.muenz@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function nrpe_enabled()
|
||||
{
|
||||
$model = new \OPNsense\Nrpe\General();
|
||||
return (string)$model->enabled == '1';
|
||||
}
|
||||
|
||||
function nrpe_services()
|
||||
{
|
||||
$services = array();
|
||||
|
||||
if (!nrpe_enabled()) {
|
||||
return $services;
|
||||
}
|
||||
|
||||
$services[] = array(
|
||||
'description' => gettext('NRPE'),
|
||||
'configd' => array(
|
||||
'restart' => array('nrpe restart'),
|
||||
'start' => array('nrpe start'),
|
||||
'stop' => array('nrpe stop'),
|
||||
),
|
||||
'name' => 'nrpe3',
|
||||
'pid' => '/var/run/nrpe.pid'
|
||||
);
|
||||
|
||||
return $services;
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (C) 2019 Michael Muenz <m.muenz@gmail.com>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Nrpe\Api;
|
||||
|
||||
use \OPNsense\Base\ApiMutableModelControllerBase;
|
||||
|
||||
class CommandController extends ApiMutableModelControllerBase
|
||||
{
|
||||
protected static $internalModelName = 'command';
|
||||
protected static $internalModelClass = '\OPNsense\Nrpe\Command';
|
||||
|
||||
public function searchCommandAction()
|
||||
{
|
||||
return $this->searchBase('commands.command', array("enabled", "name", "nrpecommand", "arguments"));
|
||||
}
|
||||
public function getCommandAction($uuid = null)
|
||||
{
|
||||
$this->sessionClose();
|
||||
return $this->getBase('command', 'commands.command', $uuid);
|
||||
}
|
||||
public function addCommandAction()
|
||||
{
|
||||
return $this->addBase('command', 'commands.command');
|
||||
}
|
||||
public function delCommandAction($uuid)
|
||||
{
|
||||
return $this->delBase('commands.command', $uuid);
|
||||
}
|
||||
public function setCommandAction($uuid)
|
||||
{
|
||||
return $this->setBase('command', 'commands.command', $uuid);
|
||||
}
|
||||
public function toggleCommandAction($uuid)
|
||||
{
|
||||
return $this->toggleBase('commands.command', $uuid);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2019 Michael Muenz <m.muenz@gmail.com>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Nrpe\Api;
|
||||
|
||||
use OPNsense\Base\ApiMutableModelControllerBase;
|
||||
|
||||
class GeneralController extends ApiMutableModelControllerBase
|
||||
{
|
||||
protected static $internalModelClass = '\OPNsense\Nrpe\General';
|
||||
protected static $internalModelName = 'general';
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2019 Michael Muenz <m.muenz@gmail.com>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Nrpe\Api;
|
||||
|
||||
use OPNsense\Base\ApiMutableServiceControllerBase;
|
||||
use OPNsense\Nrpe\General;
|
||||
|
||||
/**
|
||||
* Class ServiceController
|
||||
* @package OPNsense\Nrpe
|
||||
*/
|
||||
class ServiceController extends ApiMutableServiceControllerBase
|
||||
{
|
||||
protected static $internalServiceClass = '\OPNsense\Nrpe\General';
|
||||
protected static $internalServiceTemplate = 'OPNsense/Nrpe';
|
||||
protected static $internalServiceEnabled = 'enabled';
|
||||
protected static $internalServiceName = 'nrpe';
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2019 Michael Muenz <m.muenz@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Nrpe;
|
||||
|
||||
class GeneralController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->generalForm = $this->getForm("general");
|
||||
$this->view->formDialogEditNrpeCommand = $this->getForm("dialogEditNrpeCommand");
|
||||
$this->view->pick('OPNsense/Nrpe/general');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<form>
|
||||
<field>
|
||||
<id>command.enabled</id>
|
||||
<label>Enabled</label>
|
||||
<type>checkbox</type>
|
||||
<help>This will enable or disable the check command.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>command.name</id>
|
||||
<label>Name</label>
|
||||
<type>text</type>
|
||||
<help>Set the name for this check.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>command.nrpecommand</id>
|
||||
<label>Command</label>
|
||||
<type>text</type>
|
||||
<help>Full path to the check command.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>command.arguments</id>
|
||||
<label>Arguments</label>
|
||||
<type>text</type>
|
||||
<help>Set the arguments for this check commands.</help>
|
||||
</field>
|
||||
</form>
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<form>
|
||||
<field>
|
||||
<id>general.enabled</id>
|
||||
<label>Enable NRPE</label>
|
||||
<type>checkbox</type>
|
||||
<help>This will activate the NRPE service.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>general.server_port</id>
|
||||
<label>Port</label>
|
||||
<type>text</type>
|
||||
<help>Set the port the daemon is listening to.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>general.server_address</id>
|
||||
<label>Listen Address</label>
|
||||
<style>tokenize</style>
|
||||
<type>select_multiple</type>
|
||||
<allownew>true</allownew>
|
||||
<help>Set the address the daemon is listening to. Empty means listen to all addresses.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>general.allowed_hosts</id>
|
||||
<label>Allowed Hosts</label>
|
||||
<style>tokenize</style>
|
||||
<type>select_multiple</type>
|
||||
<allownew>true</allownew>
|
||||
<help>Set the list of allowed hosts which can query this system.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>general.dont_blame_nrpe</id>
|
||||
<label>Allow Arguments</label>
|
||||
<type>checkbox</type>
|
||||
<help>Enable to allow arguments sent to NRPE. Enabling this option is a high security risk.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>general.allow_bash_command_substitution</id>
|
||||
<label>Allow Bash Substitutions</label>
|
||||
<type>checkbox</type>
|
||||
<help>This option determines whether or not the NRPE daemon will allow clients to specify arguments that contain bash command substitutions of the form $(...). Enabling this option is a high security risk.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>general.command_timeout</id>
|
||||
<label>Command Timeout</label>
|
||||
<type>text</type>
|
||||
<help>This specifies the maximum number of seconds that the NRPE daemon will allow plugins to finish executing before killing them off.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>general.connection_timeout</id>
|
||||
<label>Connection Timeout</label>
|
||||
<type>text</type>
|
||||
<help>This specifies the maximum number of seconds that the NRPE daemon will wait for a connection to be established before exiting.</help>
|
||||
</field>
|
||||
</form>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<acl>
|
||||
<page-nrpe-config>
|
||||
<name>Services: NRPE</name>
|
||||
<patterns>
|
||||
<pattern>ui/nrpe/*</pattern>
|
||||
<pattern>api/nrpe/*</pattern>
|
||||
</patterns>
|
||||
</page-nrpe-config>
|
||||
</acl>
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2019 Michael Muenz <m.muenz@gmail.com>
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Nrpe;
|
||||
|
||||
use OPNsense\Base\BaseModel;
|
||||
|
||||
class Command extends BaseModel
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<model>
|
||||
<mount>//OPNsense/nrpe/command</mount>
|
||||
<description>NRPE command configuration</description>
|
||||
<version>0.0.1</version>
|
||||
<items>
|
||||
<commands>
|
||||
<command type="ArrayField">
|
||||
<enabled type="BooleanField">
|
||||
<default>1</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<name type="TextField">
|
||||
<default></default>
|
||||
<Required>Y</Required>
|
||||
<mask>/^[0-9a-z_\-]{1,32}$/ui</mask>
|
||||
<ValidationMessage>Only alphanumeric characters, dashes and underscores allowed.</ValidationMessage>
|
||||
</name>
|
||||
<nrpecommand type="TextField">
|
||||
<Required>Y</Required>
|
||||
</nrpecommand>
|
||||
<arguments type="TextField">
|
||||
<Required>Y</Required>
|
||||
</arguments>
|
||||
</command>
|
||||
</commands>
|
||||
</items>
|
||||
</model>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2019 Michael Muenz <m.muenz@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Nrpe;
|
||||
|
||||
use OPNsense\Base\BaseModel;
|
||||
|
||||
class General extends BaseModel
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<model>
|
||||
<mount>//OPNsense/nrpe/general</mount>
|
||||
<description>NRPE configuration</description>
|
||||
<version>0.0.1</version>
|
||||
<items>
|
||||
<enabled type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<server_port type="PortField">
|
||||
<default>5666</default>
|
||||
<Required>Y</Required>
|
||||
</server_port>
|
||||
<server_address type="NetworkField">
|
||||
<default>127.0.0.1</default>
|
||||
<Required>Y</Required>
|
||||
<FieldSeparator>,</FieldSeparator>
|
||||
<asList>Y</asList>
|
||||
</server_address>
|
||||
<allowed_hosts type="NetworkField">
|
||||
<default>127.0.0.1,::1</default>
|
||||
<Required>Y</Required>
|
||||
<FieldSeparator>,</FieldSeparator>
|
||||
<asList>Y</asList>
|
||||
</allowed_hosts>
|
||||
<dont_blame_nrpe type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>Y</Required>
|
||||
</dont_blame_nrpe>
|
||||
<allow_bash_command_substitution type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>Y</Required>
|
||||
</allow_bash_command_substitution>
|
||||
<command_timeout type="IntegerField">
|
||||
<default>60</default>
|
||||
<Required>Y</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>900</MaximumValue>
|
||||
<ValidationMessage>Value must be between 1 and 900.</ValidationMessage>
|
||||
</command_timeout>
|
||||
<connection_timeout type="IntegerField">
|
||||
<default>300</default>
|
||||
<Required>Y</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>900</MaximumValue>
|
||||
<ValidationMessage>Value must be between 1 and 900.</ValidationMessage>
|
||||
</connection_timeout>
|
||||
</items>
|
||||
</model>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<menu>
|
||||
<Services>
|
||||
<NRPE cssClass="fa fa-lightbulb-o fa-fw">
|
||||
<Configuration url="/ui/nrpe/general/index" order="10"/>
|
||||
</NRPE>
|
||||
</Services>
|
||||
</menu>
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
{#
|
||||
|
||||
OPNsense® is Copyright © 2014 – 2018 by Deciso B.V.
|
||||
This file is Copyright © 2019 by Michael Muenz <m.muenz@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#}
|
||||
|
||||
<!-- Navigation bar -->
|
||||
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
|
||||
<li class="active"><a data-toggle="tab" href="#general">{{ lang._('General') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#command">{{ lang._('Commands') }}</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content content-box tab-content">
|
||||
<div id="general" class="tab-pane fade in active">
|
||||
<div class="content-box" style="padding-bottom: 1.5em;">
|
||||
{{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_general_settings'])}}
|
||||
<div class="col-md-12">
|
||||
<hr />
|
||||
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Save') }}</b><i id="saveAct_progress"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="command" class="tab-pane fade in">
|
||||
<table id="grid-command" class="table table-responsive" data-editDialog="dialogEditNrpeCommand">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="enabled" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
|
||||
<th data-column-id="name" data-type="string" data-visible="true">{{ lang._('Name') }}</th>
|
||||
<th data-column-id="nrpecommand" data-type="string" data-visible="true">{{ lang._('Command') }}</th>
|
||||
<th data-column-id="arguments" data-type="string" data-visible="true">{{ lang._('Arguments') }}</th>
|
||||
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
|
||||
<th data-column-id="commands" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="5"></td>
|
||||
<td>
|
||||
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<div class="col-md-12">
|
||||
<hr />
|
||||
<button class="btn btn-primary" id="saveAct_command" type="button"><b>{{ lang._('Save') }}</b><i id="saveAct_command_progress"></i></button>
|
||||
<br /><br />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditNrpeCommand,'id':'dialogEditNrpeCommand','label':lang._('Edit Commands')])}}
|
||||
|
||||
<script>
|
||||
|
||||
$(function() {
|
||||
var data_get_map = {'frm_general_settings':"/api/nrpe/general/get"};
|
||||
mapDataToFormUI(data_get_map).done(function(data){
|
||||
formatTokenizersUI();
|
||||
$('.selectpicker').selectpicker('refresh');
|
||||
});
|
||||
|
||||
$("#grid-command").UIBootgrid(
|
||||
{ 'search':'/api/nrpe/command/searchCommand',
|
||||
'get':'/api/nrpe/command/getCommand/',
|
||||
'set':'/api/nrpe/command/setCommand/',
|
||||
'add':'/api/nrpe/command/addCommand/',
|
||||
'del':'/api/nrpe/command/delCommand/',
|
||||
'toggle':'/api/nrpe/command/toggleCommand/'
|
||||
}
|
||||
);
|
||||
|
||||
updateServiceControlUI('nrpe');
|
||||
|
||||
$("#saveAct").click(function(){
|
||||
saveFormToEndpoint(url="/api/nrpe/general/set", formid='frm_general_settings',callback_ok=function(){
|
||||
$("#saveAct_progress").addClass("fa fa-spinner fa-pulse");
|
||||
ajaxCall(url="/api/nrpe/service/reconfigure", sendData={}, callback=function(data,status) {
|
||||
updateServiceControlUI('nrpe');
|
||||
$("#saveAct_progress").removeClass("fa fa-spinner fa-pulse");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$("#saveAct_command").click(function(){
|
||||
saveFormToEndpoint(url="/api/nrpe/command/set", formid='frm_general_settings',callback_ok=function(){
|
||||
$("#saveAct_command_progress").addClass("fa fa-spinner fa-pulse");
|
||||
ajaxCall(url="/api/nrpe/service/reconfigure", sendData={}, callback=function(data,status) {
|
||||
$("#saveAct_command_progress").removeClass("fa fa-spinner fa-pulse");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
mkdir -p /var/run/nrpe3/
|
||||
chown nagios:nagios /var/run/nrpe3/
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
[start]
|
||||
command:/usr/local/opnsense/scripts/OPNsense/Nrpe/setup.sh;/usr/local/etc/rc.d/nrpe3 start
|
||||
parameters:
|
||||
type:script
|
||||
message:starting nrpe
|
||||
|
||||
[stop]
|
||||
command:/usr/local/etc/rc.d/nrpe3 stop
|
||||
parameters:
|
||||
type:script
|
||||
message:stopping nrpe
|
||||
|
||||
[restart]
|
||||
command:/usr/local/opnsense/scripts/OPNsense/Nrpe/setup.sh;/usr/local/etc/rc.d/nrpe3 restart
|
||||
parameters:
|
||||
type:script
|
||||
message:restarting nrpe
|
||||
|
||||
[status]
|
||||
command:/usr/local/etc/rc.d/nrpe3 status; exit 0
|
||||
parameters:
|
||||
type:script_output
|
||||
message:request nrpe status
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
nrpe:/etc/rc.conf.d/nrpe3
|
||||
nrpe.cfg:/usr/local/etc/nrpe.cfg
|
||||
nrpe_commands.cfg:/usr/local/etc/nrpe_commands.cfg
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{% if helpers.exists('OPNsense.nrpe.general.enabled') and OPNsense.nrpe.general.enabled == '1' %}
|
||||
nrpe3_enable="YES"
|
||||
{% else %}
|
||||
nrpe3_enable="NO"
|
||||
{% endif %}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
{% if helpers.exists('OPNsense.nrpe.general.enabled') and OPNsense.nrpe.general.enabled == '1' %}
|
||||
|
||||
log_facility=daemon
|
||||
log_file=/var/log/nrpe.log
|
||||
debug=0
|
||||
pid_file=/var/run/nrpe3/nrpe.pid
|
||||
nrpe_user=nagios
|
||||
nrpe_group=nagios
|
||||
|
||||
server_port={{ OPNsense.nrpe.general.server_port }}
|
||||
server_address={{ OPNsense.nrpe.general.server_address }}
|
||||
allowed_hosts={{ OPNsense.nrpe.general.allowed_hosts }}
|
||||
command_timeout={{ OPNsense.nrpe.general.command_timeout }}
|
||||
connection_timeout={{ OPNsense.nrpe.general.connection_timeout }}
|
||||
dont_blame_nrpe={{ OPNsense.nrpe.general.dont_blame_nrpe }}
|
||||
allow_bash_command_substitution={{ OPNsense.nrpe.general.allow_bash_command_substitution }}
|
||||
include=/usr/local/etc/nrpe_commands.cfg
|
||||
|
||||
{% endif %}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{% if helpers.exists('OPNsense.nrpe.general.enabled') and OPNsense.nrpe.general.enabled == '1' %}
|
||||
{% for commands in helpers.toList('OPNsense.nrpe.command.commands.command') %}
|
||||
{% if commands.enabled == '1' %}
|
||||
command[{{ commands.name }}]={{ commands.nrpecommand }} {{ commands.arguments }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
Loading…
Reference in a new issue