Thursday 31 July 2014

Squid Analyzer - Squid Report Analyzer

 





Squid Proxy native log analyzer and reports generator with full statistics about times, hits, bytes, users, networks, top urls and top domains. Statistic reports are oriented toward user and bandwidth control; this is not a pure cache statistics generator.
SquidAnalyzer use flat files to store data and don't need any SQL, SQL Lite or Berkeley databases.

This log analyzer is incremental and should be run in a daily cron or more often on huge network traffic. 


Squid Analyzer in CentOS 6.4

----------------------------------------------------------------------------------------
1) Stop unwanted Services or settings
----------------------------------------------------------------------------------------
# /etc/init.d/NetworkManager stop
# chkconfig NetworkManager off
Note: Make sure you have configured Network i.e. (IP Address/Netmask/Gateway/DNS)

# vi /etc/sysconfig/selinux
SELINUX=disabled



----------------------------------------------------------------------------------------
2) Open Necessary Ports in iptables
----------------------------------------------------------------------------------------
[root@server ~]#vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT


----------------------------------------------------------------------------------------
3) Install Require Packages and dependencies and verify
----------------------------------------------------------------------------------------

[root@server ~]#yum install perl-ExtUtils-MakeMaker perl-GD-Graph perl-GD-Graph3d make gd libpng
[root@server ~]#yum install perl-Time-HiRes



----------------------------------------------------------------------------------------
4) Download Squidanalyzer Packages Compile
----------------------------------------------------------------------------------------
[root@server ~]#cd /var/www/
[root@server ~]#wget http://downloads.sourceforge.net/project/squid-report/squid-report/5.4/squidanalyzer-5.4.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fsquid-report%2F&ts=1406810704&use_mirror=cznic
[root@server ~]#tar -zxvf squidanalyzer-5.4.tar.gz
[root@server ~]#cd squidanalyzer-5.4
[root@server ~]#perl Makefile.PL
[root@server ~]#make
[root@server ~]#cp SquidAnalyzer.pm blib/lib/SquidAnalyzer.pm
[root@server ~]#make install





----------------------------------------------------------------------------------------
5) Install and Configure Apache Web Server
----------------------------------------------------------------------------------------
[root@server ~]#yum install httpd

[root@server ~]#vi /etc/httpd/conf/httpd.conf



### SquidAnalyzer ###
Alias /squidreport /var/www/squidanalyzer
<Directory /var/www/squidanalyzer>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Deny from all
Allow from all
</Directory>




[root@server ~]#/etc/init.d/httpd restart


----------------------------------------------------------------------------------------
6) Create squidanalyzer-update script Set Cron for squidanalyzer
----------------------------------------------------------------------------------------

[root@server ~]#vi /etc/cron.daily/squidanalyzer-update.sh

#!/bin/sh
/usr/local/bin/squid-analyzer --logfile /opt/squid/var/logs/access.log --configfile /etc/squidanalyzer/squidanalyzer.conf

[root@server ~]#chmod +x /etc/cron.daily/squidanalyzer-update.sh




----------------------------------------------------------------------------------------
7) Edit squidanalyzer Main Config File & Do Following Changes
----------------------------------------------------------------------------------------

[root@server ~]#vi /var/www/squidanalyzer/etc/squidanalyzer.conf

# Set the path to the Squid log file
LogFile /opt/squid/var/logs/access.log



----------------------------------------------------------------------------------------
8) Edit squidanalyzer network-aliases Config File & Do Following Changes
----------------------------------------------------------------------------------------

[root@server ~]#vi /var/www/squidanalyzer/etc/network-aliases
ClassC Network          192.168.1.0/24

ClassC Network          192.168.2.0/24

Access via Browser

http:SERVER-IP or http://Server-IP-squidreport




#################################################################################################


Secure Your Directory Access with htpasswd


----------------------------------------------------------------------------------------
1: Edit httpd.conf & Insert Following Container
----------------------------------------------------------------------------------------

[root@server ~]#vi /etc/httpd/conf/httpd.conf

### SquidAnalyzer ###
Alias /squidreport /var/www/squidanalyzer
<Directory /var/www/squidanalyzer>
############### HTTP AUTHENTICATION START ############
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /opt/squidanalyzer.passwords
Require valid-user
############### HTTP AUTHENTICATION END ############

Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Deny from all
Allow from all
</Directory>


