Add support for MidnightBSD to a number of plugins#1342
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
|
sumpfralle
left a comment
There was a problem hiding this comment.
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)?
| if [ -n "$cpus" ] ; then | ||
| echo "yes" | ||
| else | ||
| echo "no" |
There was a problem hiding this comment.
It is always helpful for users, if no is suffixed with a reason (e.g. no (empty output of 'sysctl dev.cpu')).
| 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.
Please quote the variable. shellcheck will appreciate this ...
| ;; | ||
| config) | ||
| config | ||
| ;; |
There was a problem hiding this comment.
Please reduce indentation.
| echo yes | ||
| exit 0 | ||
| else | ||
| echo no |
There was a problem hiding this comment.
Please add a reason for no.
| exit 0 | ||
| fi | ||
| else | ||
| echo no |
There was a problem hiding this comment.
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.
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.
Please reduce indentation.
| exit 0 | ||
| fi; | ||
|
|
||
| /usr/bin/netstat -i -b -n -I $INTERFACE | awk ' |
There was a problem hiding this comment.
Please quote $INTERFACE.
| echo yes | ||
| exit 0 | ||
| else | ||
| echo "no (/usr/bin/netstat not found)" |
There was a problem hiding this comment.
Please mention /sbin/ifconfig.
| }' | ||
|
|
||
| else | ||
| /usr/bin/netstat -i -b -n -I $INTERFACE | awk ' |
There was a problem hiding this comment.
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. |
sumpfralle
left a comment
There was a problem hiding this comment.
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!
| # Ignore Memory Disks, CD-ROM drives and Floppy | ||
| continue | ||
| try: | ||
| verboselog('Trying '+drive+'...') |
There was a problem hiding this comment.
Please add spaces around operators (+). PEP8 (and flake8) would appreciate this.
| 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.
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.
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.
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.
| 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.
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))
| opendir(DEV, '/dev'); | ||
| @drives = grep /^(ada?|da)[0-9]+$/, readdir DEV; | ||
| closedir(DEV); | ||
| } elsif ($^O eq 'midnightbsd') { |
There was a problem hiding this comment.
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.