Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MidnightBSD to a number of plugins #1342

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,11 @@ if ( not $build->install_path('plugins') ) {

$plugins_files->{'plugins/plugin.sh'} = 'plugins/plugin.sh';

# MidnightBSD is similar to FreeBSD, so we also want to include FreeBSD specific plugins here.
my $os = $^O;
$os =~ s/midnightbsd/freebsd/;
File::Find::find( { wanted => \&_find_plugins_wanted },
'plugins/node.d', "plugins/node.d.$^O" );
'plugins/node.d', "plugins/node.d.$os" );

sub _find_plugins_wanted {

Expand Down
17 changes: 17 additions & 0 deletions doc/installation/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ You will have to enable the services in systemd to get them up and running.
Likely you will have to fix SELinux issues when using 3rd-Party plugins and SELinux active and set to *enforcing mode* on the Munin node.
In case you get competent and friendly support on `SELinux mailinglist <https://admin.fedoraproject.org/mailman/listinfo/selinux>`_.

MidnightBSD
-------

From source:

.. code-block:: bash

cd /usr/mports/sysutils/munin-master && make install clean
cd /usr/mports/sysutils/munin-node && make install clean

Binary packages:

.. code-block:: bash

mport install munin-master
mport install munin-node

Other systems
-------------

Expand Down
7 changes: 3 additions & 4 deletions plugins/node.d.freebsd/cpu
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ if [ "$1" = "autoconf" ]; then
fi

if [ "$1" = "config" ]; then

OSV=`$SYSCTL_BIN -n kern.osrelease | cut -f1 -d.`
if [ "$OSV" = "4" ]; then
STATUNITS=`$SYSCTL_BIN -n kern.clockrate | cut -f16 -d' '`
elif [ "$OSV" -ge "5" ]; then
if [ "$(uname -s)" = "MidnightBSD" ] || [ "$OSV" -ge "5" ]; then
STATUNITS=`$SYSCTL_BIN -n kern.clockrate | cut -f13 -d' '`
elif [ "$OSV" = "4" ]; then
STATUNITS=`$SYSCTL_BIN -n kern.clockrate | cut -f16 -d' '`
fi
PERCENT=`$SYSCTL_BIN -n hw.ncpu | awk '{print ($1)*100}'`
NCPU=`$SYSCTL_BIN -n hw.ncpu`
Expand Down
2 changes: 1 addition & 1 deletion plugins/node.d.freebsd/systat
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ EOF
exit 0
fi
ostype=`uname -s`
if [ ${ostype} = "FreeBSD" ]; then
if [ ${ostype} = "FreeBSD" ] || [ ${ostype} = "MidnightBSD" ]; then
echo "yes"
exit 0
fi
Expand Down
6 changes: 3 additions & 3 deletions plugins/node.d.freebsd/vmstat
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
OSV=`/sbin/sysctl -n kern.osrelease | cut -f1 -d.`

if [ "$1" = "autoconf" ]; then
if [ "$OSV" -ge "5" ]; then
if [ $(uname -s) = "MidnightBSD" ] || [ "$OSV" -ge "5" ]; then
/sbin/sysctl -n vm.vmtotal 2>/dev/null >/dev/null
RESULT=$?
NAME=/sbin/sysctl
Expand Down Expand Up @@ -49,7 +49,7 @@ if [ "$1" = "config" ]; then
echo 'graph_vlabel process states'
echo 'graph_category processes'
echo 'graph_info This graph shows number of processes in each state.'
if [ "$OSV" -ge "5" ]; then
if [ $(uname -s) = "MidnightBSD" ] || [ "$OSV" -ge "5" ]; then
echo 'running.label running'
echo 'running.info processes on CPU or waiting for CPU'
echo 'running.type GAUGE'
Expand All @@ -71,7 +71,7 @@ if [ "$1" = "config" ]; then
exit 0
fi

if [ "$OSV" -ge "5" ]; then
if [ $(uname -s) = "MidnightBSD" ] || [ "$OSV" -ge "5" ]; then
/sbin/sysctl -n vm.vmtotal | /usr/bin/awk '
/^Processes:/ {
print "running.value", $3;
Expand Down
2 changes: 1 addition & 1 deletion plugins/node.d/hddtemp_smartctl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ if ($^O eq 'linux') {
# Get list of all drives we found
@drives=(@drivesIDE,@drivesSCSI,@drivesNVME);

} elsif ($^O eq 'freebsd') {
} elsif (($^O eq 'freebsd') || ($^O eq 'midnightbsd')) {
opendir(DEV, '/dev');
@drives = grep /^(ada?|da)[0-9]+$/, readdir DEV;
closedir(DEV);
Expand Down
22 changes: 18 additions & 4 deletions plugins/node.d/processes
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ OPERSYS=${OPERSYS:-$(uname | cut -f 1 -d _)}

if [ "$1" = "autoconf" ]; then
case "$OPERSYS" in
Linux|SunOS|FreeBSD|OpenBSD|NetBSD|Darwin|CYGWIN)
Linux|SunOS|FreeBSD|OpenBSD|NetBSD|Darwin|CYGWIN|MidnightBSD)
if ! "$ps" >/dev/null 2>/dev/null; then
echo "no (ps=$ps failed)"
elif ! echo | "$awk" '{ print "Hei" }' >/dev/null 2>/dev/null; then
Expand Down Expand Up @@ -227,11 +227,25 @@ if [ "$1" = "config" ]; then
echo "nonexistent.info The number of nonexistent processes."
print_warning nonexistent
print_critical nonexistent
elif [ "$OPERSYS" = "MidnightBSD" ]; then
echo "graph_order sleeping idle stopped zombie lock uninterruptible interrupt runnable processes"
echo "lock.label lock"
echo "lock.draw STACK"
echo "lock.colour $LOCK"
echo "lock.info The number of processes that are waiting to acquire a lock."
print_warning lock
print_critical lock
echo "interrupt.label interrupt"
echo "interrupt.draw STACK"
echo "interrupt.colour $INTERRUPT"
echo "interrupt.info The number of idle interrupt threads."
print_warning interrupt
print_critical interrupt
fi

# Common flags for some OS
if [ "$OPERSYS" = "FreeBSD" ] || [ "$OPERSYS" = "OpenBSD" ] ||
[ "$OPERSYS" = "NetBSD" ] || [ "$OPERSYS" = "Darwin" ]; then
[ "$OPERSYS" = "NetBSD" ] || [ "$OPERSYS" = "Darwin" ] || [ "$OPERSYS" = "MidnightBSD" ]; then
echo "idle.label idle"
echo "idle.draw STACK"
echo "idle.colour $IDLE"
Expand Down Expand Up @@ -267,7 +281,7 @@ if [ "$1" = "config" ]; then
fi

if [ "$OPERSYS" = "Linux" ] || [ "$OPERSYS" = "FreeBSD" ] ||
[ "$OPERSYS" = "OpenBSD" ] || [ "$OPERSYS" = "NetBSD" ]; then
[ "$OPERSYS" = "OpenBSD" ] || [ "$OPERSYS" = "NetBSD" ] || [ "$OPERSYS" = "MidnightBSD" ]; then
echo "uninterruptible.label uninterruptible"
echo "uninterruptible.draw STACK"
echo "uninterruptible.colour $UNINTERRUPTIBLE"
Expand Down Expand Up @@ -344,7 +358,7 @@ print "runnable.value " 0+stat["R"];
print "stopped.value " 0+stat["T"];
print "zombie.value " 0+stat["Z"];
}'
elif [ "$OPERSYS" = "FreeBSD" ]; then
elif [ "$OPERSYS" = "FreeBSD" ] || [ "$OPERSYS" = "MidnightBSD" ]; then
# shellcheck disable=SC2016
"$ps" -axo state= | sed -e 's/^\(.\).*/\1/' | "$awk" '
{ processes++; stat[$1]++ }
Expand Down
4 changes: 2 additions & 2 deletions plugins/node.d/smart_
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def find_smart_drives():
continue
except Exception as exc:
verboselog('Failed to list OpenBSD disks: {}'.format(exc))
elif os.uname()[0] == "FreeBSD":
elif os.uname()[0] in {"FreeBSD", "MidnightBSD"}:
try:
sysctl_kerndisks = os.popen('sysctl kern.disks')
kerndisks = sysctl_kerndisks.readline().strip()
Expand All @@ -588,7 +588,7 @@ def find_smart_drives():
except Exception:
continue
except Exception as exc:
verboselog('Failed to list FreeBSD disks: {}'.format(exc))
verboselog('Failed to list {} disks: {}'.format(os.uname()[0], exc))
elif os.uname()[0] == "Darwin":
try:
from glob import glob
Expand Down