----------------------------------------------------------------------------------------
2: Then Generate a Username & Password with Following Command.
----------------------------------------------------------------------------------------

[root@server ~]#htpasswd -c /opt/squidanalyzer.passwords devendra


----------------------------------------------------------------------------------------
3: Check if password & username is generated
----------------------------------------------------------------------------------------

[root@server ~]#cat /opt/squidanalyzer.passwords
devendra:FgjXxAAssuZIo






Access via Browser

http:SERVER-IP or http://Server-IP-squidreport




Ref Link :http://squidanalyzer.darold.net/index.html










Sunday 27 July 2014

Vacation Plugin in Squirrelmail+Postfixadmin

Vacation Plug-in in Squirrelmail+Postfixadmin

Will be posting this steps very soon.... wait for some time..................


Saturday 26 July 2014

ifconfig command not found on CentOS 7

In CentOS 6.* and before, ifconfig command by default used . Whereas in minimal installed CentOS 7 there is no ifconfig command. so we have to install this command mannualy.

#ifconfig command not found.

To get install ifconfig command into the system , run the below command

#yum install net-tools



Now check the ifconfig command and its path in system (which and where is command will help)
   
#ifconfig
#ifconfig -a

Tuesday 22 July 2014

Linux LVM – Logical Volume Manager

This is what we are going to do
    • Create Partitions
    • Create physical volumes
    • Create Virtual Group
    • Create Logical Volumes
    • Create File system on logical volumes
    • Edit /etc/fstabExtend logical volume
      • Mount logical volumes

    • Remove logical volume

This article describes a basic logic behind a Linux logical volume manager by showing real examples of configuration and usage. Although Debian Linux will be used for this tutorial, you can also apply the same command line syntax with other Linux distributions such as Red Hat, Mandriva, SuSe Linux and others.

1. This is what we are going to do

Logical Volume Manager

2. Create Partitions

For this Linux lvm example you need an unpartitioned hard disk /dev/sdb. First you need to create physical volumes. To do this you need partitions or a whole disk. It is possible to run pvcreate command on /dev/sdb, but I prefer to use partitions and from partitions I later create physical volumes.
Logical Volume Manager List Partitions with fdisk
Use your preferred partitioning tool to create partitions. In this example I have used cfdisk.
Create partitions with cfdiskLogical Volume Manager List Partitions with fdisk
Partitions are ready to use.

3. Create physical volumes

Use the pvcreate command to create physical volumes.
# pvcreate /dev/sdb1
# pvcreate /dev/sdb2
The pvdisplay command displays all physical volumes on your system.
# pvdisplay
Alternatively the following command should be used:
# pvdisplay /dev/sdb1
Create physical volumes with pvcreate

4. Create Virtual Group

At this stage you need to create a virtual group which will serve as a container for your physical volumes. To create a virtual group with the name “mynew_vg” which will include /dev/sdb1 partition, you can issue the following command:
# vgcreate mynew_vg /dev/sdb1
To include both partitions at once you can use this command:
# vgcreate mynew_vg /dev/sdb1 /dev/sdb2
Create Virtual Group
Feel free to add new physical volumes to a virtual group by using the vgextend command.
# vgextend mynew_vg /dev/sdb2
virtual group extend

5. Create Logical Volumes

From your big cake (virtual group) you can cut pieces (logical volumes) which will be treated as a partitions for your linux system. To create a logical volume, named “vol01″, with a size of 400 MB from the virtual group “mynew_vg” use the following command:
  • create a logical volume of size 400 MB -L 400
  • create a logical volume of size 4 GB -L 4G
# lvcreate -L 400 -n vol01 mynew_vg
lvm lvcreate
With a following example you will create a logical volume with a size of 1GB and with the name vol02:
# lvcreate -L 1000 -n vol02 mynew_vg

lvcreate
Note the free size in virtual group.
lvcrete free space

6. Create File system on logical volumes

The logical volume is almost ready to use. All you need to do is to create a filesystem.:
# mkfs.ext3 -m 0 /dev/mynew_vg/vol01
the -m option specifies the percentage reserved for the super-user, set this to 0 if you wish not to waste any space, the default is 5%. create file system on the logical volumes

7. Edit /etc/fstab

Add an entry for your newly created logical volume into /etc/fstab
edit /etc/fstab to include logical volumes

7.1. Mount logical volumes

