diff --git a/inbox/ORACLE CZ/product.bisnode.cz/scripts/init_sets.sh b/inbox/ORACLE CZ/product.bisnode.cz/scripts/init_sets.sh new file mode 100644 index 0000000..955c910 --- /dev/null +++ b/inbox/ORACLE CZ/product.bisnode.cz/scripts/init_sets.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# modify by Puppet !!! +# verze:2.1 +# defunije funkce pushLog() Notify() makePID() removePID() +# autor: Ales Cernik +# + +myScript=${0##*/} +#myPath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #" +export logDir=${logDir:="/opt/log"} +[ ! -d $logDir ] && logDir="/srv/log" +[ ! -d $logDir ] && { "Neexistuje $logDir"; exit 1;} +logFile=${logDir}/${myScript}.log +myHost=$(/bin/hostname -a) +NAGIOSHOST="centreon.bisnode.cz" +lock_file=/tmp/${myScript}.pid + +pushLog () { + echo "$1 $2 $3 $4 $5 $6 $7 $8 $9" >>$logFile +} + +Notify () { # $1 - status 0=OK, 1=Warning, 2=Error $2 message + if [ ${NAGIOSHOST} != "" ]; then + pushLog $2 + /bin/echo -e "${myHost};${myScript};${1};${2}" | /usr/sbin/send_nsca -H ${NAGIOSHOST} -d \; + fi +} + +## vyhradni spousteni procesu +makePID () { + cat /dev/null >> $lock_file || { Notify 2 "nelze udelat PID file"; exit 1;} + read lastPID < $lock_file +# if lastPID is not null and a process with that pid exists , exit + [ ! -z "$lastPID" -a -d /proc/$lastPID ] && exit + [ -z $$ ] && { Notify 2 "Chybi PID parametr" ; exit 1; } + echo $$ > $lock_file || { Notify 2 "Nelze zapsat PID" ; exit 1; } +} + +removePID () { + rm $lock_file +} +