New to scripting and need some help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting New to scripting and need some help
# 1  
Old 03-28-2010
Data New to scripting and need some help

Hello all, this is my first post so please go easy on me. I have like 30 redhat servers that I manage now and it’s a requirement to do hourly checks on some processes, yes, even though we have a full time monitoring solution they still want hourly checks so I'm looking for a way to script this so I'm not spending my day logging into servers and running the same commands on all of them.

So it would go something like this;
Code:
ssh servername username and password
ps -ef | grep jboss
ps -ef | grep sendmail
ps -ef | grep auditd
ps -ef | grep symantec
process sendmail status
process jboss status
output data or send results to email by server name
ssh servername username and password
ps -ef | grep jboss
ps -ef | grep sendmail
ps -ef | grep auditd
ps -ef | grep symantec
process sendmail status
process jboss status
output data or send results to email by server name

Ect....

Then I would like it to email me the output from all the process
checks or even just give them to me in a shell. Now there are 30
servers that this needs to be done on so I want to chain this together so I only have to run one script an hour, verify that everything is good and go about getting the rest of my job done. I just got off of amazon and purchased 4 scripting books but any help would be greatly appreciated until they arrive!!

Thanks in advance!

G

edit by bakunin: i threw a few missing code-tags your way. If you don't want to get hit (and hurt) accidentally you bring them with you yourself from now on. Thank you.

Last edited by bakunin; 03-28-2010 at 05:37 PM..
# 2  
Old 03-28-2010
First off, before you start scripting lets analyze your requirements: you have some 30 servers and you want every one of them be checked and generate a mail. This is 24*30=720 mails per day and even if you would manage to implement this script (which is entirely possible) i wonder if you really would be happy with it. You might end up reading mails all day.

So probably there should be some sort of log, of course, but there should be a error condition upon which you want to be informed (by mail or whatever) and otherwise the check script should silently write its log and finish. This means it might be wise to set a number (range?) for each of the processes which is deemed "normal" and test against this number or implement some other means of deciding what is "normal" and what is "error".

Furthermore, your script shall run for a long time. This means that it will - sooner or later - have to deal with some disruptions to its normal mode of operation: a system not being reachable by ssh (system shut down, ssh-daemon not working, network down, ....) or an accidentally deleted exchanged ssh-key, whatever. All these possibilities should be taken into account and there should be some reaction built into the script dealing with this: should the script create an error? Should it silently ignore it? Should it silently ignore it for <n> runs and then raise an alarm?

These are questions best asked before you start writing a script. Even if i provide no code (yet - state your requirements and i will gladly help you write it) i

hope this helps.

bakunin
# 3  
Old 03-28-2010
After specifying your requirement (As Bakunin said ) check "/etc/sshd/ssh_config" file if the user is allowed to use ssh or not.

Besides using this is easily readible.
Code:
ps -def -o pcpu,pid,user,args | grep -i jboss >> FILE

Error handling is important if you have too many servers and too many processes to check. Connectivity to all hosts etc..
# 4  
Old 03-28-2010
You have a very valid point that I didn't even consider great catch. The requirement is to ensure that certain processes are running and not hung or crashed. I'm currently using Big Brother to monitor some of the processes but there is also a requirement to hand test them and others hourly, Now in reality I can't actually do that because that would take my whole 9 hours a day. So what I was hoping to do what write a script that would check the status of the processes across all the servers and tell me when there is an issue and tell me nothing at all if all is well. As for handling errors if the script ran once and hour via cron or whatever, I would say to have it ignore one failed connection attempt (say a server is down) but alert on the second attempt. As for ssh this is a private network (air gap) so all the ssh keys are shared all over the network. From any shell logged in as root I can ssh as root, without having to login. I hope this answers your questions. I really didn't think about the amount of email.... Once again great call...

Thanks!

G
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

2. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

3. Android

Android Scripting Environment: Shell Scripting and Android

I just upgraded to Android 2.2 from 2.1. The GPS issue that was troublesome in 2.1 seems to have been fixed. Some of web browsing seems faster, but it could just be my connection is better today ;) Flash works in some browsers but not very good and it is too slow for Flash apps designed for... (0 Replies)
Discussion started by: Neo
0 Replies

4. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

5. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

6. UNIX for Dummies Questions & Answers

Scripting Help

Hello all. Like Ive stated before, I am new to world of Unix. I was given the tast to create a script that will concatenate 20 files into one file. I know that the cat command is to be used but I am looking for something to get started on. Again, basically I need to wrtie a script that whill... (3 Replies)
Discussion started by: ndoggy020
3 Replies

7. UNIX for Advanced & Expert Users

Need help on scripting

in unix bc command is used as calculator and also for conversion, i want to convert 5f to decimal. but bc dont consider 5f as hex value it considers 5F as hex value. I get 5f from other iteration so i cant change that f to F...is there any way to convert 5f to decimal ot 5f to 5F :rolleyes: (2 Replies)
Discussion started by: abhinandantn
2 Replies

8. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

9. Shell Programming and Scripting

scripting guru's pls help me with scripting on AIX

can someone pls help me with the script for a files coming from one system to a particular directory and i want to write a script to move those files to another directory on different system by renaming the files... pls someone help me on this... thanking in anticipation.... (1 Reply)
Discussion started by: thatiprashant
1 Replies

10. AIX

New to scripting

We have a scripting requirement, Background: On a particular path, we compress a load of log files into tar.gz. This is done on an hourly basis throughout the day and it produces files of the following format, 2005-08-05-00-021031.tar.gz as an example. This is done by a script. We need: ... (2 Replies)
Discussion started by: rajesh_149
2 Replies
Login or Register to Ask a Question