Before you mount do not forget to create a mount point.
# mkdir /home/foobar
mount logical volumes

8. Extend logical volume

The biggest advantage of logical volume manager is that you can extend your logical volumes any time you are running out of the space. To increase the size of a logical volume by another 800 MB you can run this command:
# lvextend -L +800 /dev/mynew_vg/vol01
Extend logical volume
The command above does not actually increase the physical size of volume, to do that you need to:
# resize2fs  /dev/mynew_vg/vol01
Look at the figure below to see what problems you may encounter when extending a volume:
Problem with extending a logical volume

9. Remove logical volume

The command lvremove can be used to remove logical volumes. Make sure that before you attempt to remove logical volumes your logical volume does not have any valuable data stored on it, moreover, make sure the volume is unmounted.
# lvdisplay
display volume group
# lvremove /dev/mynew_vg/vol02
remove logical volume

Friday 18 July 2014

OSTicket in CentOS 6.4

OsTicket is a widely-used and trusted open source support ticket system.
It seamlessly routes enquiries created via email, web-forms and phone calls into a simple, easy-to-use, multi-user, web-based customer support platform.
osTicket comes packed with more features and tools than most of the expensive (and complex) support ticket systems on the market.
The best part is, it's completely free.


OsTicket's core features not only rival, but also exceed most high-priced help desk solutions


Custom Fields
Customize the data collected from users when submitting a ticket to help get straight to the issue.

Rich Text HTML
Rich text or HTML email, is supported and allows for rich text markup in staff replies and internal notes posted to the ticket thread.

Ticket Filters
Define rules to route incoming tickets to the right departments or staff members, and action triggers.

Help Topics
Configurable help topics for web tickets. Route inquiries without exposing internal departments or priorities.

Agent Collision Avoidance
Ticket locking mechanism to allow staff to lock tickets during response and avoid conflicting or dual responses.

Assign and Transfer
Transfer tickets between departments to make sure it's being handled by the correct staff. Assign tickets to a staff or to a team.

Auto-Responder
Configurable automatic reply sent out when a new ticket is opened or a message is received.

Internal Notes
Add internal notes to tickets for staff. Activity logs let you see events or actions that have been taken, when they took place, and by whom.

Service Level Agreements
SLA Plans allow you to track tickets and due dates without the hassle.

Customer Portal
All support requests and responses are archived online. User can login using email and ticket ID. No user account or registration required to submit a ticket.

Dashboard Reports
Get system overview and basic historical statistics on tickets count and status per department, staff and help topics.










Installation of OsTicket

Note: I had compile Apache & php in /opt


----------------------------------------------------------------------------------------
1) Stop unwanted Services or settings
----------------------------------------------------------------------------------------
# /etc/init.d/NetworkManager stop
# chkconfig NetworkManager off
Note: Make sure you have configured Network i.e. (IP Address/Netmask/Gateway/DNS)

# /etc/init.d/sendmail stop
# chkconfig sendmail off
# vi /etc/sysconfig/selinux
SELINUX=disabled

----------------------------------------------------------------------------------------
2) Open Necessary Ports in iptables
----------------------------------------------------------------------------------------
# vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
#/etc/init.d/iptables restart
#chkconfig iptables on

----------------------------------------------------------------------------------------
3) Download and install Additional YUM repositories
----------------------------------------------------------------------------------------
#mkdir  /softwares
#cd  /softwares
#wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
#rpm -ivh epel-release-6-8.noarch.rpm
#wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
#rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm


----------------------------------------------------------------------------------------
4) Install Dependencies
----------------------------------------------------------------------------------------

#yum install glibc glibc-common
#yum install gcc-*
#yum install zlib-*
#yum install openssl-*
#yum install libxml2-devel    (Require to compile PHP)
#yum install gdbm-devel        (GDM Library for PHP)


----------------------------------------------------------------------------------------
5) Create osticket database and configure
----------------------------------------------------------------------------------------

#/etc/init.d/mysqld start
#chkconfig mysqld on
#mysqladmin -u root password YOUR-PASSWORD
#mysql -u root -p


mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YOUR-PASSWORD' WITH GRANT OPTION;
mysql> create database osticket;
mysql> create user osticket IDENTIFIED BY 'osticket';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'osticket'@'%' IDENTIFIED BY 'osticket' WITH GRANT OPTION;
mysql> GRANT ALL ON osticket.* TO 'osticket'@'localhost' IDENTIFIED BY 'osticket' WITH GRANT OPTION;
mysql> quit


