I’ve written a pip2mkp tool to create MKPs from “pip”-installed packages. I create an empty site, then do a recursive install of the required package and recursivly create the MKPs.
Adding or just packaging your own files will work with this concept, too:
Create an empty instance
Copy your files inside
su into your new instance
Run “mkp template new_package_name”
Edit the template_file
Run “mkp package template_file”
Copy/use the installed package from ~/var/check_mk/packages_local
The script “pip2mkp” if you need this for python packages (CAUTION: This script uses a lot of “rm -R” and really really really should be run in an empty instance!!!):
#!/usr/bin/bash
. /etc/os-release
pip3="/usr/bin/env python3 -m pip install --upgrade"
export PYTHONUSERBASE="$OMD_ROOT/local"
export PIP_TARGET="$OMD_ROOT/local/lib/python3"
export PIP_DISABLE_PIP_VERSION_CHECK="True"
PACKAGE=$1
if [ $# -eq 0 ] ; then
echo "No package name given!"
echo -e "Usage:\n\t$0 PYTHON_PACKAGE"
exit
fi
rm $PACKAGE-MKPs/*
mkdir $PACKAGE-MKPs
cd $PACKAGE-MKPs
PACKAGE_VERSION=`omd version -b|sed 's/p.*\.*//' | sed 's/b.*\.*//'`-$VERSION_CODENAME
PYTHON_VERSION=`python3 --version`
AUTHOR="Your Name"
DOWNLOAD_URL=""
rm -R ~/var/check_mk/packages/*
rm -R $PIP_TARGET/*
$pip3 $PACKAGE
$pip3 pipdeptree
$PIP_TARGET/bin/pipdeptree -f -p $PACKAGE | sed 's/ //g'|tac| awk '!seen[$0]++' > requirements.txt
rm -R ~/var/check_mk/packages/*
rm -R ~/var/check_mk/packages_local/*
rm -R $PIP_TARGET/bin/pipdeptree
rm -R $PIP_TARGET/*
mkdir $PIP_TARGET/cmk
requirements=`cat requirements.txt`
for requirement in $requirements ; do
TITLE=`echo $requirement|sed 's/==/-/'`
$pip3 $requirement
requirement_stripped=`echo $requirement | sed 's/==/-/' | sed -e 's/[^A-Za-z0-9_-]/_/g'`
echo "Creating $requirement_stripped"
mkp template $requirement_stripped
# replace fields in ~/tmp/check_mk/$requirement_stripped.manifest.temp
sed -i "s/Title of $requirement_stripped/$TITLE/" ~/tmp/check_mk/$requirement_stripped.manifest.temp
sed -i "s/https:.*\//$DOWNLOAD_URL/" ~/tmp/check_mk/$requirement_stripped.manifest.temp
sed -i "s/Add your name here/$AUTHOR/" ~/tmp/check_mk/$requirement_stripped.manifest.temp
sed -i "s/'1.0.0'/'$PACKAGE_VERSION'/" ~/tmp/check_mk/$requirement_stripped.manifest.temp
DESCRIPTION="This is the $PYTHON_VERSION package $TITLE as MKP for Checkmk $PACKAGE_VERSION"
sed -i "s/Please add a description here/$DESCRIPTION/" ~/tmp/check_mk/$requirement_stripped.manifest.temp
echo "Packing $requirement_stripped"
mkp package ~/tmp/check_mk/$requirement_stripped.manifest.temp
done
Execution of “pip2mkp envelope” under Debian 10 resulted in these packages: