Visit The New, Modern Unix Linux Community

Script counting instances of software running on a machine

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script counting instances of software running on a machine
# 1  
Script counting instances of software running on a machine

Hello to all @here,

as Im new to this forum, I will try to start in a easy way for my first post. Im not beginner in scripting, but also not a proffessional. So please keep easy, if I dont understand your explanation at once Smilie I dont mean it in a bad way!

Here is the Problem:
There were about 470 Servers running in my company. The most of them were hardware, on which are running mostly virtual machines. On this virtual machines are running Application Servers like WebLogic (Oracle), WebSphere (IBM), JBoss, Apache, TomCat and some other applications that dont matter to me. My job is now, to check all servers and to analyze how many of this applications were actually running at the same time.
Some of the applications is maintained by the customer, some by our company. But all machines were from our company. So the point is, to create a script, which will count the applications running on a system.
My first intention was, to go over to the machine, and put a script on it, that will count the applications. But I dont have thought on one important point. Some of the machines could be maintained by the owner or a colleague, so that there is no process running at this time, when my script starts. Maybe somebody over here, have a better solution for me, how to handle this problem.
Actually Im standing at this point, that I have created a script, that takes a ps -ef and greps out the processes that were important to me over ssh to a special server. But if the machine is not running the application, I will get back no result. So I tried now in another step, to take the find command, to find the path of an apache, WAS, WLS, ...and so on. My next problem that occured was, that some customers have saved their installations of WAS, WLS, JBoss, Apache ... under different directories with different names. Some call it WebLogic, others WLS1, other OracleWebLogic and some in companynames or crypted names. The main thing is, that all of this applications use apache or tomcat as a communication plattform for extern connections.
Now there were 2 different ways to go on. I can create a script, that can be stored local on the virtual machine, or I can store it on a central place and work with a list, of all available servers, to solve my problem. What is the best way, what do you thing and what would you prefer in this way? Do you have an other solution for me? Maybe I need some other impulses?!!?!? Smilie
What I forgot to say, some customers were running more than one instance of the application server. For example, there were some customers, that have running 6-8 WLS on a cluster of 3 machines. And additional they have installed also some other applications for testing purposes. I have to count all instances, that were running. So I need to know, if WLS for example is running at this machine, and if so, how many instances were installed/running actually.
If somebody is interested in my script, let me know, maybe I can post it here or somewhere else, so that you can take a look at. But I would like to know, if Im on the right way with my thoughts or if I should go another way that is more comfortable.
If you have questions, let me know!
Systems running : UNIX

# 2  
By "running" I think you mean the machine is licensed for something and could run it. But you get false negatives.

If your company installed everything then you have a very high probability that there is commonality in naming conventions. The default WebLogic owner uid is wls, so if there is a WLS user, apache has to be there as well. Directory names will be there, like for oracle certain lower level names like libclntsh will only exist on a box that can run oracle as either a client or a server, or, /var/opt/oracle/oratab will have entries that end in :Y os :S for boxes that actively run an orcacle database or a standby and so are oracle servers.

Therefore - you need to logically create a set of queries a means of determining, yes this has jboss or not. And the method does not always depend on what users are running but usually depends on what exists in /etc/passwd, /etc/group, /var/opt/... etc.

This is like one of those puzzles where you work out what has to exist by a small numbers of observations. The most dependable are: names of certain files, usernames, some group names, if you are lucky sometimes a daemon with a fixed name will be running full time.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Thx for the fast reply. I just worked out my script, and now seems to work good. Need to make some optimizing in the next future, but for now, Im happy that it works.
Thank you jim mcnamara for your thoughts and explanations! That have been really usefull!

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #941
Difficulty: Medium
A ping of death is a type of attack on a computer system that involves sending a malformed or otherwise malicious ping to a computer.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Keep a script on remote machine running (nohup?)

Hi, I'm using expect to ssh into remote machine (i know its not the best practice), and run script "". This "" checks whether an other process (some another script) is running and if not, it runs it as some other user. #!/bin/bash /usr/bin/expect << EOD set... (5 Replies)
Discussion started by: oseri
5 Replies

2. OS X (Apple)

Quit a shell script thats running on a remote machine

I'm in a situation where I am executing a shell script(Bash) on another machine remotely using ssh, and for various reasons sometimes need to quit it and restart it. The shell script being run does many different things, so its hard to know what process to kill on the remote machine, and even if I... (2 Replies)
Discussion started by: TheDrizzle
2 Replies

3. Shell Programming and Scripting

Counting Instances of a String with AWK

I have a list of URLs and I want to be able to count the number of instances of addresses ending in a certain TLD and output and sort it like so. 5 48 49 Input is as so (1 Reply)
Discussion started by: Pjstaab
1 Replies

4. Shell Programming and Scripting

A script that kills previous instances of itself upon running not killing child processes

I'm likely going to explain this clumsily, so apologies in advance: I have the following script: #!/bin/bash pidPrefix="logGen" checkPrime () { if /sbin/ifconfig eth0:0|/bin/grep -wq inet;then isPrime=1;else isPrime=0;fi } killScript () { /usr/bin/find /var/run -name... (4 Replies)
Discussion started by: DeCoTwc
4 Replies

5. UNIX for Advanced & Expert Users

Script running on remote machine - How ??

Hi All, This was an interview question " There is a clean-up shell-script in one UNIX machine and it is connected to 100 other UNIX machines. Howe can we run the script on all the 100 machines without ftping/copying the script to target machines ? I was unable to answer, please answer if... (5 Replies)
Discussion started by: coolbhai
5 Replies

6. Shell Programming and Scripting

running script in background on remote machine

Hi there I have a script which is running a remote command on hundreds of boxes, it takes around 5 minutes to return an output from this command and because i am running this all from a central box, it goes off to each box in my for loop sequentially meaning that my script will wait for output... (5 Replies)
Discussion started by: hcclnoodles
5 Replies

7. UNIX for Advanced & Expert Users

Running script on remote machine

if i have a script in my system which i need to run on remote system using ssh, how shall i do it? One easy way to to first scp it to remote machine and then run it on remote machine using ssh. Is there any one step way to do it. Preferably one in which i should give password only once (3 Replies)
Discussion started by: vickylife
3 Replies

8. AIX

multiple instances of same vg on same AIX machine

hi, i am new to AIX and to this forum as well. Can you please help me out with following issue/requirement 1) I have one physical volume (pv1) (a scsi disk). (pv1) on 1st AIX machine. I have a single volume group on it(vg1). 2)I removed it from the 1st AIX machine and exported to the 2nd... (1 Reply)
Discussion started by: navadeep
1 Replies

9. Shell Programming and Scripting

Script that checks for previous instances running

Hello, I'm trying to write a script that checks for previous instances of the same script which may still be running (this script is scheduled to run every 30 minutes). I want to somehow use the pid from each instance to make sure the previous one isn't running before continuing with my... (5 Replies)
Discussion started by: bd_joy
5 Replies

10. Shell Programming and Scripting

How to limit the number of running instances of a script?

I would like to allow only one instance of a script to run at any moment. I've tried the following solution to count the instances but the result is always the number of running instances plus one and I can't find the problem ps -ef | grep $0 | sed '/^$/ d' | sed '/grep/ d' | wc -l Please... (2 Replies)
Discussion started by: oti
2 Replies

Featured Tech Videos