Tag Archives: SERVICE

Assistiance in small bash script

By Aviel.shani

Hi All,
i wrote an simple script, that will monitor some services ,and if particular service will found down ,the code will restarts the service and message about the process will be sent on mail.

I have a problem somewhere in the syntax that the script initializes the service even if is up ..

Your help please, what should I fix the code :

#!/bin/bash
# Simple script that uses systemctl to check if a service is
# running. If its not it is restarted and an email is sent to
# the configured mailbox.
SERVICE=/etc/init.d/xinetd
MAILBOX=*********
STATUS=”/etc/init.d/xinetd status”
if [ “$SERVICE status” != ‘xinetd is stopped’ ]
then
/etc/init.d/xinetd restart
$STATUS | mail -s “the xinet.d service getting restart” $MAILBOX
fi
exit 0

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Help/Advise on parsing these line of text

By newbie_01

Hi,

Can anyone please advise how do I parse the following line of strings?


14-OCT-2012 06:38:59 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINifrun60.EXE)(HOST=8000XXX05004RV)(USER=mickey))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1552)) * establish * test * 0
14-OCT-2012 06:39:15 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINRWRBE60.exe)(HOST=8000XXX05004RV)(USER=mickey))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1574)) * establish * test * 0
14-OCT-2012 06:40:48 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINifrun60.EXE)(HOST=8200XXX138060Z)(USER=mouse))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.217.35.94)(PORT=2525)) * establish * test * 0
14-OCT-2012 07:01:04 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=server911)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=test)(VERSION=135296000)) *
status * 0


– I am wanting parse or de-construct it so that I can get the HOST, PROGRAM and USER

– awk’s -F and cut only accept single delimiter so am lost on how to parse these strings.

– Feedback/advise much appreciated. Thanks in advance.

Source: FULL ARTICLE at The UNIX and Linux Forums

Help with awk using * (asterisk) as the delimiter

By newbie_01

Hi

I am trying to parse the following lines and has to use * (asterisk) as the delimiter.

These lines are in a file, for example tmp.txt and I am using a while loop


tmp.txt:

14-OCT-2012 06:38:59 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINifrun60.EXE)(HOST=8000XXX05004RV)(USER=mickey
))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1552)) * establish * test * 0
14-OCT-2012 06:39:15 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINRWRBE60.exe)(HOST=8000XXX05004RV)(USER=mickey
))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.90.24.239)(PORT=1574)) * establish * test * 0
14-OCT-2012 06:40:48 * (CONNECT_DATA=(SID=test)(GLOBAL_NAME=test.mydb.com.ch)(CID=(PROGRAM=Z:Ora6iBINifrun60.EXE)(HOST=8200XXX138060Z)(USER=mouse))) * (ADDRESS=(PROTOCOL=tcp)(HOST=11.217.35.94)(PORT=2525)) * establish * test * 0
14-OCT-2012 07:01:04 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=server911)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=test)(VERSION=135296000)) *
status * 0

- while loop code block

while read line
do
echo " ---> Parsing ---> "
echo " - $line"
echo ""
timestamp=`echo $line | awk -F* '{ print $1 }'`
echo " - timestamp = ${timestamp}"
echo ""
echo ""
done < ${pid}.tmp.01


Instead of just getting the timestamp, I am getting the timestamp plus what looks like a directory listing of all files, i.e. like a timestamp and echo * of the directory that I am in.

Can anyone please advise how to get around this?

Feeback/advise much appreciated. Thanks in advance.

Source: FULL ARTICLE at The UNIX and Linux Forums