Skip to content

Add support for MidnightBSD to a number of plugins#1342

Open
laffer1 wants to merge 1 commit into
munin-monitoring:masterfrom
laffer1:midnightbsd
Open

Add support for MidnightBSD to a number of plugins#1342
laffer1 wants to merge 1 commit into
munin-monitoring:masterfrom
laffer1:midnightbsd

Conversation

@laffer1
Copy link
Copy Markdown
Contributor

@laffer1 laffer1 commented Jul 7, 2020

No description provided.

@coveralls
Copy link
Copy Markdown

coveralls commented Jul 7, 2020

Pull Request Test Coverage Report for Build 3007

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 52.42%

Totals Coverage Status
Change from base Build 3000: 0.0%
Covered Lines: 1083
Relevant Lines: 2066

💛 - Coveralls

@h01ger
Copy link
Copy Markdown
Contributor

h01ger commented Jul 8, 2020 via email

@laffer1
Copy link
Copy Markdown
Contributor Author

laffer1 commented Jul 8, 2020

It seemed to be the pattern with the others. I can modify the node.d.freebsd scripts instead to do an OS check and skip the legacy freebsd 4 and lower cases instead.

I will have to hack up build.pl though since it's doing this and midnightbsd is a supported platform in perl.

File::Find::find( { wanted => &_find_plugins_wanted },
'plugins/node.d', "plugins/node.d.$^O" );

@h01ger
Copy link
Copy Markdown
Contributor

h01ger commented Jul 8, 2020 via email

Copy link
Copy Markdown
Collaborator

@sumpfralle sumpfralle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

After going through half of the plugins (and commenting them) I noticed, that these look very similar to the set of files below plugins/node.d.freebsd.

Maybe you could describe, where are the relevant differences? Maybe these can be incorporated without creating a code copy (which would increase the maintenance burden)?

Comment thread plugins/node.d.midnightbsd/coretemp Outdated
if [ -n "$cpus" ] ; then
echo "yes"
else
echo "no"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is always helpful for users, if no is suffixed with a reason (e.g. no (empty output of 'sysctl dev.cpu')).

Comment thread plugins/node.d.midnightbsd/coretemp Outdated
reqcpus
for cpu in $cpus ; do
echo -n "CPU$cpu.value "
sysctl -n dev.cpu.$cpu.temperature | tr -d C
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please quote the variable. shellcheck will appreciate this ...

Comment thread plugins/node.d.midnightbsd/coretemp Outdated
;;
config)
config
;;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reduce indentation.

Comment thread plugins/node.d.midnightbsd/cpu Outdated
echo yes
exit 0
else
echo no
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a reason for no.

Comment thread plugins/node.d.midnightbsd/cpu Outdated
exit 0
fi
else
echo no
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add something like (executable 'sysctl' not found).

Comment thread plugins/node.d.midnightbsd/if_errcoll_ Outdated
netstat -i -b -n | sed -n -e '/^faith/d' -e '/^lo[0-9]/d' -e '/^pf(log|sync)/d' -e '/<Link#[0-9]*>/s/\** .*//p'
exit 0
else
exit 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a helpful error message?

Comment thread plugins/node.d.midnightbsd/if_errcoll_ Outdated
echo 'graph_category network'
echo "graph_info This graph shows the amount of errors and collisions on the $INTERFACE network interface."
echo 'ierrors.label Input Errors'
echo 'ierrors.type COUNTER'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reduce indentation.

Comment thread plugins/node.d.midnightbsd/if_errcoll_ Outdated
exit 0
fi;

/usr/bin/netstat -i -b -n -I $INTERFACE | awk '
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please quote $INTERFACE.

Comment thread plugins/node.d.midnightbsd/if_packets_ Outdated
echo yes
exit 0
else
echo "no (/usr/bin/netstat not found)"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention /sbin/ifconfig.

Comment thread plugins/node.d.midnightbsd/if_packets_ Outdated
}'

else
/usr/bin/netstat -i -b -n -I $INTERFACE | awk '
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please quote $INTERFACE.

@laffer1
Copy link
Copy Markdown
Contributor Author

laffer1 commented Jul 9, 2020

I pushed a newer commit that removes the entire node.d.midnightbsd directory and uses the existing freebsd scripts with modifications to check uname output as needed.

Copy link
Copy Markdown
Collaborator

@sumpfralle sumpfralle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank your for minimizing your set of changes! This looks fine to me now.

Please take a look at my minor nitpicks below and please squash your commits into one.

Thank you!

Comment thread plugins/node.d/smart_ Outdated
# Ignore Memory Disks, CD-ROM drives and Floppy
continue
try:
verboselog('Trying '+drive+'...')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add spaces around operators (+). PEP8 (and flake8) would appreciate this.

Comment thread plugins/node.d.freebsd/cpu Outdated
OSV=`$SYSCTL_BIN -n kern.osrelease | cut -f1 -d.`
if [ "$OSV" = "4" ]; then
if [ $(uname -s) = "MidnightBSD" ]; then
STATUNITS=`$SYSCTL_BIN -n kern.clockrate | cut -f13 -d' '`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, you mixed up tabs and spaces here.

Additionally it would be great, if you could quote $(uname -s) in order to avoid and potential whitespace issues (and to please shellcheck).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After taking another look at it: maybe you can just add the condition to the branch for "$OSV -ge "5" below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the order so that the $(uname -s) = "MidnightBSD" || "$OSV -ge "5" check is before "$OSV" = "4" instead. Otherwise, when MidnightBSD hits version 4, things will break.

Comment thread plugins/node.d/smart_ Outdated
continue
except Exception as exc:
verboselog('Failed to list FreeBSD disks: {}'.format(exc))
elif os.uname()[0] == "MidnightBSD":
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After taking another look at this: I think, you can avoid code duplication here by simply changing the above condition from elif os.uname()[0] == "NetBSD" to elif os.uname()[0] in {"NetBSD", "MidnightBSD"}:.

And maybe customize the final error message as verboselog('Failed to list {} disks: {}'.format(os.uname()[0], exc))

Comment thread plugins/node.d/hddtemp_smartctl Outdated
opendir(DEV, '/dev');
@drives = grep /^(ada?|da)[0-9]+$/, readdir DEV;
closedir(DEV);
} elsif ($^O eq 'midnightbsd') {
Copy link
Copy Markdown
Collaborator

@sumpfralle sumpfralle Jul 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as above - maybe just use } elsif (($^O eq 'freebsd') || ($^O eq 'midnightbsd')) {.

Every line counts :)

@laffer1
Copy link
Copy Markdown
Contributor Author

laffer1 commented Jul 13, 2020

I've made the changes requested.

@daftaupe
Copy link
Copy Markdown

Hello, is that still expected to be merged someday ?
It would be a good basis to add DragonFlyBSD support :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

6 participants