==> Features
* This particular script alerts the admin if the mail queue is larger than the specified limit
* Script for EXIM Mail Servers
==> Usage
* Copy the below code to a file and give it execute permission
Code:
$ chmod 755 [file_name]
* Set the code to run every 30 minutes by configuring it as a cron job
Code:
*/30 * * * * /bin/sh [/path/to/file] > /dev/null 2>&1
* Edit the variables under the section: "Edit here" to suit your requirements
==> Script
Code:
#!/bin/bash
# Script from www.r6host.com to alert admin about larger mail queue
# Save the file as eximqueue.sh
######### Edit here ##########
_mail_user=info@r6host.com # Set this to your email id to receive alerts on mail queue
_limit=200 # Set the limit here
##############################
clear;
_result="/tmp/eximqueue.txt"
_queue="`exim-bpc`"
if [ "$_queue" -ge "$_limit" ]; then
echo "Current queue is: $_queue" > $_result
echo "Summary of Mail queue" >> $_result
echo "`exim -bp | exiqsumm`" >> $_result
mail -s "Number of mails on `hostname` : $_queue" $_mail_user < $_result
cat $_result
fi
rm -f $_result
Monday, 9 July 2012
Sunday, 8 July 2012
Counting Ips in an access log
So, If you need to look through an apache access log and count how many IP addresses there are this is how:
So this command will write out your access file to screen, use awk to print the first column, sort it, get the unique values, then sort it with a count, and print to "less".
Very useful to see if your being scraped!
root@sertechs [~]# cd /usr/local/apache/logs/
root@sertechs [~]# cat access_log | awk '{print$1}' | sort | uniq -c | sort -nr | less
So this command will write out your access file to screen, use awk to print the first column, sort it, get the unique values, then sort it with a count, and print to "less".
Very useful to see if your being scraped!
FIND Command
Some examples:
Find all files with 777 permissions:
find . -type f -perm 777 -print
Find all files that are older than 14 days and ls:
find . -type f -mtime +14 -exec ls -l {} ;
Find all your writable files and list them:
find . -perm -0777 -type f -ls
Find files and change their permission to writeable:
find . -name "NAME*" -exec chmod 666 {} ;
Find files created in the past 7 days:
find . -mtime -7 -type f
Find files modified in the past 7 days:
find . -mtime -7 -type f
Find files owned by a particular user:
find . -user esofthub
Find files that were modified more than 7 days ago and tar them into an archive (with a date in the name):
find . -type f -mtime +7 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files that were modified less than 7 days ago and tar them into an archive (with a date in the name):
find . -type f -mtime -7 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find how many files are in a path:
find . -type f -exec basename {} ; | wc -l
Find the top 50 Biggest Files:
find / -type f -not -path "/proc/*" -not -path "/dev/*" -not -path "/sys/*" -not -path "/home/rack/*" -printf "%s %h/%fn" | sort -rn -k1 | head -n 50 | awk '{print $1/1048576 "MB" " " $2}'
Find all files with 777 permissions:
find . -type f -perm 777 -print
Find all files that are older than 14 days and ls:
find . -type f -mtime +14 -exec ls -l {} ;
Find all your writable files and list them:
find . -perm -0777 -type f -ls
Find files and change their permission to writeable:
find . -name "NAME*" -exec chmod 666 {} ;
Find files created in the past 7 days:
find . -mtime -7 -type f
Find files modified in the past 7 days:
find . -mtime -7 -type f
Find files owned by a particular user:
find . -user esofthub
Find files that were modified more than 7 days ago and tar them into an archive (with a date in the name):
find . -type f -mtime +7 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files that were modified less than 7 days ago and tar them into an archive (with a date in the name):
find . -type f -mtime -7 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find how many files are in a path:
find . -type f -exec basename {} ; | wc -l
Find the top 50 Biggest Files:
find / -type f -not -path "/proc/*" -not -path "/dev/*" -not -path "/sys/*" -not -path "/home/rack/*" -printf "%s %h/%fn" | sort -rn -k1 | head -n 50 | awk '{print $1/1048576 "MB" " " $2}'
Install zend optimiser on direct admin server
cd /usr/local/directadmin/custombuild
./build update
vi /usr/local/directadmin/custombuild/options.conf
Change no to yes in options.conf
./build zend
./build update
vi /usr/local/directadmin/custombuild/options.conf
Change no to yes in options.conf
./build zend
How to enable open_basedir for particular domain in plesk
SSH into your Plesk machine as “root” and cd to the conf directory for the domain.
Create a “vhost.conf” file in “/var/www/vhosts/<domain name>/conf/”
<Directory /var/www/vhosts/<domain name>/httpdocs>
php_admin_value safe_mode on
php_admin_value open_basedir none
</Directory>
Rebuild the domain configs for the particular host via::–
[ #/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=<domain name> ]
or rebuild all via :
#/usr/local/psa/admin/sbin/websrvmng -a
#service httpd reload
Create a “vhost.conf” file in “/var/www/vhosts/<domain name>/conf/”
<Directory /var/www/vhosts/<domain name>/httpdocs>
php_admin_value safe_mode on
php_admin_value open_basedir none
</Directory>
Rebuild the domain configs for the particular host via::–
[ #/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=<domain name> ]
or rebuild all via :
#/usr/local/psa/admin/sbin/websrvmng -a
#service httpd reload
phpmyadmin upload limitation
To increase the phpmyadmin upload limitation in cpanel servers you can edit the php.ini file mentioned below :
vi /usr/local/cpanel/3rdparty/etc/phpmyadmin/php.ini.
upload_max_filesize = 100M
post_max_size = 100M
Even if you edit the main php.ini file it wont work in this case.
Cpanel >> phpmyadmin may not reflect the change, if so go to
WHM >> tweak settings >> cPanel PHP max POST size >> and increase the limit.
or
Increase WHM >> Tweak Settings >> cPanel PHP max upload size
vi /usr/local/cpanel/3rdparty/etc/phpmyadmin/php.ini.
upload_max_filesize = 100M
post_max_size = 100M
Even if you edit the main php.ini file it wont work in this case.
Cpanel >> phpmyadmin may not reflect the change, if so go to
WHM >> tweak settings >> cPanel PHP max POST size >> and increase the limit.
or
Increase WHM >> Tweak Settings >> cPanel PHP max upload size
Subscribe to:
Posts (Atom)