#lsof -i :3306


----------------------------------------------------------------------------------------
6) Download and install Install Aapache
----------------------------------------------------------------------------------------

#cd /softwares
#wget http://archive.apache.org/dist/httpd/httpd-2.2.25.tar.gz
#tar -zxvf httpd-2.2.25.tar.gz
#cd httpd-2.2.25

#./configure --prefix=/opt/apache --enable-mods-shared=all --enable-so --enable-cgi --enable-proxy --enable-headers --enable-expires --enable-vhost-alias --enable-info --enable-rewrite --enable-speling    --enable-usertrack --enable-deflate --enable-ssl --enable-mime-magic

#make

#make install

#vi /opt/apache/conf/httpd.conf
Listen 80
User apache
Group apache

#/opt/apache/bin/apachectl -k restart

#rm -rf /softwares/httpd-2.2.25


----------------------------------------------------------------------------------------
7) Download and install Install PHP
----------------------------------------------------------------------------------------
#yum install mysql mysql-server
#yum install gd
#yum install libpng
#yum install libjpeg
#yum install php-gd
#yum install libpng-devel
#yum install libjpeg-devel
#yum install libXpm-devel
#yum install libmcrypt-*
#yum install uw-imap*    Note:  this package is available at  wget ftp://rpmfind.net/linux/epel/5/x86_64/uw-imap-2007e-14.el5.x86_64.rpm
#yum install libc-client
#yum install libc-client-devel
#yum install pam-devel



----------------------------------------------------------------------------------------
8) Install imap to suport php-imap extention
----------------------------------------------------------------------------------------

> Note in CentOS 6 you need to compile imap php support seperatly to do so use following script

# vi setup-imap.sh

#!/bin/sh
# Script for PHP-IMAP installation. 0.1b
# Written by Martynas Bendorius (smtalk)

CWD=`pwd`
OS=`uname`

#Is it a 64-bit OS?
B64=0
   
B64COUNT=`uname -m | grep -c 64`
if [ "$B64COUNT" -eq 1 ]; then
    B64=1
    LD_LIBRARY_PATH=/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib
    export LD_LIBRARY_PATH
fi

if [ ! -e /usr/include/krb5.h ] && [ -e /etc/redhat-release ]; then
    echo "Installing krb5-devel"
    yum -y install krb5-devel
fi

VERSION=2006k
URL="ftp://ftp.cac.washington.edu/imap/old/imap-${VERSION}.tar.Z"
FILENAME=imap-${VERSION}
TARBALL=${FILENAME}.tar.Z

echo "Downloading ${TARBALL}..."
wget -O ${TARBALL} ${URL}
tar xzf ${TARBALL}
cd ${FILENAME}

echo "Installing ${FILENAME}..."

if [ ${OS} = "FreeBSD" ]; then
    if [ ${B64} -eq 0 ]; then
        make bsf
    else
        make bsf EXTRACFLAGS=-fPIC
    fi
else
    perl -pi -e 's#SSLDIR=/usr/local/ssl#SSLDIR=/etc/pki/tls#' src/osdep/unix/Makefile
    perl -pi -e 's#SSLINCLUDE=\$\(SSLDIR\)/include#SSLINCLUDE=/usr/include/openssl#' src/osdep/unix/Makefile
    perl -pi -e 's#SSLLIB=\$\(SSLDIR\)/lib#SSLLIB=/usr/lib/openssl#' src/osdep/unix/Makefile
    if [ ${B64} -eq 0 ]; then
        make slx
    else
        make slx EXTRACFLAGS=-fPIC
    fi
fi

echo "Copying files to /usr/local/php-imap"
mkdir -p /usr/local/php-imap/include
mkdir -p /usr/local/php-imap/lib
chmod -R 077 /usr/local/php-imap
cp -f c-client/*.h /usr/local/php-imap/include/
cp -f c-client/*.c /usr/local/php-imap/lib/
cp -f c-client/c-client.a /usr/local/php-imap/lib/libc-client.a
cd ..
rm -rf ${FILENAME}

exit 0;
------------------------------------------------------------------------------------------------------

#chmod +x setup-imap.sh

#./setup-imap.sh

----------------------------------------------------------------------------------------
9) Download and Install php with mysql + apache support
----------------------------------------------------------------------------------------


#cd /softwares

#wget http://us2.php.net/get/php-5.5.5.tar.gz/from/in1.php.net/mirror
#tar -zxvf php-5.5.5.tar.gz
#cd php-5.5.5


Node: following configuration parameter would install gd extention support also.

#./configure --prefix=/opt/apache/php --with-apxs2=/opt/apache/bin/apxs --enable-cli --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-sockets --with-config-file-path=/opt/apache/php --with-mysql=/opt/mysql --with-xmlrpc --without-pear --with-gd --with-jpeg-dir=/opt/apache/php --with-png-dir=/opt/apache/php --with-mcrypt --with-mcrypt --with-zlib --with-gettext --with-gdbm  --enable-pdo  --with-pdo-mysql --with-imap=/usr/local/php-imap  --with-imap-ssl --with-kerberos  --with-openssl
#make
#make install
#cp /softwares/php-5.5.5/php.ini-production /opt/apache/php/php.ini



Edit php.ini & Check following

1: short_open_tag
2: date.timezone


#vi /opt/apache/php/php.ini

short_open_tag = On



#vi /opt/apache/php/php.ini

date.timezone = Asia/Kolkata




#vi /opt/apache/conf/httpd.conf

#++++++++PHP+++++++++++
# Make sure there's only **1** line for each of these 2 directives:
# Use for PHP 4.x:
#LoadModule php4_module modules/libphp4.so
#AddHandler php-script  .php
# Use for PHP 5.x:
#LoadModule php5_module  modules/libphp5.so
AddHandler php5-script  .php
# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php
AddType text/html       .php
# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source phps
#++++++++++PHP+++++++++++++++

#/opt/apache/bin/apachectl -k restart

#/opt/apache/bin/httpd -M | grep php
Syntax OK
php5_module (shared)

#rm -rf  /softwares/php-5.5.5




----------------------------------------------------------------------------------------
10) Download and install Install OSTicket
----------------------------------------------------------------------------------------

#cd /softwares

#wget http://osticket.com/dl/osTicket-v1.7.2.zip
OR
#wget https://github.com/osTicket/osTicket-1.7/releases/download/v1.7.3/osTicket-v1.7.3.zip


# unzip osTicket-v1.7.2.zip

# mkdir /opt/osticket/

# cp  -r /softwares/upload/* /opt/osticket/

#chown -R  apache.apache /opt/osticket/

#vi /opt/apache/conf/httpd.conf

### OS Ticket ###
Alias /ticket /opt/osticket
<Directory /opt/osticket/>
Options Indexes
AllowOverride none
DirectoryIndex index.php
Order allow,deny
allow from all
</Directory>

#/opt/apache/bin/apachectl -k restart


http://SERVER-IP/ticket
http://LOCALHOST/ticket
http://127.0.0.1/ticket


#Fill all the required Setting i.e Name, Email ID & all.

#Also Fill the Database setting i.e DBName,DBUser,DBPassowrd & Click on Install


# cp /opt/osticket/include/ost-sampleconfig.php /opt/osticket/include/ost-config.php
# chown apache.apache /opt/osticket/include/ost-config.php





# chmod 664 /opt/osticket/include/ost-config.php
# rm -rf /opt/osticket/setup/

Note: We have mapped helpdesk.linuktricks.com A Record in My DNS
Go to installer program and follow the instructions:

----------------------------------------------------------------------------------------
11) Empty /opt/apache/conf/extra/httpd-vhosts.conf file
----------------------------------------------------------------------------------------

#> /opt/apache/conf/extra/httpd-vhosts.conf


#vi /opt/apache/conf/extra/httpd-vhosts.conf

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin devendra.joshi@linuktricks.com
    DocumentRoot /opt/osticket
    ServerName helpdesk.linuktricks.com
    ErrorLog "logs/ticket-error_log"
    CustomLog "logs/ticket-access_log" common
</VirtualHost>


#vi /opt/apache/conf/httpd.conf
Include conf/extra/httpd-vhosts.conf

#/opt/apache/bin/apachectl -k restart

#mkdir /opt/osticket/attachment
#chown apache.apache /opt/osticket/attachment
#chmod 777 /opt/osticket/attachment





Note :For HT Password : http://www.htaccesstools.com/htpasswd-generator/