-
Notifications
You must be signed in to change notification settings - Fork 474
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
base: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 3007
💛 - Coveralls |
On Tue, Jul 07, 2020 at 02:25:41PM -0700, Lucas Holt wrote:
-- Commit Summary --
* Add support for MidnightBSD to a number of plugins
-- File Changes --
M contrib/plugin-gallery/print-gallery.awk (1)
M doc/installation/install.rst (17)
A plugins/node.d.midnightbsd/coretemp (100)
A plugins/node.d.midnightbsd/cpu (103)
A plugins/node.d.midnightbsd/dev_cpu_ (138)
A plugins/node.d.midnightbsd/df (57)
A plugins/node.d.midnightbsd/df_inode (69)
A plugins/node.d.midnightbsd/if_ (109)
A plugins/node.d.midnightbsd/if_errcoll_ (80)
[10 more plugins]
is midnightbsd really so much different from FreeBSD (from which it was
forked), NetBSD and OpenBSD that it needs special plugins?
…--
cheers,
Holger
-------------------------------------------------------------------------------
holger@(debian|reproducible-builds|layer-acht).org
PGP fingerprint: B8BF 5413 7B09 D35C F026 FE9D 091A B856 069A AA1C
|
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 }, |
On Wed, Jul 08, 2020 at 07:28:34AM -0700, Lucas Holt wrote:
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 think that's preferable, thanks.
…--
cheers,
Holger
-------------------------------------------------------------------------------
holger@(debian|reproducible-builds|layer-acht).org
PGP fingerprint: B8BF 5413 7B09 D35C F026 FE9D 091A B856 069A AA1C
|
There was a problem hiding this 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)?
plugins/node.d.midnightbsd/coretemp
Outdated
if [ -n "$cpus" ] ; then | ||
echo "yes" | ||
else | ||
echo "no" |
There was a problem hiding this comment.
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')
).
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 |
There was a problem hiding this comment.
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 ...
plugins/node.d.midnightbsd/coretemp
Outdated
;; | ||
config) | ||
config | ||
;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reduce indentation.
plugins/node.d.midnightbsd/cpu
Outdated
echo yes | ||
exit 0 | ||
else | ||
echo no |
There was a problem hiding this comment.
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
.
plugins/node.d.midnightbsd/cpu
Outdated
exit 0 | ||
fi | ||
else | ||
echo no |
There was a problem hiding this comment.
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)
.
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 |
There was a problem hiding this comment.
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?
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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reduce indentation.
exit 0 | ||
fi; | ||
|
||
/usr/bin/netstat -i -b -n -I $INTERFACE | awk ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please quote $INTERFACE
.
echo yes | ||
exit 0 | ||
else | ||
echo "no (/usr/bin/netstat not found)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mention /sbin/ifconfig
.
}' | ||
|
||
else | ||
/usr/bin/netstat -i -b -n -I $INTERFACE | awk ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please quote $INTERFACE
.
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. |
There was a problem hiding this 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!
plugins/node.d/smart_
Outdated
# Ignore Memory Disks, CD-ROM drives and Floppy | ||
continue | ||
try: | ||
verboselog('Trying '+drive+'...') |
There was a problem hiding this comment.
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.
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' '` |
There was a problem hiding this comment.
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
).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
plugins/node.d/smart_
Outdated
@@ -589,6 +589,23 @@ def find_smart_drives(): | |||
continue | |||
except Exception as exc: | |||
verboselog('Failed to list FreeBSD disks: {}'.format(exc)) | |||
elif os.uname()[0] == "MidnightBSD": |
There was a problem hiding this comment.
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))
plugins/node.d/hddtemp_smartctl
Outdated
@@ -187,6 +187,10 @@ if ($^O eq 'linux') { | |||
opendir(DEV, '/dev'); | |||
@drives = grep /^(ada?|da)[0-9]+$/, readdir DEV; | |||
closedir(DEV); | |||
} elsif ($^O eq 'midnightbsd') { |
There was a problem hiding this comment.
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 :)
I've made the changes requested. |
Hello, is that still expected to be merged someday ? |
No description provided.