Skip to content

Instantly share code, notes, and snippets.

@jeffgeiger
Last active April 7, 2022 20:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffgeiger/5102259 to your computer and use it in GitHub Desktop.
Save jeffgeiger/5102259 to your computer and use it in GitHub Desktop.
A generic stand-in for munin-node written to run on AIX, may work elsewhere.
#!/bin/ksh
#Connected - echo basic info
echo "# munin node at `hostname`"
#watchdog timestamp
WD_TIME=$(perl -e 'print time')
#looped function
function main {
read cmd arg
if [ -n "$arg" ]; then
arg=$(echo $arg | sed 's/\^M//g')
else
cmd=$(echo $cmd | sed 's/\^M//g')
fi
case $cmd in
"list")
#echo "bdf cpu load memory uptime processes ps_zombies users"
echo $( ls -1 /opt/munin/plugins | tr '\n' ' ')
;;
"nodes")
echo `hostname`
echo "."
;;
"version")
echo "munin node on `hostname` version: KSH"
;;
"config") #check for $arg, error if none, else pass to config
if [ -f "/opt/munin/plugins/$arg" ]; then
/opt/munin/plugins/$arg config
else
echo "# Unknown service"
fi
echo "."
;;
"fetch") #check for $arg, error if none, else pass to fetch
if [ -f "/opt/munin/plugins/$arg" ]; then
/opt/munin/plugins/$arg
else
echo "# Unknown service"
fi
echo "."
;;
"quit")
exit 0
;;
*)
echo "# Unknown command. Try list, nodes, config, fetch, version or quit"
;;
esac
}
while :; do
main
done
exit 0
###############
# Notes
###############
#
#Add this to /etc/services:
#munin-node 4949/tcp
#
#And this to /etc/inetd.conf
#munin-node stream tcp nowait root /opt/munin/munin-node munin-node
#
#Plugins go in /opt/munin/plugins
@benedikt-wegmann
Copy link

Hello!

Thanks for providing this script, it saves me from having to compile munin on an aging AIX system! ❤️

The line arg=$(echo $arg | sed 's/\^M//g') was giving me trouble as it didn't remove the ^M on my AIX box. However, arg=$(echo $arg | tr -d '\r') does.

Cheers! 🍻

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