sysutils/munin-node: New plugin (#1690)

This commit is contained in:
Michael 2020-02-10 17:21:02 +01:00 committed by GitHub
parent 90a6ed9cbd
commit aa15997d0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 418 additions and 0 deletions

View file

@ -47,6 +47,7 @@ misc/theme-tukan -- The tukan theme - blue/white
misc/theme-vicuna -- The vicuna theme - dark anthrazit
net-mgmt/collectd -- Collect system and application performance metrics periodically
net-mgmt/lldpd -- LLDP allows you to know exactly on which port is a server
net-mgmt/munin -- Munin monitoring node
net-mgmt/net-snmp -- Net-SNMP is a daemon for the SNMP protocol
net-mgmt/netdata -- Real-time performance monitoring
net-mgmt/nrpe -- Execute nagios plugins

View file

@ -0,0 +1,8 @@
PLUGIN_NAME= munin-node
PLUGIN_VERSION= 0.1
PLUGIN_COMMENT= munin monitorin agent
PLUGIN_DEPENDS= munin-node
PLUGIN_DEVEL= YES
PLUGIN_MAINTAINER= m.muenz@gmail.com
.include "../../Mk/plugins.mk"

View file

@ -0,0 +1,13 @@
Munin network-wide graphing framework (node)
Munin is a tool for graphing all sorts of information about one or more
servers and displaying it in a web interface. It uses the excellent
RRDTool (written by Tobi Oetiker) and is written in Perl. Munin has a
master/node architecture. The master connects to all the nodes at regular
intervals, and asks them for data. It then stores the data in RRD-files,
and (if needed) updates the graphs. One of the main goals have been ease
of creating own "plugins" (graphs).
This is the node part. It is used on all machines Munin shall watch.
WWW: http://munin-monitoring.org/

View file

@ -0,0 +1,49 @@
<?php
/*
* Copyright (C) 2020 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 muninnode_services()
{
global $config;
$services = array();
if (isset($config['OPNsense']['muninnode']['general']['enabled']) && $config['OPNsense']['muninnode']['general']['enabled'] == 1) {
$services[] = array(
'description' => gettext('muninnode daemon'),
'configd' => array(
'restart' => array('muninnode restart'),
'start' => array('muninnode start'),
'stop' => array('muninnode stop'),
),
'name' => 'munin_node',
'pidfile' => '/var/run/munin/munin-node.pid'
);
}
return $services;
}

View file

@ -0,0 +1,37 @@
<?php
/*
* Copyright (C) 2020 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\Muninnode\Api;
use OPNsense\Base\ApiMutableModelControllerBase;
class GeneralController extends ApiMutableModelControllerBase
{
protected static $internalModelClass = '\OPNsense\Muninnode\General';
protected static $internalModelName = 'general';
}

View file

@ -0,0 +1,39 @@
<?php
/*
* Copyright (C) 2020 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\Muninnode\Api;
use OPNsense\Base\ApiMutableServiceControllerBase;
class ServiceController extends ApiMutableServiceControllerBase
{
protected static $internalServiceClass = '\OPNsense\Muninnode\General';
protected static $internalServiceTemplate = 'OPNsense/Muninnode';
protected static $internalServiceEnabled = 'enabled';
protected static $internalServiceName = 'muninnode';
}

View file

@ -0,0 +1,38 @@
<?php
/*
* Copyright (C) 2020 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\Muninnode;
class GeneralController extends \OPNsense\Base\IndexController
{
public function indexAction()
{
$this->view->generalForm = $this->getForm('general');
$this->view->pick('OPNsense/Muninnode/general');
}
}

View file

@ -0,0 +1,28 @@
<form>
<field>
<id>general.enabled</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable Munin-Node daemon.</help>
</field>
<field>
<id>general.hostname</id>
<label>Hostname</label>
<type>text</type>
<help>Set the hostname which will indicate this system at the central munin platform.</help>
</field>
<field>
<id>general.port</id>
<label>Listen Port</label>
<type>text</type>
<help>Set the port munin listen to.</help>
</field>
<field>
<id>general.allowednetworks</id>
<label>Allowed Networks</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set the CIDR networks allowed to contact this node. For a single host please use /32</help>
</field>
</form>

View file

@ -0,0 +1,9 @@
<acl>
<page-services-muninnode>
<name>Services: Munin-Node</name>
<patterns>
<pattern>ui/muninnode/*</pattern>
<pattern>api/muninnode/*</pattern>
</patterns>
</page-services-muninnode>
</acl>

View file

@ -0,0 +1,35 @@
<?php
/*
* Copyright (C) 2020 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\Muninnode;
use OPNsense\Base\BaseModel;
class General extends BaseModel
{
}

View file

@ -0,0 +1,23 @@
<model>
<mount>//OPNsense/muninnode/general</mount>
<description>Munin-Node configuration</description>
<version>0.0.2</version>
<items>
<enabled type="BooleanField">
<default>0</default>
<Required>Y</Required>
</enabled>
<hostname type="TextField">
<default>OPNsense</default>
<Required>Y</Required>
</hostname>
<port type="PortField">
<default>4949</default>
<Required>Y</Required>
</port>
<allowednetworks type="CSVListField">
<default></default>
<Required>N</Required>
</allowednetworks>
</items>
</model>

View file

@ -0,0 +1,7 @@
<menu>
<Services>
<Munin-Node cssClass="fa fa-pie-chart">
<General url="/ui/muninnode/general/index"/>
</Munin-Node>
</Services>
</menu>

View file

@ -0,0 +1,57 @@
{#
# Copyright (c) 2019 Deciso B.V.
# Copyright (c) 2020 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.
#}
<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>
<script>
$(function() {
var data_get_map = {'frm_general_settings':"/api/muninnode/general/get"};
mapDataToFormUI(data_get_map).done(function(data){
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
});
updateServiceControlUI('muninnode');
// link save button to API set action
$("#saveAct").click(function(){
saveFormToEndpoint(url="/api/muninnode/general/set", formid='frm_general_settings',callback_ok=function(){
$("#saveAct_progress").addClass("fa fa-spinner fa-pulse");
ajaxCall(url="/api/muninnode/service/reconfigure", sendData={}, callback=function(data,status) {
updateServiceControlUI('muninnode');
$("#saveAct_progress").removeClass("fa fa-spinner fa-pulse");
});
});
});
});
</script>

View file

@ -0,0 +1,8 @@
#!/bin/sh
mkdir -p /var/munin/plugin-state/
mkdir -p /var/log/munin/
mkdir -p /var/run/munin/
chown -R munin:munin /var/munin/plugin-state/ /var/munin/ /var/log/munin/ /var/run/munin/
chmod 755 /var/munin/plugin-state/ /var/munin/ /var/log/munin/ /var/run/munin/

View file

@ -0,0 +1,23 @@
[start]
command:/usr/local/opnsense/scripts/OPNsense/Muninnode/setup.sh;/usr/local/etc/rc.d/munin-node start
parameters:
type:script
message:starting munin-node
[stop]
command:/usr/local/etc/rc.d/munin-node stop
parameters:
type:script
message:stopping munin-node
[restart]
command:/usr/local/opnsense/scripts/OPNsense/Muninnode/setup.sh;/usr/local/etc/rc.d/munin-node restart
parameters:
type:script
message:restarting munin-node
[status]
command:/usr/local/etc/rc.d/munin-node status;exit 0
parameters:
type:script_output
message:request munin-node status

View file

@ -0,0 +1,2 @@
munin_node:/etc/rc.conf.d/munin_node
munin-node.conf:/usr/local/etc/munin/munin-node.conf

View file

@ -0,0 +1,34 @@
{% if helpers.exists('OPNsense.muninnode.general.enabled') and OPNsense.muninnode.general.enabled == '1' %}
log_level 4
log_file /var/log/munin/munin-node.log
pid_file /var/run/munin/munin-node.pid
background 1
setsid 1
user root
group wheel
# Regexps for files to ignore
ignore_file [\#~]$
ignore_file DEADJOE$
ignore_file \.bak$
ignore_file %$
ignore_file \.dpkg-(tmp|new|old|dist)$
ignore_file \.rpm(save|new)$
ignore_file \.pod$
ignore_file \.sample$
host_name {{ OPNsense.muninnode.general.hostname }}
{% if helpers.exists('OPNsense.muninnode.general.allowednetworks') %}
{% for network in OPNsense.muninnode.general.allowednetworks.split(',') %}
cidr_allow {{ network }}
{% endfor %}
{% endif %}
host *
port {{ OPNsense.muninnode.general.port }}
{% endif %}

View file

@ -0,0 +1,7 @@
{% if helpers.exists('OPNsense.muninnode.general.enabled') and OPNsense.muninnode.general.enabled == '1' %}
munin_node_var_script="/usr/local/opnsense/scripts/OPNsense/Muninnode/setup.sh"
munin_node_enable="YES"
{% else %}
munin_node_enable="NO"
{% endif %}
munin_node_var_mfs="/var/cache/munin_node /var/db/munin_node /var/log/munin_node"