Notify when the script run(hourly)on my jump-box only when there is a failure on my remote-box

Team,

Presently I have a script, which i have set up cron on one of my Jump-boxes,and gives me the output on every hourly basis,fetching the data from the remote machine.Basically it gives me the list of all active users logged and its count once we execute the script.Here the count is mentioned/specified as Total Transaction(column)and users are mentioned as List of users(column).
Currently there are 100 users(different names) and the count is 100

below is the main script details

FILEDATE=`date +%F`
LOGFILE=/home/xyz/scripts/myscript.$FILEDATE.log
find /home/xyz/scripts/myscript.*.log -type f -mtime -3 -delete
touch $LOGFILE
exec 1>$LOGFILE 2>&1
for ip_addr in $(cat /home/xyz/scripts/ip_remote);do
echo "###logged into $ip_addr### "
ssh ${ip_addr} "bash -s" < /home/xyz/scripts/hourly_details
echo "###logged out  $ip_addr###"
done
cat /home/xyz/scripts/myscript.$FILEDATE.log | mailx -s "Hourly active users" <ur email id>

the ip_remote consist of the remote ip address its going to login
the hourly_details consist of below

sudo su - abc
sh active.sh

Basically, I am looking to execute the script hourly on my jump-box but to notify me only when any of the users(List of users) are down and as per its count(Total Transactions).
Is there any way around ?

Regards
Whizkid

How about NOT logging anything but errors, and finally checking the log file's size?

No, basically it has to alert us incase any of the users are down and with the count status.. I dont need to manually log into the jumpbox to check the logs size etc..

Regards
Whizkidash

What's the content of active.sh ?

I see two possible approaches for your requirement:

  1. After the "run" (for loop): Parsing /home/xyz/scripts/myscript.$FILEDATE.log for "errors"
  2. During the "run": Extend active.sh to create /home/xyz/scripts/myscript.$FILEDATE.err on-the-fly as it encounters errors.

I vote for 2.

Make sure you extend your main script as follows:

#Before the for loop (to avoid false-positives)
Delete /home/xyz/scripts/myscript.*.err
Don't "touch" it afterwards.

#After the for loop

ERRFILE=/home/xyz/scripts/myscript.$FILEDATE.err
if [ -e "$ERRFILE" ]; then
cat "$ERRFILE" | mailx -s "Hourly active users: ERROR" <ur email id>
fi

Hey Junior,

Between the active.sh consist mix of various shell script calling multiple scripts within...

Between, I do get the below output in my log as below:

Partner_id      TX   RX   TR   Totals for: 11/17/2014:05:07
Alpha                    8    9    0     17
Beta                     0    0    6      6
Charlie               8    8    0     16
Bravo               20   11    0     31
Indigo                0    0    1      1
Sigma                6    0    0      6
Omega             1    1    0      2
TOTALS         375  287  181    843
TOTAL Partners =  7

As described earlier, i just need to monitor just the Partner_id(column) and the total partners count, and notify me incase the count goes down and any of the users missing from the Partner_id column.

Both the points mentioned by you, is not meeting my goal..Need more inputs as per the points mentioned above.

Regards
Whizkid

Please tell us exactly and verbosely WHAT is correct and WHAT is an error. Intercept the result of the remote command and compare it to what you need it to be. If it is OK, don't log it. If it isn't, log it. If, at the end, logs exist, mail them.

Hi Rudi,

I need the logs, but need to highlight it as to which one is down.(as mentioned below in the example)

I am looking to execute the script hourly basis on my jump-box and to notify me with the below mentioned output.

eg:

Below Partner_id is down: <Partner_id> (if the user is down)
All Partner_id is ok (If every thing is fine)

the Total partners: count <as per the latest update, with the total count>

Hope everthing is clear now.