Hi folks,
another task ahead of me ...
Maybe you could give me a little idea about how to proceed.
I got a nice little monitoring script. Something like this (short version, just to make clear where the problem is):
I keep the window containing the script active, running on screen of a monitoring PC.
Question is: Is it possible to modify the script, so that it would be possible to enter a command (e.g. restart the archiver, if it goes down) without having to interrupt the while statement ?
A first I thought of using functions somehow. Like this:
But that's not it yet. It reads my Inputs, but keeps clearing them every 2 seconds, so I have to be extremely fast, which is quite impossible if I'm trying to enter longer commands. Increasing the sleep value wouldn't work either, because e.g. if I set it to 30 and accidently start entering the command after let's say 28 seconds I'm facing the same problem again. I need a way to separate the checking function from the input function ...
What am I missing ?
How else could I solve this problem ?
Regards,
Thomas
another task ahead of me ...
Maybe you could give me a little idea about how to proceed.
I got a nice little monitoring script. Something like this (short version, just to make clear where the problem is):
Code:
clear
while [ 1 = 1 ];
do
arcstat=$(ps -ef | grep archiver | wc -l)
clear
case $arcstat in
0) echo "Archiver NOT running !";;
*) echo "Archiver running";;
esac
sleep 30
done
I keep the window containing the script active, running on screen of a monitoring PC.
Question is: Is it possible to modify the script, so that it would be possible to enter a command (e.g. restart the archiver, if it goes down) without having to interrupt the while statement ?
A first I thought of using functions somehow. Like this:
Code:
function checking
{
clear
while [ 1 = 1 ];
do
arcstat=$(ps -ef | grep archiver | wc -l)
clear
case $arcstat in
0) echo "Archiver NOT running !";;
*) echo "Archiver running";;
esac
sleep 2
done
}
function input
{
while [ 1 = 1 ];
do
read action
case $action in
Q|q) kill $checkingpid
;;
*) $action;;
esac
done
}
checking &
checkingpid=$!
input
But that's not it yet. It reads my Inputs, but keeps clearing them every 2 seconds, so I have to be extremely fast, which is quite impossible if I'm trying to enter longer commands. Increasing the sleep value wouldn't work either, because e.g. if I set it to 30 and accidently start entering the command after let's say 28 seconds I'm facing the same problem again. I need a way to separate the checking function from the input function ...
What am I missing ?
How else could I solve this problem ?
Regards,
Thomas