Friday, July 13, 2012

Post reply notification issue sending only to last replier

SkyHi @ Friday, July 13, 2012
Problem:
I have a phpBB Server, currently 3.0.6, but this issue has existed previously, that is sending out email notifications to users about updates to threads that have been deleted. The user can click on the link in the email and it will just take them to a page saying the thread does not exist.

Sometimes it sends out 20+ such emails to the same users a day, this is not affecting all threads or users, just a few, and only on specific threads. I have tried looking in the SQL database for references to this thread to see where it is maintaining the thread watch list or some other place where it is linking this deleted thread to the affected users, but have had no success.



Solution:
I found a file called queue.php and a file called queue.php.lock in the cache folder which were not deleted when the cache was purged using ACP. These files appeared to hold information related to the mass email. I deleted them manually which should, for now, stop the repeated sending of emails.

By default, phpBB will only send one notification email to each user subscribed to the topic when someone replies. Additional replies will not send more notifications UNTIL the user visits the topic again. 

1) User subscribes to a topic
2) Someone replies to the topic and a notification email is sent out
4) Someone else replies to the topic, no notification email is sent
5) User visits the topic again
6) Someone replies to the topic, so another single email is sent out.
Repeat.

The reasoning for this is simple: Say you subscribe to a topic. Then say 100 people reply to the topic before you've had a chance to read it again. Every single user subscribed to the topic would receive 100 emails, which puts quite a strain on both the server as well as spamming your email inbox.

The SMTP settings in the ACP should be the same settings you use inside of Outlook. The server is typically your domain name. This isn't always the case, but it will be the same as the "Outgoing" mail settings in Outlook. The username and password is the same that you use in Outlook.

REFERENCES
http://startrekguide.com/community/viewtopic.php?f=62&t=3238
http://www.phpbb.com/community/viewtopic.php?f=46&t=2108975
http://www.phpbb.com/community/viewtopic.php?f=46&t=1927475

Thursday, July 12, 2012

Ubuntu new terminal tab

SkyHi @ Thursday, July 12, 2012

 CTRL + Shift + Tab  //new window
right click on mouse and select open tab  // new tab
OR
use File menu 

http://askubuntu.com/questions/42855/how-do-i-open-multiple-terminals

Wednesday, July 11, 2012

Linux Load Problem

SkyHi @ Wednesday, July 11, 2012


  1. http://shebangme.blogspot.ca/2012/07/introduction-to-lsof.html                                    // lsof +p PID
  2. http://shebangme.blogspot.ca/2010/08/debugging-tip-trace-process-and-see.html        // strace -p PID
  3. http://shebangme.blogspot.ca/2012/03/5-simple-ways-to-troubleshoot-using.html        // strace
  4. http://shebangme.blogspot.ca/2009/10/dos.html                                                          //  netstat 
  5. http://shebangme.blogspot.ca/2010/06/parse-log-file-with-most-accessed-ip.html       //  parse log
  6. http://shebangme.blogspot.ca/2012/07/how-to-track-down-high-server-load.html      // top script

How to track down a high server load

SkyHi @ Wednesday, July 11, 2012
One common issue with a dedicated server (or a Virtual Private Server for that matter), is that it can be quite difficult to track down the cause of a high server load.  Most people just write it off as inevitable, but something should be done about it.  If you have a busy site, you'll want to tweak your server to handle high loads as best as possible.  But how can you find out what is causing the high load?  It's simple (kind of)...  These steps are for a *nix based server (Linux, Unix, FreeBSD (I think)).

Find out what's causing the high load

        In *nix, there's a really handy command called TOP.  What TOP does is display process information about the currently running programs.  With some of it's options, and a little output redirection, we can get a glimpse into what's causing our high load.  Here's the command...
top -b -i -n 20 >> ./top_procs
        What that does is tell TOP to run in "batch" mode (not look for any user input), show only running processes, loop 20 times, and append the output to the file /top_procs.  Run that command when you are experiencing a high server load.  Then you can view the contents of that file to tell you some information.  To view the file, you can either open it in your favorite editor (vim?), or simply use "cat ./top_procs | less".  Now, that will give you a bunch of output like this:
top - 11:06:36 up 69 days,  2:53,  0 users,  load average: 0.02, 0.05, 0.07 
Tasks: 137 total,   1 running, 136 sleeping,   0 stopped,   0 zombie 
Cpu(s):  2.3% us,  0.5% sy,  0.0% ni, 97.1% id,  0.2% wa,  0.0% hi,  0.0% si 
Mem:  12278340k total, 12230332k used,    48008k free,   363352k buffers 
Swap: 16386292k total,   157092k used, 16229200k free,  2699912k cached    
PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND  
8066 root      15   0  1888 1032  776 R  0.1  0.0   0:00.02 top  

Tasks: 137 total,   1 running, 136 sleeping,   0 stopped,   0 zombie 
Cpu(s):  2.8% us,  1.5% sy,  0.0% ni, 94.6% id,  1.1% wa,  0.0% hi,  0.0% si 
Mem:  12278340k total, 12230740k used,    47600k free,   361956k buffers 
Swap: 16386292k total,   157092k used, 16229200k free,  2696368k cached   
PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND  
8066 root      15   0  1880  944  704 R  2.0  0.0   0:00.01 top  

