Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


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


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
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

Code:
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

Code:
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

Last edited by Don Cragun; 11-17-2014 at 02:20 AM.. Reason: Fix CODE tags.
# 2  
How about NOT logging anything but errors, and finally checking the log file's size?
# 3  
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
# 4  
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
Code:
ERRFILE=/home/xyz/scripts/myscript.$FILEDATE.err
if [ -e "$ERRFILE" ]; then
cat "$ERRFILE" | mailx -s "Hourly active users: ERROR" <ur email id>
fi

# 5  
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:

Code:
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
# 6  
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.
# 7  
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:

Code:
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.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
How to find remote Linux box login account without login in to that box?
Muthuselvan
Hi, How to find remote Linux box login account without login in to that box? I don't have login account at my remote Linux box. But I need who are all having login account. How do I findout? Thanks, --Muthu.... Linux
3
Linux
ftp file starting with particular name on Windows box to Unix box using shell script
vijayb4u83
Hello all ! I'm trying to write a shell script (bash) to ftp a file starting with particular name like "Latest_" that is present on a Windows box to UNIX server. Basically I want to set this script in the cron so that daily the new build that is posted on the Windows box can be downloaded to the...... Shell Programming and Scripting
2
Shell Programming and Scripting
calling a unix script in one box from another box
trichyselva
i have a unix script which is available in a box say box1 i want this script to be run in box box2 and put the output file in box2 what is the procedure to execute this script in box2 i will call the script in box1 using cybermation... Shell Programming and Scripting
1
Shell Programming and Scripting
Box A's perl script calling box B's shell script
new2ss
Hi all, i have a perl script one server. I am running a cronjob to execute my perl script. #! /usr/bin/perl ... ... ... #call a shell script on another server How can i accomplish #? Do i have to issue a system (" ssh -l username server | shellscript.sh") in my shell script? or is there a...... Shell Programming and Scripting
1
Shell Programming and Scripting
Script to Reboot a linux box from a windows box
Crazy_murli
HI All, I need a script to reboot a linux box from a windows box. The script needs to run automatically whenever a sitescope alerts with an error message. Have searched for this in the forums, but could not get something relative. Pls. let me know the various alternatives we have to do...... Shell Programming and Scripting
2
Shell Programming and Scripting

Featured Tech Videos