Automated log script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automated log script
# 1  
Old 01-26-2011
Question Automated log script

Hello,

I am scripting noob but I need little monitoring script.
It will be very good if you can help me.

What I need:
Script will login via ssh to another machine (ssh -l user ipadress), make top command and log first row + machine ip. It should monitor like 10 machines.
Script should run via cron every hour. Log file should not be overwritten but new information should be added into end.

Output should be written into home directory on monitoring machine and should looks like
machineip
top - 12:00:00 up 90 days, 00:00, 3 users, load average: 0.50, 0.50, 0.50
machineip2
top - 12:00:00 up 30 days, 00:00, 13 users, load average: 1.50, 1.50, 1.50.

Can you help me please?

Thank you very much
# 2  
Old 01-27-2011
Hi Biosko,

given that you established a password-less ssh-login on all of the remote machines and the username is the same on all machines, the following one-liner should do what you want:

Code:
#!/bin/bash
for h in machine1 machine2;do echo $h;ssh -l user $h uptime;done 1>>monitoring.log

cheers,
Max
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need an automated script

Hi, I need a script to execute below task. As of now I am doing it manually and want it automated. 1)go to below path cd /path/of/file check for the availibility of two file as below of the latest date. test.week1.data test.week2.data Case1. If above files are not present... (3 Replies)
Discussion started by: sv0081493
3 Replies

2. UNIX for Dummies Questions & Answers

how to make script automated

if i have a script called test.sh file1=$(ls -l|awk '{print $9 $1}') awk ' /date_of_selling:/ { print $6 ":" &9 }' /$file1 >> data.txt if i wanna this script to run automatically every day at 8 am :D (3 Replies)
Discussion started by: teefa
3 Replies

3. Shell Programming and Scripting

Help with Automated Shell Script

Hello, how can I write a shell script that looks in running processes and if there isn't a process name containing 91.34.124.35 then execute a file in a certain place. I know PHP, in PHP I could do a preg_match_all but I don't know how to do it in shell. (5 Replies)
Discussion started by: nottingham
5 Replies

4. UNIX for Dummies Questions & Answers

Automated backup script

I want to create an automated backup script that will copy files to different directories for different days. I will use a detachable USB drive, under SCO 5.0.7. I am very new to Unix, and will require most of the script. Thanks (5 Replies)
Discussion started by: Bennieinbots
5 Replies

5. UNIX for Advanced & Expert Users

scp automated script

Hi Unix gurus, I am trying to create a script to automate the copying of files daily from one server to another using the scp command. --> #!/bin/ksh KEY="$HOME/.ssh/SSHKEY" if ;then echo "Private key not found at $KEY" >> $LOGFILE echo "* Please create it with \"ssh-keygen -t dsa\" *"... (5 Replies)
Discussion started by: gholdbhurg
5 Replies

6. Shell Programming and Scripting

Automated SFTP script

Hi All, I am writing an automated SFTP script to xfer files. I am able to do sftp in batch mode and it is working absolutely fine. The problem is that on redirecting the output of SFTP session to some file, it is not writing about the status of SFTP operation. All i can see in output file is :... (6 Replies)
Discussion started by: aggar_y
6 Replies

7. Shell Programming and Scripting

i want automated script

echo "Enter your choice :\c" read num case $num in . 1)"${TEST_HOME}"/ctrl_extract.ksh 1 ;; 2)"${TEST_HOME}"/ctrl_extract.ksh 2 ;;3)"${TEST_HOME}"/ctrl_extract.ksh 3 ;; 4)"${TEST_HOME}"/ctrl_extract.ksh 4 ;; 5)"${TEST_HOME}"/ctrl_extract.ksh 5 ;;... (3 Replies)
Discussion started by: arghya_owen
3 Replies

8. Shell Programming and Scripting

Need automated shell script please

I'm totally new to shell scripting and I would like to ask your help 1.i want to have a .sh script where it runs opening 2 applications one after another 2.i have 2 applications in /applications/app1 /applications/app2 3. want this script to launch app1 for 20 seconds and get killed... (2 Replies)
Discussion started by: uneex
2 Replies

9. UNIX for Advanced & Expert Users

help for automated script

Hi ALL: I need to write a script that will start bunch of servers. and these servers each has a sudo account and they need a passowrd. I dont know where to start and look. Can you please give me some hints or some sample code. Thanks in advance. splax (4 Replies)
Discussion started by: splax
4 Replies

10. Shell Programming and Scripting

automated email on a log event

I am monitoring a logfile using tail -f file.log|"ERROR" I would like to write a korn script that monitors this for me and emails me if the event happens. It would be great if it attached the file to the email as well. Any Ideas? (2 Replies)
Discussion started by: seran128
2 Replies
Login or Register to Ask a Question