How to capture hostnames or ip address in the log files generated?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to capture hostnames or ip address in the log files generated?
# 1  
Old 09-06-2014
How to capture hostnames or ip address in the log files generated?

Team,

I have prepared a script which I run from my remote machine(Jump-box)server
Below is the script

Code:
FILEDATE=`date +%F`
LOGFILE=/home/abc/scripts/xyz.$FILEDATE.log
find /home/abc/scripts/xyz.*.log -type f -mtime -3 -delete
touch $LOGFILE
exec 1>$LOGFILE 2>&1
#healthcheck batch runs here
for ip_addr in $(cat ip_abc);do 
ssh ${ip_addr} "bash -s" < my_script
done

There are 10 different ip address in my ip_abc file,and my_script file has a series of similar commands which i capture in my logs.Now when i run the above script, it runs successfully, but i need to add one more pointer to classify in my logs like the start and end of each ip address(mentioned below).
Code:
eg:batch <hostname or ip_address> begins
    batch <hostname or ip_address> ends

This will enable me identify easily that the logs are for the specific ipaddress or the hostnames.


Regards
Whizkid

Last edited by Franklin52; 09-06-2014 at 12:21 PM.. Reason: Fixed code tags
# 2  
Old 09-06-2014
Try adding
Code:
echo "batch $ip_addr begins"

before the ssh command and

Code:
echo "batch $ip_addr ends"

after the ssh command.
This User Gave Thanks to junior-helper For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ip address for multiple hostnames

i have a file which has 100 servers,i want a script which can output me ip address and hostname for that server. Thanks in advance!! input file abc.com output file should be abc.com 192.168.1..1 (1 Reply)
Discussion started by: Moon1234
1 Replies

2. Shell Programming and Scripting

Script to grep for a string in log files generated in last 15 minutes.

Dear Guru's I've a requirment to grep for a string in series of log files that are getting generated almost every minute. I'm looking to schedule a script every 15 mountes,in order to check if the error string has been generated in any of the log files generated in last 15 minutes. Please... (3 Replies)
Discussion started by: rajivatnova
3 Replies

3. Shell Programming and Scripting

Files generated today

I would like to find the Files which are generated today in the current directory: I use the commad ls -lrt * | egrep " `date "+%b"` * `date "+%d"` to acheive this. Is there any better way to acquire the same. Multiple answers will be great. Thanks (3 Replies)
Discussion started by: kusathy
3 Replies

4. Shell Programming and Scripting

Files generated by a particular user

Hi I have the following files generated by different users on a directory -rw-rw-r-- 1 NAME1 database03 809 Nov 17 10:41 PCAS_CARD_TRANS_OFF.1111171041.lg -rw-rw-r-- 1 richard ccsdba 10968411 Nov 17 10:43 load_123_RX0_0.1111171016.lg -rw-rw-r-- 1 DEV db03 10713 Nov 17... (5 Replies)
Discussion started by: bobby1015
5 Replies

5. UNIX for Dummies Questions & Answers

Log file not getting generated

Hi , Log file is not getting generated. any suggestion? Thanks date1=$(date '+%m/%d/%y-%H:%M:%S') log="wrapper.log.$date1" echo " somethng" > $log (2 Replies)
Discussion started by: ajincoep
2 Replies

6. UNIX for Dummies Questions & Answers

Is there a unix command to find ALL hostnames for an ip address?

I am trying to determine if there are several url/host names for an IP address. Is there a UNIX command to find ALL host names for an IP address? Thank you in advance. (3 Replies)
Discussion started by: rukasu
3 Replies

7. Solaris

core files not getting generated

Hi, We have an application ASPA . The application related processes are running in /ASPA/bin directory . now whenever a process terminates abruptly , a core file should be generated (correct me if i am wrong) in the /ASPA/bin directory . But i am not able to see any such files . The... (4 Replies)
Discussion started by: asalman.qazi
4 Replies

8. UNIX for Advanced & Expert Users

Type v for generated files

Hi All, I was checking some of the files and I got the following entries:- =============== v, 664, serv, serv, version.txt, exe L, 775, serv, serv, start.sh, eventserv ================ Could someone please tell me what does the type"v" and "L" represent to. I have not... (2 Replies)
Discussion started by: shubhranshu
2 Replies

9. Shell Programming and Scripting

Ftp all the generated files

Hi All, I'm working on a ftp shell script in which I'm tranfering files from one sever to another using ftp. Some program generates files at undefined time & throughout the day. I have to transfer the files time to time.. i.e. once the file is generated, it should be transfered at the very... (3 Replies)
Discussion started by: im_new
3 Replies

10. Shell Programming and Scripting

get the last generated log file

Hi I need to get the last generated file in a directory using ls -ltr. I need to store the output of ls -ltr in a variable. it will like this $xyz = -rw-rw-r-- 1 sblp003 siebel 1060 Dec 18 13:33 from this output, I need to do a substring to get this value alone "Dec 18... (8 Replies)
Discussion started by: ragha81
8 Replies
Login or Register to Ask a Question