Thursday, September 26, 2013

Spamming : A very useful SHELL SCRIPT to find spamming on the server. Borrowed from a friend ;)

I found this script more useful and time saving than "View Mail Statistics Summary" option in WHM.
==========================
Commands:
vi mailscript.sh
chmod 755 mailscript.sh
./mailscript.sh

==========================

Code : mailscript.sh

Note: You need to change word "username" with any existing username on server ;)


#!/bin/bash
echo > /home/username/temp_eximlog
a=`date --date="5 hours ago" +%Y-%m-%d\ %H`
b=`date +%Y-%m-%d\ %H`
awk -v s="$a" -v e="$b" '$0~s,$0~e' /var/log/exim_mainlog >> /home/username/temp_eximlog
echo > /home/username/mailqueue
echo "Top local senders by message count"  >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
eximstats /home/username/temp_eximlog | grep -A7 "Top 50 local senders by message count" | tail -5 | awk '{print $1,$NF}'  >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
echo "Top Local recipients" >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
eximstats /home/username/temp_eximlog | grep -A7 "Top 50 local destinations by message count" | tail -5 | awk '{print $1,$NF}'  >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
echo "No of emails sent by authenticated user" >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
cat /home/username/temp_eximlog | grep dovecot | awk {'print $9'}| cut -d: -f2|sort|uniq -c|sort -n >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
echo "No of emails sent through script" >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
grep "cwd=" /home/username/temp_eximlog|awk '{for(i=1;i<=10;i++){print $i}}'|sort|uniq -c|grep cwd|sort -n >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
echo "Number of hits from an IP" >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
tail -n1000 /home/username/temp_eximlog |grep SMTP|cut -d[ -f2|cut -d] -f1|sort -n |uniq -c >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
echo "IP and no of tries done the IP to send mail but rejected by the server"  >> /home/username/mailqueue
tail -3000 /home/username/temp_eximlog |grep 'rejected RCPT' |awk '{print$4}'|awk -F\[ '{print $2} '|awk -F\] '{print $1} '|sort | uniq -c | sort -k 1 -nr | head -n 5 >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
echo "Connections from a certain ip to the   SMTP server" >> /home/username/mailqueue
netstat -plan|grep :25|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1 >> /home/username/mailqueue
echo "=============================" >> /home/username/mailqueue
cat mailqueue | mail -s "Mail Stats" uday.gade@yahoo.com


Monday, September 16, 2013

mysqladmin commands

mysqladmin pr |grep -v Sleep To show only sleep processes
mysql> SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY TIME DESC; To show processes in ascending order.
=============================
mysqladmin flush-hosts Flush all cached hosts
mysqladmin status Gives a short status message from the server
mysqladmin processlist Show list of active threads in server

Mysql command to show processes in ascending order

SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY TIME DESC;

Sunday, September 15, 2013

Apache Restarted Issue: Due to Semaphores

Check semaphores list:
ipcs -s

Remove them using following command:

ipcs -s | grep nobody | awk . { print $2 } . | xargs ipcrm sem

Syntax:
ipcs -s | grep process-owner | awk . { print $2 } . | xargs ipcrm sem

Thursday, September 5, 2013

Mysql : Too many connections error

mysqladmin flush-hosts

Run this command to remove current mysql connections

Email login failure log filename

/usr/local/cpanel/logs/login_log

CPANEL EMAIL CREATION LOGS
/usr/local/cpanel/logs/access_log

(look for addpop and delpop and editquota words)

LFD log file path

/var/log/lfd.log

Tuesday, September 3, 2013

How to check linux cpanel server is physical or virtual

[~]# grep -H '' /var/cpanel/envtype
/var/cpanel/envtype:standard
-- This means this server is physical

Monday, September 2, 2013

Roundcube error for only one email ID

DATABASE ERROR: CONNECTION FAILED!
Unable to connect to the database!
Please contact your server-administrator.

Resolution :
fixed issue.

/home/username/etc/domain.com
total 888
drwxr-x--- 3 username mail 4096 Aug 6 02:54 ./
drwxr-x--- 5 username mail 4096 Jul 24 00:16 ../
rw------ 1 username username 39936 Aug 6 02:54 admin.rcube.db

Deleted this file admin.rcube.db
It then got recreated.

Some songs URLs

Some good songs
http://udaygade.wordpress.com/some-good-songs/

http://www.sysnet.ucsd.edu/~voelker/tmp/good-bad-ugly.mp3

http://www.sysnet.ucsd.edu/~voelker/tmp/

http://mp3lover.eu/sha/shaggy-sexy-lady-songs-pk-mp3
197 kbps
4.68 MB
Shaggy - Hey Sexy Lady.mp3

bees saal baad 1088 mere saamne tu sada
http://new.downloadming1.com/audio%20songs/bollywood%20mp3/Bees%20Saal%20Baad%20(1988)/03%20Mere%20Saaamne%20Tu%20Din%20Raat%20Rahe%20-%20%20Mohd%20Aziz,%20Sarika%20Kapoor%20-%20www.downloadming.com.mp3


http://www.saavn.com/s/#!/search/hindi/tu+iss+tarah

http://www.youtube.com/watch?v=5erZ_LXw5HE

tu mere saath saath

aaj kahin na ja

tere liye

dus kahaaniya

kaali kaali aankhon ka jaadu- ek thi daayan

katra katra ijajat

raat shabnami

main naraye mastana

http://mp3skull.com/mp3/majhiya_priyala_preet_kalena.html


ye jivlaga
http://mp3skull.com/mp3/ye_jivlaga.html

oru varth oru sollu
http://www.youtube.com/watch?v=fXDpNYxw9x4

tujhe yaad na meri aayi

sambhala hai maine

aye meri zindagi -- Saaya
http://www.saavn.com/s/#!/search/hindi/saaya

http://mp3skull.com/mp3/robby_feel.html

PHP relocation error 500 Internal server error

Solution : Run easyapache to rebuild php on server.

Horde Login Issue

Error:
PHP Warning: Unknown: open(/var/cpanel/userhomes/cpanelhorde/sessions/sess_6f4fe8e66b99d89b239eb0839e3393a7, O_RDWR) failed: Permission denied (13) in Unknown on line 0
PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/cpanel/userhomes/cpanelhorde/sessions) in Unknown on line 0

Steps used to solve the error:

tail -f /usr/local/cpanel/logs/error_log
cd /var/cpanel/userhomes/cpanelhorde/sessions/
ls -la
cd ..
cd ..
ls -la
cd cpanelhorde/
ls -la
chown cpanelhorde.cpanelhorde * -R
tail -f /usr/local/cpanel/logs/error_log

My other blog