Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
In my company we are hosting web applications from our server Using Apache and Apache Tomcat. Is it possible to write "Bash script to Monitor The entire URL's " if possible means please guide me to write Script , I have basic ideas in bash script..
Hi Friends,
In my company we are hosting web applications from our server Using Apache and Apache Tomcat. Is it possible to write "Bash script to Monitor The entire URL's " if possible means please guide me to write Script , I have basic ideas in bash script..
Yes, very possible. We can "guide you" to go to http://www.google.com, and put in "bash scripting tutorial", and read some of them, if you don't know how to write a bash script. Also, read the man pages for the wget command.
And also, if you look it up, you'll probably also find many scripts that are already written, that you can look at and modify to suit you.
Using this command i can able to get the HTTP error code.
using this code + with the help of conditonal statements i can able to write the script. but this is the right way to monitor the website using script, or any option is available??
@TB0ne : thanks for your link. with the help of that link i get some ideas :-)
Using this command i can able to get the HTTP error code.
using this code + with the help of conditonal statements i can able to write the script. but this is the right way to monitor the website using script, or any option is available??
Again, you don't say WHAT you're trying to monitor, HOW. And there is no 'right way'...the right way is whatever way you need, to do what you want. Bash scripting is only ONE method...there are many programs in Perl, Python, Ruby, and probably a dozen other languages that can do this. YOU have to decide what is best, and make it fit your needs.
Quote:
@TB0ne : thanks for your link. with the help of that link i get some ideas :-)
Lots more links, but you need to try to look them up yourself. Again, read some scripting tutorials, and the man pages on the commands.
There are many ways to monitor a web server. You need to find the method that works for your situation. What aspect of the server are you concerned about? Page content? Response time? You could write the script yourself or utilize one of the many projects that have already attempted to solve this problem.
My requirement is we need to monitor the url, which are hosted from my server, whether the URL is working fine or down like that.
Because in my company we face one issue one time even the HTTP service is running but i got 502 error, because of java heap size prob.
Now i need to write script to identify, to check url is working fine or not, and response time, and all.
@stickman. below i mention my requirement , i have some basic ideas only in bash scripting so with the help of examples,man page only i can able to understand, and iam trying also.
if i entered this command means it shows.
cut: the delimiter must be a single character
When I read man for cut it states ... delim can be a multi-byte character. ... What am I doing/interpreting wrong here?
Running the command as you entered, doesn't give the string "time_takentime", anywhere in the output. Change it to "totaltime" (without the double quotes), and it will work. Try stepping through commands like this one at a time, to see what you're getting. And again, you need to look at some bash scripting tutorials...
TB0ne nailed what you need to do if you're in doubt, take it one command at a time if you don't understand what it does. Following TB0ne's guidance, did you get it to work and are the results as expected?
#!/bin/bash
# Apache Process Monitor
# Restart Apache Web Server When It Goes Down
# -------------------------------------------------------------------------
# Copyright (c) 2003 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# RHEL / CentOS / Fedora Linux restart command
RESTART="/sbin/service httpd restart"
# uncomment if you are using Debian / Ubuntu Linux
#RESTART="/etc/init.d/apache2 restart"
#path to pgrep command
PGREP="/usr/bin/pgrep"
# Httpd daemon name,
# Under RHEL/CentOS/Fedora it is httpd
# Under Debian 4.x it is apache2
HTTPD="httpd"
# find httpd pid
$PGREP ${HTTPD}
if [ $? -ne 0 ] # if apache not running
then
# restart apache
$RESTART
fi
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.