top - 11:06:46 up 69 days,  2:53,  0 users,  load average: 0.09, 0.06, 0.07 
Tasks: 137 total,   3 running, 134 sleeping,   0 stopped,   0 zombie 
Cpu(s):  2.2% us,  0.3% sy,  0.0% ni, 97.2% id,  0.3% wa,  0.0% hi,  0.0% si 
Mem:  12278340k total, 12173908k used,   104432k free,   363416k buffers 
Swap: 16386292k total,   157092k used, 16229200k free,  2696988k cached   
PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND  
8066 root      16   0  1888 1032  776 R  0.1  0.0   0:00.03 top  
6103 mailman   16   0 10536 7204 2744 R  0.0  0.1   0:33.08 python2.4  
6108 mailman   16   0 10172 6904 2648 R  0.0  0.1   0:37.92 python2.4
        What does all of that mean? It's really not as bad as it seems.  If you break it down, it's really just 3 repetitions of almost the same information.  Here's what it means, line by line.
  1. Line 1 - General server information - Current time, uptime (since last restart of server), number of users logged on (other than yourself), and the load average for the last 1, 5, and 15 minutes
  2. Line 2 - Tasks - Number of processes, number of actively running processes, sleeping process, stopped process, and zombie processes
  3. Line 3 - CPU usage info (User, System, Nice, Idle, Waiting, Hardware Interrupts, Software Interrupts).  Just worry about Idle, user, system, and waiting.
  4. Line 4 - Memory usage
  5. Line 5 - Swap usage (used should be almost 0 if not 0)
  6. Table header for process list (Process ID, User, Priority, Nice, Virtual Memory, Resident Size, Shared Size, , State, CPU, Memory, CPU Time used, Command)
  7. The processes themselves...
        Now, what to look for is a process that has a high CPU % that appears in multiple repetitions, as well as has a high CPU time.  Be aware that you'll more than likely have a few of them.  Write down the highest ones (most likely MySQL, Apache, etc).  Now that you know what you need to tweak, lets look at how to.

Tweaking MySQL

        If one of the top processes is MySQL, you may need to tweak MySQL for the load.  There are a whole bunch of articles out there on tweaking MySQL, so I'm not going to go into too much detail here.  Things that you will want to do is adjust the Key_buffer_size, query_cache_size, thread_cache, and table_cache to larger values (be careful not to go too big, they can easily eat up all available ram).  If you want to read more, take a look at Performance Tuning MySQL For Load.

Tweaking Apache

        Apache may appear in the list as apache or httpd.  Now, I'm not going to get into tweaking Apache for two reasons.  First, I don't use Apache, so I'm not familiar with tweaking it, and second, there is a whole host of articles on the internet devoted to tweaking Apache.  Here's a decent article on Tweaking Apache For Load.

What if it's something else?

        Now this is where things get interesting.  Are you noticing something else using your CPU time?  There are a few common culprits that like to cause high load.  The two biggest ones are SpamAssassin and Sendmail.  If you need to have SpamAssassin running, you should set it to discard all messages marked as spam to /dev/null (blackhole).  If you don't need it, disable it... It's a great program, but it uses a lot of CPU time to do what it does.  Disable all "Catch All" e-mail accounts (as they add time to the spool). 

Ok, so now what?

        So you've tweaked the server.  It's running faster, and more efficient.  For now.  As time goes on, you may need to tweak some more (as your load changes, or resources change, etc).  That's what administrating a server is all about.  Your job is never done.  However, you really should install some kind of server monitoring tool such as SICM or MRTG, and let them watch your server load.  That way you can identify patterns in load, and determine if the problem is with too many users, or something else.  I also suggest moving away from Apache, and use Lighttpd, as it uses less memory, less CPU time, and is significantly faster.  There you have it!





REFERENCES
http://www.joomlaperformance.com/articles/server_related/how_to_track_down_a_high_server_load_5_16.html

Introduction to lsof

SkyHi @ Wednesday, July 11, 2012

Overview
LiSt Open Files is a useful and powerful tool that will show you opened files. In Unix everything is a file: pipes are files, IP sockets are files, unix sockets are files, directories are files, devices are files, inodes are files...
Useful Examples
So in this tangle of files lsof listst files opened by processes running on your system.
When lsof is called without parameters, it will show all the files opened by any processes.
     lsof | nl
Let us know who is using the apache executable file, /etc/passwd, what files are opened on device /dev/hda6 or who's accessing /dev/cdrom:
     lsof `which apache2`
     lsof /etc/passwd
     lsof /dev/hda6
     lsof /dev/cdrom
Now show us what process IDs are using the apache binary, and only the PID:
     lsof -t `which apache2`
Show us what files are opened by processes whose names starts by "k" (klogd, kswapd...) and bash. Show us what files are opened by init:
     lsof -c k
     lsof -c bash
     lsof -c init
Show us what files are opened by processes whose names starts by "courier", but exclude those whose owner is the user "zahn":
     lsof -c courier -u ^zahn
Show us the processes opened by user apache and user zahn:
     lsof -u apache,zahn
Show us what files are using the process whose PID is 30297:
     lsof +p 30297
Search for all opened instances of directory /tmp and all the files and directories it contains:
     lsof +D /tmp
List all opened internet sockets and sockets related to port 80:
     lsof -i
     lsof -i :80
List all opened Internet and UNIX domain files:
     lsof -i -U
Show us what process(es) has an UDP connection opened to or from the host www.akadia.com at port 123 (ntp):
     lsof -iUDP@www.akadia.com:123
lsof provides many more options and could be an unvaluable foresinc tool if your system get compromised or as daily basis check tool.


REFERENCES
http://www.akadia.com/services/lsof_intro.html