added headers for curl
This commit is contained in:
35
checkmk.sh
35
checkmk.sh
@@ -26,14 +26,15 @@ set -e
|
||||
|
||||
url="gauntcheckmk.home.johnhgaunt.com/Gaunt"
|
||||
user="automation"
|
||||
pass="$3"
|
||||
pass="$1"
|
||||
header="Authorization: Bearer ${user} ${pass}"
|
||||
read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" host
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
|
||||
if [ -x /usr/bin/dpkg ]; then
|
||||
tmpfile=$tmpdir/checkmkagent.deb
|
||||
wget -O $tmpfile "$url/check_mk/api/1.0/domain-types/agent/actions/download/invoke?os_type=linux_deb"
|
||||
wget -O $tmpfile -H "${header}" "${url}/check_mk/api/1.0/domain-types/agent/actions/download/invoke?os_type=linux_deb"
|
||||
if dpkg -l check-mk-agent > /dev/null; then
|
||||
dpkg -P check-mk-agent
|
||||
fi
|
||||
@@ -41,7 +42,7 @@ if [ -x /usr/bin/dpkg ]; then
|
||||
dpkg -i $tmpfile
|
||||
elif [ -x /usr/bin/rpm -o -x /bin/rpm ]; then
|
||||
tmpfile=$tmpdir/checkmkagent.rpm
|
||||
wget -O $tmpfile "$url/check_mk/api/1.0/domain-types/agent/actions/download/invoke?os_type=linux_rpm"
|
||||
wget -O $tmpfile -H "${header}" "${url}/check_mk/api/1.0/domain-types/agent/actions/download/invoke?os_type=linux_rpm"
|
||||
if rpm -q check-mk-agent > /dev/null; then
|
||||
rpm -e check-mk-agent
|
||||
fi
|
||||
@@ -62,12 +63,12 @@ rm -fv /etc/cmk-update-agent.state
|
||||
echo
|
||||
read -p "Agent installed"
|
||||
|
||||
curl -v "$url/check_mk/webapi.py?action=add_host&_username=$user&_secret=$pass" -d "request={\"hostname\": \"$host\", \"folder\": \"Servers\"}"
|
||||
curl -v "${url}/check_mk/webapi.py?action=add_host&_username=$user&_secret=$pass" -d "request={\"hostname\": \"$host\", \"folder\": \"Servers\"}"
|
||||
|
||||
echo
|
||||
read -p "Host created"
|
||||
|
||||
curl -v "$url/check_mk/webapi.py?action=activate_changes&_username=$user&_secret=$pass"
|
||||
curl -v "${url}/check_mk/webapi.py?action=activate_changes&_username=$user&_secret=$pass"
|
||||
|
||||
# test if not a VM and if so, install the smartctl stuff
|
||||
if [ "${VM}" == "false" ]; then
|
||||
@@ -82,20 +83,28 @@ fi
|
||||
echo
|
||||
read -p "Changes activated"
|
||||
|
||||
/usr/bin/cmk-update-agent register -v -U $user -S $pass -H $host
|
||||
/usr/bin/cmk-agent-ctl register --hostname $host \
|
||||
--server gauntcheckmk.home.johnhgaunt.com --site Gaunt \
|
||||
--user $user --password $pass \
|
||||
--trust-cert
|
||||
|
||||
echo
|
||||
read -p "Agent Updater registered"
|
||||
read -p "Agent registered"
|
||||
|
||||
curl -v "$url/check_mk/webapi.py?action=bake_agents&_username=$user&_secret=$pass"
|
||||
#/usr/bin/cmk-update-agent register -v -U $user -S $pass -H $host
|
||||
|
||||
echo
|
||||
read -p "Agents baked"
|
||||
#echo
|
||||
#read -p "Agent Updater registered"
|
||||
|
||||
/usr/bin/cmk-update-agent -v
|
||||
#curl -v "$url/check_mk/webapi.py?action=bake_agents&_username=$user&_secret=$pass"
|
||||
|
||||
echo
|
||||
read -p "Agent updated"
|
||||
#echo
|
||||
#read -p "Agents baked"
|
||||
|
||||
#/usr/bin/cmk-update-agent -v
|
||||
|
||||
#echo
|
||||
#read -p "Agent updated"
|
||||
|
||||
curl -v "$url/check_mk/webapi.py?action=discover_services&_username=$user&_secret=$pass" -d "request={\"hostname\": \"$host\"}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user