How to setup SquidAnalyzer on Centos.

Today we setup SquidAnalyzer for watch log of squid.
Step 1.  Make folder and download

mkdir /opt/squidanalyzer
cd /opt/squidanalyzer
yum install gd make libpng perl-ExUtils-MakeMaker perl-GD-Graph perl-GD-Graph3d perl-TimesHiRes

Step 2. Download file and install:

wget https://downloads.sourceforge.net/project/squid-report/squid-report/6.5/squidanalyzer-6.5.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fsquid-report%2F&ts=1490960374&use_mirror=netix
mv squidanalyzer-6.5.tar.gz\?r\=https\:%2F%2Fsourceforge.net%2Fprojects%2Fsquid-report%2F squidanalyzer-6.5.tar.gz
tar -zxvf squidanalyzer-6.5.tar.gz
cd squid*
perl Makefile.PL
make
make install

Step 3. Now make copy to original config file and config:

cp /etc/squidanalyzer/squidanalyzer.conf /etc/squidanalyzer/squidanalyzer.conf.orig

Edit config file with this options:
vim /etc/squidanalyzer/squidanalyzer.conf

# Path where SquidAnalyzer should dump all HTML and images files.
# Choose a path that can be read by a Web browser
Output /var/www/html/squidanalyzer

# The URL of the SquidAnalyzer javascript, HTML and images files.
## WebUrl /squidreport
WebUrl /squidanalyzer

# Set the path to the Squid, squidGuard and/or ufdbGuard log files
## LogFile /var/log/squid3/access.log
LogFile /var/log/squid/access.log
………………………………………
# Cost of the bandwith per Mb. If you want to generate invoice per Mb
# for bandwith traffic this can help you. Value 0 mean no cost.
# CostPrice 0.5
CostPrice 0

Step 4. Edit network-aliases of SquidAnalyzer.
vim /etc/squidanalyzer/network-aliases

#
# See examples below.
#
#——————————————————————————-
#Home Network 192\.168\.1\.
#Associated Networks ^10\.169\.[2-4]\.,^10\.169\.[7-9]\.
#ClassB Network 10.172.0.0/16
#ClassC Network 192.168.1.0/24
Custom Network 192.168.18.1/24

Step 5. add to crontab daily to update

vim /etc/crontab

# SquidAnalyzer log reporting daily
0 2 * * * root /usr/local/bin/squid-analyzer > /dev/null 2>&1

To generate file execute /usr/local/bin/squid-analyzer  and wait.

To see page with go to http://192.168.18.1/squidanalyzer/ ,  you can setup .htpasswd access secure this page.

Source information for this page: YouToube

[Solved] Error: virtual_mailbox_limit is smaller than message_size_limit

If you get error from postfix mail log we have sollutions.
Error:

fatal: main.cf configuration error: mailbox_size_limit is smaller than message_size_limit

Show information about mailbox_size_limit and message_size_limit:

[root@email ~]# postconf -n | grep virtual_mailbox_limit
virtual_mailbox_limit = 51200000
[root@email ~]# postconf -n | grep message_size_limit
message_size_limit = 52928640

Now set a new value for virtual_mailbox_limit (bigger than message_size_limit) as follows:

postconf -e ‘virtual_mailbox_limit = 102400000’

(Replace 102400000 with a value of your choice.)

As an alternative, you can disable virtual_mailbox_limit by setting it to 0:

postconf -e ‘virtual_mailbox_limit = 0’

/etc/init.d/postfix restart

Script to monitor disk space on Linux partition.

We want to monitor or watch the disk space on Linux Partitions.

Example of script:

#!/bin/sh
# set -x
# Shell script to monitor or watch the disk space
# It will send an email to $ADMIN, if the (free available) percentage of space is >= 90%.
# ————————————————————————-
# Set admin email so that you can get email.
ADMIN=”samba@domain.com”
### ADMIN=”clucian@ceae.info”
# set alert level 90% is default
ALERT=90
# Exclude list of unwanted monitoring, if several partions then use “|” to separate the partitions.
# An example: EXCLUDE_LIST=”/dev/sda1|/dev/sdc5″
### EXCLUDE_LIST=”/auto/ripper”
EXCLUDE_LIST=”/dev/md0|/dev/md2″
#
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#
function main_prog() {
while read output;
do
# echo $output
usep=$(echo $output | awk ‘{ print $2}’ | cut -d’%’ -f1)
partition=$(echo $output | awk ‘{print $3}’)
size=$(echo $output | awk ‘{print $1}’)
free=$(echo $output | awk ‘{print $4}’)
if [ $usep -ge $ALERT ] ; then
### echo “Running out of space \”$partition ($usep%)\” on server $(hostname), $(date)” | \
echo “Running out of space \”$partition ($usep%)\” server $(hostname), $(date), Space use = $size”, Free = $free. | \
mail -s “Alerta: Space on Samba este $usep%” $ADMIN
fi
done
}

if [ “$EXCLUDE_LIST” != “” ] ; then
df -H | grep -vE “^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}” | awk ‘{print $3 ” ” $5 ” ” $6 ” ” $4}’ | main_prog
else
df -H | grep -vE “^Filesystem|tmpfs|cdrom” | awk ‘{print $3 ” ” $5 ” ” $6 ” ” $4}’ | main_prog
fi

If you want more device to report or to see output on bash / cli uncoment “# echo $output”.
Enjoy. Source of info https://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html

Postfix reject mail from unknown IP

Q:  How to reject mails from unknown IP with Postfix ?

A:  Use  reject_unknown_reverse_client_hostname in you postfix config file.

Ex: vim /etc/postfix/main.cf

smtpd_recipient_restrictions =………………. , reject_unknown_reverse_client_hostname, ……..

smtpd_client_restrictions = hash:/etc/postfix/access, permit_mynetworks, permit_sasl_authenticated, reject_unknown_reverse_client_hostname, reject_rbl_client …………………………….

Info link: http://www.postfix.org/postconf.5.html#reject_unknown_reverse_client_hostname

How to reset admin password wordpress from SQL.

Q: How to reset WordPress password via SQL ?

A: Login to mysql database

mysql -u wordpress -p

use db_wordprs;

MariaDB [(none)]> use db_wordprs;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

MariaDB [db_wordprs]> select * from wp_users;

+—-+————+————————————+—————+——————+———-+———————+———————+————-+————–+
| ID | user_login | user_pass | user_nicename | user_email | user_url | user_registered | user_activation_key | user_status | display_name |
+—-+————+————————————+—————+——————+———-+———————+———————+————-+————–+
| 1 | admin | $P$BeI/6SDDb5x33lthRtdqaoVuO8.TfH/ | admin | liviu@team-work.ro | | 2016-10-26 07:55:16 | | 0 | admin |
+—-+————+————————————+—————+——————+———-+———————+———————+————-+————–+
1 row in set (0.00 sec)

And now change / update password:
UPDATE wp_users SET user_pass= MD5(‘Your-Password’) WHERE ID = 1;

MariaDB [db_rezes]> UPDATE wp_users SET user_pass= MD5(‘Your-Password’) WHERE ID = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

Enjoy, done.

How to add .htpasswd for Apache

  1. Suppose we have mod_rewrite activated in Apache

First step create a file .htaccess in you folder

vim /var/www/html/website/.htaccess
and add this

AuthUserFile /var/www/html/website/.htpasswd
AuthGroupFile /dev/null
AuthName "Please Enter Password"
AuthType Basic
Require valid-user

Now we add user in .htpasswd

htpasswd /var/www/html/website/.htpasswd  useracces

Enjoy !