Skip to content
Permalink
Browse files

New Agent for MacOS

  • Loading branch information...
Christian Zigotzky
Christian Zigotzky committed May 29, 2012
1 parent 2d6cfdf commit 57255cf24dc8bafb00bff36b833ea7122b6fbc14
Showing with 72 additions and 0 deletions.
  1. +72 −0 agents/check_mk_agent.macosx
@@ -0,0 +1,72 @@
#!/bin/sh
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2010 mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation in version 2. check_mk is distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more de-
# ails. You should have received a copy of the GNU General Public
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
#
# NOTE: This agent has beed adapted from the Check_MK linux agent.

# Remove locale settings to eliminate localized outputs where possible
# Author: Christian Zigotzky <info@xenosoft.de>
export LC_ALL=C
unset LANG

export MK_LIBDIR="/to/be/changed"
export MK_CONFDIR="/to/be/changed"

echo '<<<check_mk>>>'
echo Version: 1.2.0b5
echo AgentOS: macosx

osver="$(uname -r)"

echo '<<<df>>>';
df -kPt hfs | sed -e 's/^\([^ ][^ ]*\) \(.*\)$/\1 hfs \2/' | sed 1d

echo '<<<cpu>>>';
echo `sysctl -n vm.loadavg | tr -d '{}'` `top -l 1 -n 1 | egrep ^Processes: |
awk '{print $4"/"$2;}'` `echo 'echo $$' | bash` `sysctl -n hw.ncpu`

echo '<<<uptime>>>';
echo `date +%s` - `sysctl -n kern.boottime | cut -d' ' -f 4,7 | tr ',' '.' |
tr -d ' '` | bc

echo '<<<netctr>>>';
date +'%s'; netstat -inb | egrep -v '(^Name|lo|plip)' | grep Link | awk '{
print $1,$7,$5,$6,"0","0","0","0","0",$10,$8,$9,"0","0",$11,"0","0"; }'

echo '<<<ps>>>'
ps ax -o user,vsz,rss,pcpu,command | sed -e 1d -e 's/ *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) */(\1,\2,\3,\4) /'

# MK's Remote Plugin Executor
if [ -e "/etc/mrpe.cfg" ]
then
echo '<<<mrpe>>>'
grep -Ev '^[[:space:]]*($|#)' "/etc/mrpe.cfg" | \
while read descr cmdline
do
PLUGIN=${cmdline%% *}
OUTPUT=$(eval "$cmdline")
echo "(${PLUGIN##*/}) $descr $? $OUTPUT" | tr \\n \\1
echo
done
fi

0 comments on commit 57255cf

Please sign in to comment.
You can’t perform that action at this time.