Putty for dummies

Status
Not open for further replies.

erect

New member
Jun 3, 2007
3,796
154
0
Esoterica
twitter.com
Hey guys I could use some help evaluating how my server is performing. The catch is that I know absolute shit about root access. Good programmer, shitty sys admin but it's necessary when you move to VPS/dedi boxes. Here is the extent of my knowledge at this moment.

command :::: definition of what it does
_____________________________________
top :::: active processes
free -m :::: checks how much ram I have / is free
ps -ef :::: what's actually running at this moment

^^ am I defining these correct here? What important command am I missing?


As far as the utter basics I can open crontabs and insert new ones. Currently I restart apache every 30 minutes or so just to keep any server downtime limited to that window

crontab -e
service httpd restart
service mysql restart


Well that's about the extent of my knowledge. Does anyone have some commands to add to this that would help me evaluate server performance? Or perhaps just some cool shit I'm missing out on ... any help would be appreciated.

I've googled and there is a lot of help for specific problems but not really a catch all of "must have" commands to run.

If I missed something obvious tell me to fuck off and google deeper ... or just help a brother out.
 


'top', 'free', and 'ps' are great tools to figure out what's going on with your system, definitely worth while spending some time getting familiar with them.

for some general cmd's I've found this to be a good resource:

hxxp://www.scribd.com/full/2933314?access_key=key-2lwqsfr2e5s00wi1ztjf

but there are SO many great tools that it's easier to just identify the problem your having and find some tools that will help you solve it.

I'd add to the list of basics with:

man
df
grep
| (pipes)

man is short for manual, basically, it the unix help file system. type 'man top' or 'man ps' or 'man free' to get all of the cmd's and infor for each tool. if you need help figuring out man itself, type 'man man'.

df tell's you how much disk space you have free, 'df -h' gives you an easy to read display.

some things off the top of my head about the cmd's you mentioned that I use often:

top - hit the number '1' on the keyboard and if you have multiple processors (or mulit-cores) you'll get a print-out of each processor. hitting the 'shift >' key sequence allows you to sort by columns. I think the default is set to %CPU, but 'shift >' will sort by the next column, %MEM. 'shift <' moves the column focus in the opposite direction. I use this often when running my code, and monitoring my processes...

free - like you said, use the 'free -m' but make sure your looking at the output properlly.


Mem: 2027 1964 62 0 222 1387
-/+ buffers/cache: 354 1672


the 'Mem:' line is shit, ignore it. You want to pay attention to the '-/+ buffers/cache:' line. when unix boots up, it takes most of the available memory and slams it into buffers, so the free column in the 'Mem:' row will show mostly nothing while the free column in the 'buffers' row will show the true amount of memory available on your system (unless you have some freaky setup).

ps - ps is great. when i'm running my software i can kill it if it's spinning out of control, or just check up on it by piping the output to the grep command

'ps aux | grep ruby' will show me all ruby processes on the system.
'ps aux | grep php' will show me all php processess on the system.
'ps aux | grep apache' will show me all apache processes on the system.

if I have an output of:

root 29516 0.0 0.0 1936 624 pts/0 S+ 15:24 0:00 ruby

and I want to kill it immediatly, try this:

kill -9 29516

...this was all just a quick brain dump, so take it all with a grain of salt - but these are things that i use day-to-day to help manage any of my boxes...
 
  • Like
Reactions: erect and radio
If you're using MySQL, you should probably also check how it's performing using a specific script such as mysqltuner or the tuning script from here: Sundry MySQL Scripts and Docs

Regarding Apache, why on earth are you restarting it every thirty minutes? With linux, things should be pretty rock solid, and I've never heard of a site requiring such a process.
 
  • Like
Reactions: erect
You can also see the last few entries of a text file (i.e. a server log) with "tail" - and follow it with "tail -f [log]" - see new entries as they come in...
 
  • Like
Reactions: erect
I love you guys ... in a totally gay webmaster type way. +rep all around

1st off: Musashi ... great advice even though it was over my head. I did pick up a few things from that scribd article (things like arrow keys for finding previous commands) and will be rereading it when I get some time on my hands

awatson, thanks for the log file command ... putty just looks at me stupid when I do that one but no worries, stats are my friend and I don't need command line to get around them.

@moomycow - I'm definintly looking into that mysql thing. That's the entire reason I moved from my shared to VPS ... max 25 mysql connections. I'm sure I've got some bad practices in my coding but never knew how to troubleshoot it, really I just guessed where my bottlenecks were.

Regarding Apache ::: it actually got worse then a lot better. I had a crontab reboot every 10 minutes because ram got filled up in a hurry. Each instance of apache would take like 130 MB and there were always 4-6 so you can see my 1/2 GB of dedi ram got gobbled up in a hurry. My site is not one where 1 user surfs a bunch of pages so I have to follow sessions and stuff. Basically I get a ton of organic traffic but each visitor only visits 1 page before clicking an ad or the back button, so the frequent reboots bothered me not!

After suggesting that I switch to lighthttpd instead of apache my sys admins realized there was something running that was causing apache to leak memory like a SOB. After the tweak, each apache instance only takes up 8MB instead of 130MB .. you can tell just by that comment that the server is alive and well again.

I'm currently only using about 1/2 the available ram so I'm dropping my crontabs that restart apache gradually until I feel comfortable only rebooting every hour. I'd prefer keeping it at that level just incase there is some downtime and I'm away from the cpu or asleep ... I'd rather have my downtime no longer than 1 hour ever, sounds reasonable unless someone here can talk me out of it.

Guys, thanks for the advice and keep the cool tips coming. I'm sucking at this stuff a lot less than I did last week.
 
Status
Not open for further replies.