Skip to content
Snippets Groups Projects
Commit aeaaacf3 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

use wget default params; shell fixes

parent 6520c344
No related branches found
No related tags found
1 merge request!11use wget default params; shell fixes
......@@ -10,14 +10,19 @@
# 2020-05-04 v1.1 <axel.hahn@iml.unibe.ch> show message if monitor-uri was not set
# 2020-12-03 v1.2 <axel.hahn@iml.unibe.ch> loop over multiple frontend status urls
# 2021-12-14 v1.3 <axel.hahn@iml.unibe.ch> use updated haproxy paser in sourced file
# 2022-04-01 v1.4 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes
# ======================================================================
. `dirname $0`/inc_pluginfunctions
. `dirname $0`/inc_haproxy_cfg.sh
. $(dirname $0)/inc_pluginfunctions
. $(dirname $0)/inc_haproxy_cfg.sh
cfgfile=/etc/haproxy/haproxy.cfg
tmpfile=/tmp/check_haproxy_healthcheck_$$
paramsWget="-T 5 -t 1 --no-check-certificate"
# ^ ^
# | tries = 1
# timeout in seconds
# ----------------------------------------------------------------------
......@@ -27,7 +32,7 @@ ph.require wget
cat $cfgfile >/dev/null
if [ $? -ne 0 ]; then
ph.abort "UNKNOWN: unable to read ha proxy config $cfgfile ... `ls -l $cfgfile`"
ph.abort "UNKNOWN: unable to read ha proxy config $cfgfile ... $(ls -l $cfgfile)"
fi
cat $cfgfile | grep "\ mode\ .*http" >/dev/null
......@@ -47,16 +52,16 @@ fi
safeurl=$( echo $url | sed "s#\(://\)\(.*@\)#\1#g" )
# --- get status page
wget --no-check-certificate -O $tmpfile $url 2>/dev/null
wget $paramsWget -O $tmpfile $url 2>/dev/null
if [ $? -ne 0 ]; then
rm -f $tmpfile
ph.abort "UNKNOWN: url $safeurl did not respond. `wget --no-check-certificate -O - -S $url`"
ph.abort "UNKNOWN: url $safeurl did not respond. $(wget wget $paramsWget -O - -S $url)"
fi
grep "200 OK" $tmpfile >/dev/null
if [ $? -ne 0 ]; then
ph.setStatus "error"
ph.status "url $safeurl did not contain 200 OK. `wget --no-check-certificate -O - -S $url`"
ph.status "url $safeurl did not contain 200 OK. $(wget wget $paramsWget -O - -S $url)"
else
ph.status "HA Proxy $safeurl is up and running."
fi
......
......@@ -15,10 +15,11 @@
# 2020-06-03 v1.3 <axel.hahn@iml.unibe.ch> added ping to each backend server
# 2020-12-03 v1.4 <axel.hahn@iml.unibe.ch> added support of multiple front- and backends
# 2021-12-14 v1.5 <axel.hahn@iml.unibe.ch> use updated haproxy paser in sourced file
# 2022-04-01 v1.6 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes
# ======================================================================
. `dirname $0`/inc_pluginfunctions
. `dirname $0`/inc_haproxy_cfg.sh
. $(dirname $0)/inc_pluginfunctions
. $(dirname $0)/inc_haproxy_cfg.sh
cfgfile=/etc/haproxy/haproxy.cfg
......@@ -26,6 +27,11 @@ tmpfile=/tmp/check_haproxy_status_$$
tmpfile2=/tmp/check_haproxy_status2_$$
tmpfileping=/tmp/check_haproxy_status3_$$
paramsWget="-T 5 -t 1 --no-check-certificate"
# ^ ^
# | tries = 1
# timeout in seconds
# ----------------------------------------------------------------------
# pre checks
# ----------------------------------------------------------------------
......@@ -102,28 +108,28 @@ urlmasked=$( echo $url | sed "s#\(://\)\(.*@\)#\1#g" )
# --- get status page
wget --no-check-certificate -O $tmpfile $url 2>/dev/null
wget $paramsWget -O $tmpfile $url 2>/dev/null
if [ $? -ne 0 ]; then
rm -f $tmpfile
ph.abort "UNKNOWN: url $urlmasked did not respond. `wget --no-check-certificate -O - -S $url`"
ph.abort "UNKNOWN: url $urlmasked did not respond. $(wget --no-check-certificate -O - -S $url)"
fi
colLimit=`getColnumber "slim"`
colCurrentConnections=`getColnumber "scur"`
colStatus=`getColnumber "status"`
colLimit=$(getColnumber "slim")
colCurrentConnections=$(getColnumber "scur")
colStatus=$(getColnumber "status")
statusFront=`getColumn $colStatus ",FRONTEND," | cut -f 2 -d "," | tr "\n" " "`
statusBack=` getColumn $colStatus ",BACKEND," | cut -f 2 -d "," | tr "\n" " "`
statusFront=$(getColumn $colStatus ",FRONTEND," | cut -f 2 -d "," | tr "\n" " ")
statusBack=$( getColumn $colStatus ",BACKEND," | cut -f 2 -d "," | tr "\n" " ")
typeset -i iMaxConnFront=`getColSum $colLimit ",FRONTEND,"`
typeset -i iMaxConnBack=` getColSum $colLimit ",BACKEND,"`
typeset -i iMaxConnFront=$(getColSum $colLimit ",FRONTEND,")
typeset -i iMaxConnBack=$( getColSum $colLimit ",BACKEND,")
typeset -i iFrontend=`getColSum $colCurrentConnections ",FRONTEND,"`
typeset -i iFrontend=$(getColSum $colCurrentConnections ",FRONTEND,")
typeset -i iFrontendFree=$iMaxConnFront-$iFrontend
typeset -i iBackend=` getColSum $colCurrentConnections ",BACKEND," `
typeset -i iBackend=$( getColSum $colCurrentConnections ",BACKEND," )
typeset -i iBackendFree=$iMaxConnBack-$iBackend
statusExt=
......@@ -160,9 +166,9 @@ ph.perfadd "backend-free" "${iBackendFree}"
getColumn $colCurrentConnections | sed -n "2,$ p" >$tmpfile2
while read line
do
srv=`echo $line | cut -f 1 -d ","`
val=`echo $line | cut -f 2 -d ","`
label=`echo $srv | tr [:upper:] [:lower:]`
srv=$(echo $line | cut -f 1 -d ",")
val=$(echo $line | cut -f 2 -d ",")
label=$(echo $srv | tr [:upper:] [:lower:])
# echo "${srv} - ${val}"
echo -n "${srv} - ${val} "
......
......@@ -19,10 +19,11 @@
# 2019-05-10 v1.0 ah,ds
# 2019-05-22 v1.1 show built date
# 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
# 2022-04-01 v1.3 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes
# ======================================================================
. `dirname $0`/inc_pluginfunctions
. $(dirname $0)/inc_pluginfunctions
tmpOk=/tmp/check_opencpu-ok
tmpErr=/tmp/check_opencpu-error
......@@ -30,6 +31,11 @@ ocpuUrl=http://localhost/ocpu
packages="eosceGLM eosceLinReg eosceReliability eosceReporter msrdAnalytics"
paramsWget="-T 5 -t 1 --no-check-certificate"
# ^ ^
# | tries = 1
# timeout in seconds
# ----------------------------------------------------------------------
# FUNCTIONS
# ----------------------------------------------------------------------
......@@ -40,11 +46,11 @@ function checkOpenCpuPackage(){
pkgUrl=$ocpuUrl/library/$package/info
tmpfile=/tmp/check_opencpu-$package
wget -O $tmpfile $pkgUrl 2>/dev/null
wget $paramsWget -O $tmpfile $pkgUrl 2>/dev/null
if [ $? -ne 0 ]; then
echo "ERROR: package is NOT available [$package]" >>$tmpErr
else
echo "OK: package is available [$mypackage] .. Build: `cat $tmpfile | grep "^Built" | cut -c 21-`" >>$tmpOk
echo "OK: package is available [$mypackage] .. Build: $(cat $tmpfile | grep "^Built" | cut -c 21-)" >>$tmpOk
fi
rm -f $tmpfile 2>/dev/null
}
......@@ -65,10 +71,10 @@ if [ $? -ne 0 ]; then
fi
# ----- check if openCpu is running
wget -O /dev/null $ocpuUrl 2>/dev/null
wget $paramsWget -O /dev/null $ocpuUrl 2>/dev/null
if [ $? -ne 0 ]; then
echo "ERROR: unable to connect to openCpu with $ocpuUrl"
wget -O /dev/null -S $ocpuUrl
wget $paramsWget -O /dev/null -S $ocpuUrl
ph.setStatus "error"
ph.exit
fi
......
......@@ -10,9 +10,10 @@
# 2021-10-01 v0.2 <axel.hahn@iml.unibe.ch> fetch full status as json
# 2021-12-23 v0.4 <axel.hahn@iml.unibe.ch> remove switch to warning level if just one slow request was detected
# 2022-02-11 v0.5 <axel.hahn@iml.unibe.ch> show running workers in 1st line
# 2022-04-01 v0.6 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes
# ======================================================================
. `dirname $0`/inc_pluginfunctions
. $(dirname $0)/inc_pluginfunctions
tmpfile=/tmp/check_fpm_processes_1
defaulturl=localhost/status
......@@ -63,6 +64,7 @@ function _getvalue(){
function showHelp(){
local _self=$(basename $0)
cat <<EOF
______________________________________________________________________
......@@ -90,7 +92,7 @@ For performance data it echos:
php-fpm-speed requests per $sDeltaunit (since last execution of this check)
SYNTAX:
`basename $0` [-u URL]
$_self [-u URL]
OPTIONS:
......@@ -102,7 +104,7 @@ PARAMETERS:
None.
EXAMPLE:
`basename $0` -u http://localhost/my-custom-fpm-statuspage.php
$_self -u http://localhost/my-custom-fpm-statuspage.php
EOF
}
......@@ -130,15 +132,15 @@ ph.require jq wget
# ----------------------------------------------------------------------
# set default / override from command line params
typeset -i iWarnLimit=` ph.getValueWithParam 75 w "$@"`
typeset -i iCriticalLimit=` ph.getValueWithParam 90 c "$@"`
typeset -i iWarnLimit=$( ph.getValueWithParam 75 w "$@")
typeset -i iCriticalLimit=$( ph.getValueWithParam 90 c "$@")
url=$( ph.getValueWithParam $defaulturl u "$@" )
# --- get /server-status page
wget --no-check-certificate -O $tmpfile "$url?full&json" 2>/dev/null
wget $paramsWget -O $tmpfile "$url?full&json" 2>/dev/null
if [ $? -ne 0 ]; then
rm -f $tmpfile
ph.abort "UNKNOWN: request to url $url failed. `wget --no-check-certificate -O - -S $url`"
ph.abort "UNKNOWN: request to url $url failed. $(wget $paramsWget -O - -S $url)"
fi
# ----------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment