Skip to content

Instantly share code, notes, and snippets.

@josy1024
Created February 12, 2016 18:55
Show Gist options
  • Save josy1024/ff0dbac4567e26afe57c to your computer and use it in GitHub Desktop.
Save josy1024/ff0dbac4567e26afe57c to your computer and use it in GitHub Desktop.
relaxed universal logging script linux
#!/bin/bash
# das pzs "functions.sh" file
# logging function
# parameter 1: OK ERROR OK_START, OK_DONE
# parameter 2: code
logstats="https://logurl.domain.com/api/rw/l.php"
http_user="user"
http_pass='pass'
function gstatslog
{
code=$2
ok=$1
post=$3
[ -e /usr/bin/wget ] && /usr/bin/wget --timeout=10 --tries=2 --no-check-certificate --http-user="$http_user" --http-password="$http_pass" "${logstats}?val=$HOSTNAME&code=$1_${code}${post}" -O "/tmp/$1_$HOSTNAME" >/dev/null 2>&1
[ ! -e /usr/bin/wget ] && [ -e /usr/bin/curl ] && /usr/bin/curl --connect-timeout 10 --insecure --silent --digest --user "$http_user":"$http_pass" --url "${logstats}?val=$HOSTNAME&code=$1_${code}${post}" >/dev/null 2>&1
}
post=""
if [ ! -z "$3" ]
then
post="%23_$3"
fi
gstatslog $1 $2 $post
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment