Being an Unix based Middleware Administrator, We can write a shell script to find the applications running on the system
Follow the step and check out the magic at the end
1. Login into the corresponding server where you wish to create the dashboard.
2. Being the administrator, if you are root privileged, go to /root. Else you have to go to the default directory (/home/$user) after login with sudo or specific user.
3. Create a shell script named as ‘Dashboard.sh‘. Now suppose, for this case we know that this Linux box contains Oracle WebLogic server based applications. But the question is what are they and how many of them. So quickly write the script as below
Dashboard.sh:
#!/bin/bash
#Linux/Unix login dashboard echo ‘Server Name: ‘ $(hostname)
echo ‘ ‘
echo ‘Server Uptime: ‘ $(uptime | awk ‘{print $3,$4,$5}’)
echo ‘ ‘
echo ‘Operating System: ‘$(uname -o)
echo ‘ ‘
echo ‘Number of Applications: ‘$(ps -ef | grep java | grep WebLogic | awk ‘{print $1}’| sort -u | wc -l)
echo ‘ ‘
echo ‘Running Applications:’
ps -ef | grep java | grep WebLogic | grep -v ‘grep’ | awk ‘{print NR,$1}’| sort -u
4. Save and exit from the shell script. Now is the crucial part. How to see the output at very login into the server. The trick is quite easy. In /root path, you will find a file ‘.bash profile‘. Add the following line at the very end. Put the necessary path where you jump down after login as any user instead of ‘/root’ by which you are logging in: /root/loginScript.sh
5. You are almost done. Now it is time for a sanity testing round. Logout from the server and log in again. Just after login, you will find the dashboard working as a charm.
Server Name: TestLinux01
Server Uptime: 107 days, 20:33
Operating System: GNU/LINUX
Number of Applications: 6
Running Applications:
1 application_1
2 application_2
3 application_3
4 application_4
5 application_5
6 application_6
Note:
You can replace the search of ‘WebLogic’ with any related middleware application server names like: ‘apache’, ‘tomcat’, ‘jboss’, ‘osb’ etc. You can add the following searches in below lines of the script. It will give you a quick view of the running applications in a grouped format quickly at login. It will save a quite a time for every visit, especially when you are in real hurry.
No comments:
Post a Comment