Skip to content

Add osx agent, OSX-compatible mk-job#145

Closed
catchdave wants to merge 3 commits into
Checkmk:masterfrom
catchdave:add-osx-agent
Closed

Add osx agent, OSX-compatible mk-job#145
catchdave wants to merge 3 commits into
Checkmk:masterfrom
catchdave:add-osx-agent

Conversation

@catchdave
Copy link
Copy Markdown

@catchdave catchdave commented Mar 18, 2020

Better OSX agent:

  • I adapted the OSX version of the agent originally found at: ThomasKaiser/Check_MK. This seems to be more modern that the version in this repo, I believe.
  • I added OSX support for lnx_if since the original netctr is no longer supported in check_mk.
  • I fixed a bug that breaks smartctl stats for NVME drives in OSX
  • Added a OSX version for mk-job (<<<job>>>). Different than original since head is non-GNU

Modified mk-job for OSX

  • OSX is BSD-based and therefore time does not work as written. It is common for OSX systems to use brew to install GNU-tools, so mk-job will now work as long as gnu-time is installed.

Installer for OSX agent
I could not find instructions for installing the OSX agent anywhere. So I put together a simple script that I used to install on my mac machines. I have done ZERO testing outside of my 2 machines.

# is a sub directory per user that ran a job. That directory must be
# owned by the user so that a symlink or hardlink attack for reading
# arbitrary files can be avoided.
JOB_DIR="$MK_VARDIR/job"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is new code added by me: Add OSX version of mk-job

print $1,$7,$5,$6,"0","0","0","0","0",$10,$8,$9,"0","0",$11,"0","0"; }'
# FIXME: send netstat -inb plain, write proper check plugins for
# clean parsing of the output
# Mac version of lnx_if. Needs `iproute2mac` to have been installed.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is new code: replace netctr with osx version of lnx_if

@jonaskluger
Copy link
Copy Markdown
Contributor

Hello catchdave,

thank you for this pull request. We will have a closer look at your patch and discuss internally on how and if we can implement it into the official code base.

Internal Ref: CMK-4103

@Notausstieg0309
Copy link
Copy Markdown
Contributor

I have tested your proposed MacOS Agent on my MacMini's with macOS 10.15.4.

Regarding the lnx_if: Your implementation does not work for my machines as they have no homebrew software installed. So I have used the implementation from #180 together with your agent, as it supports plugins which is essential to me.

Copy link
Copy Markdown
Contributor

@Notausstieg0309 Notausstieg0309 left a comment

Choose a reason for hiding this comment

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

I would suggest some slight changes to get a bit closer to the linux agent implementation/behavior.

Comment on lines +38 to +40
export MK_LIBDIR='/usr/local/lib/check_mk_agent'
export MK_CONFDIR='/etc/check_mk'
export MK_VARDIR='/var/lib/check_mk_agent'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please honor the environment before using the default paths as the official linux agent does as well:

Suggested change
export MK_LIBDIR='/usr/local/lib/check_mk_agent'
export MK_CONFDIR='/etc/check_mk'
export MK_VARDIR='/var/lib/check_mk_agent'
export MK_LIBDIR=${MK_LIBDIR:-/usr/local/lib/check_mk_agent}
export MK_CONFDIR=${MK_CONFDIR:-/etc/check_mk}
export MK_VARDIR=${MK_VARDIR:-/var/lib/check_mk_agent}

These paths can be configured via the launch daemon definition to a custom path without modifying the agent.

;;
esac
done
elif type osx-cpu-temp >/dev/null
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

According to Linux Agent, this line should be changed by inserting and using the inpath() function as in the Linux agent:

# Function to replace "if type [somecmd]" idiom
# 'command -v' tends to be more robust vs 'which' and 'type' based tests
inpath() {
    command -v "${1:?No command to test}" >/dev/null 2>&1
}

@mo-ki
Copy link
Copy Markdown
Member

mo-ki commented May 1, 2022

Hi catchdave,

I am sorry to close this PR, in particular because it took us so long.
I am not closing it, because it is awful, but because it is too large to asses it thoroughly. We currently don't have a bigger OSX environment to test it (and, judging from your comment, neither do you). Since I don't expect anyone to be confident enough to merge this in the next few years, I think closing it is the honest thing to do.
At the very least the change in mk-job is worth a dedicated PR, I think.

Cheers,
Moritz

@mo-ki mo-ki closed this May 1, 2022
CheckmkCI pushed a commit that referenced this pull request Nov 18, 2025
Change-Id: Ifd9ff34051096968f6ef6c4b104583c90dd357c8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants