Archive for November, 2005

Dealing with remote users and troubleshooting — WhatIP.org

I deal with alot of troubleshooting in my life, and one of the things I have to do is talk to end users who are having problems hitting the site.

I need them to tell me their IP address… which is a near impossibility for most people… so I’ve been using WhatIP.org to get that information.

I generally tell them to hit whatip.org in a browser and then send me the output of the site… it makes my life easier because then I can search thru error logs or access logs and determine what they’re doing, or do a traceroute and see if the bandwidth is having issues.

Comments

What is going on… or, why is the server slow when your not around.

I’ve been called in the middle of the night with “the server is slow” being the emphasis of the call. Sometimes it’s not obvious using standard utilties, or sometimes it only happens during certain times.

I’ve used a simple script to eliminate this issue, and run it from cron every minute or 5 minutes to give me output on whats going on with the system.

This is ment for temporary use only, or at least make sure you clear the files every once and a while, because they get pretty big, thus I wrote a cyclecheck script and even a cyclerebootcheck script to see why a machine rebooted.



check script:

#!/bin/sh
echo “——————-” >> /data/`/bin/hostname`.load
echo “——————-” >> /data/`/bin/hostname`.psaux
/bin/date >> /data/`/bin/hostname`.load
/bin/date >> /data/`/bin/hostname`.psaux
/usr/bin/w >> /data/`/bin/hostname`.load
/usr/bin/w >> /data/`/bin/hostname`.psaux
ps -awux >> /data/`/bin/hostname`.psaux



cyclecheck script:
mv /data/`/bin/hostname`.psaux /data/`/bin/hostname`.psauwx.old
mv /data/`/bin/hostname`.load /data/`/bin/hostname`.load.old


cyclerebootcheck script:

mv /data/`/bin/hostname`.psaux /data/`/bin/hostname`.psauwx.reboot
mv /data/`/bin/hostname`.load /data/`/bin/hostname`.load.reboot
echo `hostname` rebooted `date` | mail pageadmin@site.com



install script:

echo “*/1 * * * * root /root/scripts/check” >> /etc/crontab
echo “1 0 * * * root /root/scripts/cyclecheck” >> /etc/crontab
echo “/root/scripts/cyclerebootcheck” /etc/rc.local
killall -HUP crond



I place them all in /root/scripts and chmod -R 755 /root/scripts, then run /root/scripts/install to place these things into the crontab.

Then you can view the output in /data/hostname-of-server.load or /data/hostname-of-server.psaux each with a timestamped entry.

——————-
Wed Nov 2 00:02:00 EDT 2005
12:02AM up 123 days, 23:45, 0 users, load averages: 0.15, 0.28, 0.24
(what users are logged on listed here)
USER TTY FROM LOGIN@ IDLE WHAT
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
root 24498 0.0 0.0 984 224 ?? R 12:02AM 0:00.00 ps -awux

It works at least.. edit for directories you need, this is written for freebsd in this case.

Comments

Simple Web Statistics — awstats

I run a bunch of virtual hosted sites for friends and they’re always asking me for statistics on how many people are hitting their page.

One of the simplest programs I’ve setup is awstats..

Once you’ve downloaded the program I simply run it from the crontab every 15 minutes and let it clunk away on their stats.

I’ll post a full config howto shortly.

Comments

How many files in a directory.. with find and wc

I’ve had to figure out how many files are in a directory about a billion times now… and the easiest way I’ve done it is

cd /directory-in-question
find . | wc -l

This introducting WC, wordcount… Wordcount works in many ways, however it can be used to count lines in a file or directory listing or a find or whatever you need…

output is something like:

$ find . | wc -l [ENTER}
325
$

Saying I have 325 files in the directory (and any subdirectories)

Comments

A sane way to keep apache redirects (or configuration) indentical

I work in an environment with clustered computers, so one thing that we run into all the time is dealing with configuration changes across multiple webservers. One of our customers requres redirects to be configured all the time, and it was becomming mind numbing entering them onto every server.

So I did something simple, since the main web root was attached using NFS to each server (for keeping files in sync) I created a /apache directory outside of the webroot and created a file called redirects.conf in that directory.

Now for each VirtualHost I setup, I add the line

Include /path-to-website/apache

and it includes all files in that directory to the apache configuration.

You can have mod_rewrite rules, etc. And the best part is when i need to edit it, I simply change one file, and restart the servers.

Change once, restart many, thats the way to do it.

Comments

Grep… and some of it’s useful commands

I love grep… it’s a great way to search for lines in error logs, find out where references to a URL are in your websites, and all in all, a good program.

context is : grep searchterm filename

however it’s much more powerful.

For example, you can do a

grep username /etc/passwd

to find out if a user has an account. Or you can pipe system processes thru grep to find only the ones in question

ps -awux | grep processname

You can exclude things using grep as well, for example lets say you know you have 20 sendmail processes going but you just need the one thats “accepting connections”

ps -awux | grep sendmail | grep -v accepting

will show it to you (yes, it’s an abuse of grep there.. you can complain if you want :)

Comments

« Previous entries · Next entries »