Rabu, 10 September 2014

In the area of monitoring systems using GPL software Nagios is a big player but the organization of
displaying the history graphs is not so ideal.
Zabbix is wonderful as well, it produces also good graphs but it creates them dynamically, resulting
in a long wait time when we need to display a large amount of them at once. To achieve this Cacti
is one of the best GPL History-Graphs-Only monitoring program out there.
Note:
I have put together here a step-by-step HOWTO to help setting-up some of the most important items to be monitored in a short time. Although the theme says to use ‘Lenny’ the same should apply to Squeeze with very minor modification if any.
The difficulty with the version of Cacti provided with Debian Lenny/Squeeze is that it’s outdated.
I tried to install the latest version of Cacti and somehow got into some difficulties which
I felt I didn’t want to bother solving. I knew there was a faster solution to this and didn’t have the time
to do troubleshooting.
The fast solution is to install the regular (and outdated) Debian version of Cacti
and then replace its components with the latest version(0.8.7.g).
For later versions, simply replace the version number where applied. So here is how I did it:

Install the Debian Lenny/Squeeze version

apt-get install cacti
Note: Please make sure you complete the whole installation especially concerning the creation of the Mysql Database.
Download the current Cacti version
(at the time of this article the version 0.8.7g was the latest one.)
wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
Put the Debian Cacti files aside to leave space to the new one.
mv /usr/share/cacti /usr/share/cacti_Debian
Prepare space for the new version
mkdir -p /usr/share/cacti-0.8.7g
Install the new version with the same directory structure as with the Debian version
tar fvxz cacti-0.8.7g.tar.gz -C /usr/share/cacti-0.8.7g/
mv /usr/share/cacti-0.8.7g/cacti-0.8.7g /usr/share/cacti-0.8.7g/site
ln -s /usr/share/cacti-0.8.7g /usr/share/cacti
mv /usr/share/cacti-0.8.7g/site/rra /usr/share/cacti-0.8.7g/site/rra_orig
ln -s /var/lib/cacti/rra /usr/share/cacti-0.8.7g/site/rra
ln -s /usr/share/cacti-0.8.7g/site/resource /usr/share/cacti-0.8.7g/resource

Get a copy of the config.php from Debian version
This php file refers to the configuration file /etc/cacti/debian.php as installed by the original Debian version.
mv /usr/share/cacti/site/include/config.php /usr/share/cacti/site/include/config.php.orig
cp /usr/share/cacti_Debian/site/include/config.php /usr/share/cacti/site/include/config.php

Restart your web server
/etc/init.d/apache2 restart
Upgrade to the new cacti
http://myserver.com/cacti
and simply follow the on screen instructions to upgrade to the new version.
NOTES:
1) Debian Lenny/Squeeze uses the SNMP protocol Ver. 2.0 therefore make sure you do
configure the correct version in the cati web interface.
2) For better compatibility, in the /etc/snmp/snmpd.conf I used only the following configuration:
com2sec readonly default public
group MyROSystem v1 paranoid
group MyROSystem v2c paranoid
group MyROSystem usm paranoid
group MyROGroup v1 readonly
group MyROGroup v2c readonly
group MyROGroup usm readonly
group MyRWGroup v1 readwrite
group MyRWGroup v2c readwrite
group MyRWGroup usm readwrite
view all included .1 80
view system included .iso.org.dod.internet.mgmt.mib-2.system
access MyROSystem "" any noauth exact system none none
access MyROGroup "" any noauth exact all none none
access MyRWGroup "" any noauth exact all all none
syslocation Unknown (configure /etc/snmp/snmpd.local.conf)
syscontact Root (configure /etc/snmp/snmpd.local.conf)
Restart SNMPD Daemon
/etc/init.d/snmpd restart
Testing the SNMP configuration on the monitored system
snmpwalk -Os -c public -v 1 localhost system
3) I prefer to use the UDP Ping instead of the SNMP Ping for finding out if the server is available. This way if the SNMP service dies in the monitored host I get the proper information regarding if the monitored host died or not.
4) In our case, since we are going to get all sorts in information from the system where the user snmp is not allowed, we need to run the snmpd daemon as ‘root’ instead as ‘snmp’. To do this do the following changes:
vim /etc/default/snmpd
snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-Lsd -Lf /var/log/snmpd.log -u root -I -smux -p /var/run/snmpd.pid 192.168.0.3,127.0.0.1'
Note: You also need to include the IP of the interface from where the monitoring server will be making its queries. In the above SNMPDOPTS settings, both interfaces having the IPs 192.168.0.3 and 127.0.0.1 will accept snmp queries. If any of the connected to the internet, make sure the /etc/hosts.allow/ & /etc/hosts.deny are correctly configured as follows:
Allowing the monitoring server acccess to snmpd daemon
In /etc/hosts.allow
snmpd: 90.78.145.72
Making sure all other hosts are denied access
In /etc/hosts.deny
snmpd: ALL

Installing some cacti templates

Apache statistics

In the monitored hosts
Make sure that in the client host you configure Apache for extended server-status and if needed configure the access control to accept the monitoring server where cacti runs.
In the monitoring server
– Download the apache template locally in desktop from
– Import the template in Cacti interface
wget http://public.itmatrix.eu/Cacti_templates/Apache/cacti_host_template_webserver_apache.xml
– Login as root:
cd /usr/share/cacti/site/scripts
wget http://public.itmatrix.eu/Cacti_templates/Apache/ws_apachestats.pl

Postfix queues

In the monitored host:
– download the postfix queues script in to /usr/local/bin/
cd /usr/local/bin/
wget http://public.itmatrix.eu/Cacti_templates/Postfix_queues/getmailq.sh
chmod 755 /usr/local/bin/getmailq.sh

Add the necessary SNMP configuration and restart
echo 'extend .1.3.6.1.4.1.2021.53.101.0 mailq /usr/local/bin/getmailq.sh' >> /etc/snmp/snmpd.conf
/etc/init.d/snmpd restart

Testing the script in the monitored host:
/usr/bin/snmpwalk -Oav -v2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.53.101.0.4 | cut -d'"' -f2
You should get an output similar to this:
incoming:0 active:0 deferred:6 hold:0
In the monitoring server:
Log into the monitoring server and get the data query script
cd /usr/share/cacti/site/scripts
wget http://public.itmatrix.eu/Cacti_templates/Postfix_queues/postfixqueues.sh
chmod 755 /usr/share/cacti/site/scripts/postfixqueues.sh

Download and Import the template in cacti interface
http://public.itmatrix.eu/Cacti_templates/Postfix_queues/cacti_graph_template_postfix_queues.xml

Postfix statistics

In the monitored host
Download the postfix stats script in to /usr/local/bin/
cd /usr/local/bin/
wget http://public.itmatrix.eu/Cacti_templates/Postfix_stats/fetch_mail_statistics.pl
chmod 755 /usr/local/bin/fetch_mail_statistics.pl

Add the necessary SNMP configuration and restart
echo 'pass .1.3.6.1.4.1.2021.252 /usr/local/bin/fetch_mail_statistics.pl /var/log/mail.log /var/log/mailstats.db .1.3.6.1.4.1.2021.252' >> /etc/snmp/snmpd.conf
/etc/init.d/snmpd restart

Testing the script on the monitored host:
/usr/bin/snmpwalk -Oav -v2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.252
You should get an output similar to this:
Output Description
============= ====================================
INTEGER: 25 Received
INTEGER: 1 Sent
INTEGER: 58 Deferred (Saved and to be resent later)
INTEGER: 0 Bounced (Bounced back)
INTEGER: 293 Rejected (Total rejected mails)
INTEGER: 15 Clean
INTEGER: 188 Pspam (Possible SPAM GreyListed)
INTEGER: 287 Spam (RBL and spammassassin Blocked)
INTEGER: 0 Infected (Blocked Virus)
INTEGER: 1 Bad Header
INTEGER: 1 Banned (Banned content)

In the Monitoring server (Via cacti web interface)
Download and Import the host template in cacti interface
http://public.itmatrix.eu/Cacti_templates/Postfix_stats/cacti_host_template_postfix_mailserver.xml

DISK IO statistics

In the monitored host:
Download the DISK IO stats script into /usr/local/bin/
cd /usr/local/bin/
wget http://public.itmatrix.eu/Cacti_templates/Disk_IO/snmpdiskio
chmod 755 /usr/local/bin/snmpdiskio

Add entries to /etc/snmp/snmpd.conf
echo 'extend .1.3.6.1.4.1.2021.54 hdNum /usr/local/bin/snmpdiskio hdNum' >> /etc/snmp/snmpd.conf
echo 'extend .1.3.6.1.4.1.2021.55 hdIndex /usr/local/bin/snmpdiskio hdIndex' >> /etc/snmp/snmpd.conf
echo 'extend .1.3.6.1.4.1.2021.56 hdDescr /usr/local/bin/snmpdiskio hdDescr' >> /etc/snmp/snmpd.conf
echo 'extend .1.3.6.1.4.1.2021.57 hdInBlocks /usr/local/bin/snmpdiskio hdInBlocks' >> /etc/snmp/snmpd.conf
echo 'extend .1.3.6.1.4.1.2021.58 hdOutBlocks /usr/local/bin/snmpdiskio hdOutBlocks' >> /etc/snmp/snmpd.conf

Restart snmpd service
/etc/init.d/snmpd restart
Testing the data query on the monitored host:
/usr/bin/snmpwalk -Oav -v2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.54.4
/usr/bin/snmpwalk -Oav -v2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.55.4
/usr/bin/snmpwalk -Oav -v2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.56.4
/usr/bin/snmpwalk -Oav -v2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.57.4
/usr/bin/snmpwalk -Oav -v2c -c public 127.0.0.1 .1.3.6.1.4.1.2021.58.4

In the Monitoring server:
Install the needed xml file
mkdir -p /usr/share/cacti/extras
cd /usr/share/cacti/site/resource/
wget http://public.itmatrix.eu/Cacti_templates/Disk_IO/partition.xml
ln -s /usr/share/cacti/site/resource/snmp_queries/partition.xml /usr/share/cacti/extras/partition.xml

Download on local desktop and import the host template using the Cacti web interface
http://public.itmatrix.eu/Cacti_templates/Disk_IO/cacti_data_query_snmp_disk_statistics.xml
http://public.itmatrix.eu/Cacti_templates/Disk_IO/cacti_graph_template_disk_io_bytessec.xml

Advanced MySQL statistics

In the monitored host:
– Create a special user for monitoring in MySQL server with the same username and password for all monitored hosts
– This user must have the SUPER_Privilege only
– Use ‘PASSWORD’ type and NOT MD5 or something else
Make sure the mysql server binds to ALL network interfaces:
Edit /etc/mysql/my.cnf
[mysqld]
........
#bind-address = 127.0.0.1
bind-address = 0.0.0.0

Protect the mysql server from Internet access using a firewall or the /etc/hosts.allow & /etc/hosts.deny as follows:
————————————-
Allowing the monitoring server acccess to snmpd daemon
In /etc/hosts.allow
mysqld: 127.0.0.1 192.168.100.0/255.255.255.0
Making sure all other hosts are denied access
In /etc/hosts.deny
mysqld: ALL
In the Monitoring server:
Download and install the php script
cd /usr/share/cacti/site/scripts/
wget http://public.itmatrix.eu/Cacti_templates/Improved_Mysql/ss_get_mysql_stats.php
ln -s /usr/share/cacti/site/scripts/ss_get_mysql_stats.php /usr/share/cacti/extras/

Edit the name and password in /usr/share/cacti/site/scripts/ss_get_mysql_stats.php
eg.
$mysql_user = 'monitor';
$mysql_pass = 'monitor';

Download on desktop and Import the host template using the cacti web interface
http://public.itmatrix.eu/Cacti_templates/Improved_Mysql/cacti_host_template_x_db_server_ht_0.8.6j.xml

TeMySQL statistics

In the monitored host:
– Create a special user for monitoring in MySQL server with the same username and password for all monitored hosts
– This user must have the SUPER_Privilege only
– Use ‘PASSWORD’ type and nothing else
Make sure the mysql server binds to ALL network interfaces:
Edit /etc/mysql/my.cnf
[mysqld]
........
#bind-address = 127.0.0.1
bind-address = 0.0.0.0

Protect the mysql server from Internet access using a firewall or the /etc/hosts.allow & /etc/hosts.deny as follows:
Allowing the monitoring server acccess to snmpd daemon
In /etc/hosts.allow
mysqld: 127.0.0.1 192.168.100.0/255.255.255.0
Making sure all other hosts are denied access
In /etc/hosts.deny
mysqld: ALL
In the Monitoring server:
Download and install the php scripts
cd /usr/share/cacti/site/scripts/
wget http://public.itmatrix.eu/Cacti_templates/teMySQLcacti/mysql_stats.php
ln -s /usr/share/cacti/site/scripts/mysql_stats.php /usr/share/cacti/extras/

Download on desktop and Import the host template in cacti interface
http://public.itmatrix.eu/Cacti_templates/teMySQLcacti/cacti_host_template_temysql_host-step300-heartbeat600.xml
During the creation of teMysql graphs in each device, enter the name and password of the mysql user configured in the monitored host for this purpose.
eg.
Name: monitor
PW: monitor

Network statistics

In the monitoring server:
Log into the monitoring server and get the data query script
cd /usr/share/cacti/site/scripts
wget http://public.itmatrix.eu/Cacti_templates/Netstat/lvm_netstat_tcp.pl
chmod 755 /usr/share/cacti/site/scripts/lvm_netstat_tcp.pl
ln -s /usr/share/cacti/site/scripts/lvm_netstat_tcp.pl /usr/share/cacti/extras/

Download and Import the template using the cacti web interface
http://public.itmatrix.eu/Cacti_templates/Netstat/cacti_graph_template_snmp_get_tcp_connection_status.xml

Advanced Ping

In the monitoring server:
Log into the monitoring server and get the data query script:
cd /usr/share/cacti/site/scripts
wget http://public.itmatrix.eu/Cacti_templates/Advanced_ping/ss_fping.php
ln -s /usr/share/cacti/site/scripts/ss_fping.php /usr/share/cacti/extras/

Download and Import the template in cacti interface
http://public.itmatrix.eu/Cacti_templates/Netstat/cacti_graph_template_ping_advanced_ping_v1_3.xml

SNMP Disk Usage

In the monitoring server:
Log into the monitoring server and get the query xml file
cd /usr/share/cacti/site/resource/snmp_queries/
wget http://public.itmatrix.eu/Cacti_templates/hrStorageTable/hrStorageTable.xml
ln -s /usr/share/cacti/site/resource/snmp_queries/hrStorageTable.xml /usr/share/cacti/extras/

Download and Import the template in cacti interface
http://public.itmatrix.eu/Cacti_templates/hrStorageTable/cacti087d_data_query_snmp_-_hrstoragetable.xml

HTTP Response Time

In the monitoring server:
Log into the monitoring server and get the script file
cd /usr/share/cacti/site/scripts
wget http://public.itmatrix.eu/Cacti_templates/HTTP_response_time/http_response_time.pl
ln -s /usr/share/cacti/site/scripts/http_response_time.pl /usr/share/cacti/extras/

Download and Import the template using cacti web interface
http://public.itmatrix.eu/Cacti_templates/HTTP_response_time/cacti_data_template_http_reponse_time.xml
http://public.itmatrix.eu/Cacti_templates/HTTP_response_time/cacti_graph_template_http_response_time.xml

NOTE: If by any chance you get no graphs created after a good 10 minutes then look at this solution:
Click on ‘Graph Management’, Click on one of the ‘HTTP Response Time ‘ graphs links and if you get no graph and the ‘RRDTool Says:’
ERROR: the RRD does not contain an RRA matching the chosen CF
Then the following might be the reason:
You are using (the Graph Template includes) the LAST consolidation function.
But your RRA definitions do not include this CF.
Edit RRAs when clicking onto “Data Sources”, then select “RRAs”
and edit all of them to add “LAST” CF
Then, you’ll have to re-create the failing rrd file
By deleting the graph from Graph management and under each device create the graph again.

PostGres Statistics

PostGres Data Base Cacti templates:
Ref: http://forums.cacti.net/viewtopic.php?f=12&t=23300
Installation instruction:
1. Make sure you have enabled Statistic Collector in Postgres (postgresql.conf)
Till postgres 8.2
stats_start_collector = true
stats_command_string = true
stats_block_level = true
stats_row_level = true
stats_reset_on_server_start = false

From postgres 8.3
track_activities = on
track_counts = on
update_process_title = on

Also in this configuration file:
Make sure PostGresql server listens to the interfaces that will be used for connections:
Here you give the IP of the server’s local interfaces.
eg.
listen_addresses = '127.0.0.1,192.168.100.117'
2. Edit the access rights file /etc/postgresql/8.3/main/pg_hba.conf
Then make sure the clients will be allowed in via the same interface Postgres is listening on above:
Add the access rights line:
host all all 192.168.100.0/24 md5
3. Create new User in PostgreSQL ,for example ‘monitor’
(you don’t have to grant any special roles to this users AFAIK, any user has access to Statistic Tables).
su - postgres
createuser --pwprompt --encrypted --no-adduser --no-createdb monitor

– Enter password for new role: monitor
– Enter it again: monitor
– Shall the new role be allowed to create more new roles? (y/n) n
4. Try to connect remotely under this user to postgres Database:
psql -h YOUR_POSTGRES_HOST -U monitor -W postgres
and try execute following SQL:
select * from pg_stat_all_tables;
If everything work proceed with installation otherwise fix your problem till you get results.
5.In monitoring server:
Commands:
cd /usr/share/cacti/site/scripts
wget http://public.itmatrix.eu/Cacti_templates/PostGres/postgresql_database_stats/pgsql_stats.php
cd /usr/share/cacti/site/resource/script_queries
wget http://public.itmatrix.eu/Cacti_templates/PostGres/postgresql_database_stats/postgres_dbstat.xml

Description of templates.
pgsql_stats.php - the Script, put this in /scripts/
postgres_dbstat.xml - the Definition, put this in /resource/script_queries
cacti_data_query_postgresql_database_stats.xml - Data Query + Graphs - import into Cacti

6. Install the debian package ‘php-pgsql’
apt-get install php5-pgsql
/etc/init.d/apache2 restart

7. Download and Import the template using cacti web interface
http://public.itmatrix.eu/Cacti_templates/PostGres/postgresql_database_stats/cacti_data_query_postgresql_database_stats.xml
8. Edit pgsql_stats.php line 173 and 174 and put username and password you have created at point 1.
(I don’t know how to pass username and password parameters to Data Queries. If you know how,
let me know so I can remote username and password from script)
9. Edit your Host Template or Device and add PostgreSQL Database Stats in Data Queries.
10. Create your Graphs :)

My Processes

Note: this self made cacti monitoring template does the monitoring of the number of processes per specific services as follows:
OUTPUT example:
allprocs:226 apache2:12 mysqld:19 mysqld2:0 bash:1 gpg:0 pop3:3
Its called : MyProcessesMGT2 in the monioring list
In the monitoring server:
– get the script file
cd /usr/share/cacti/site/scripts
wget http://public.itmatrix.eu/Cacti_templates/My_Processes/my_processes.sh
chmod 755 /usr/share/cacti/site/scripts/my_processes.sh

Make sure the user www-data on the monitoring server can run via ssh without password the script /usr/share/cacti/site/scripts/my_processes.sh
Commands in monitoring server:
mkdir /home/www-data
usermod -d /home/www-data -s /bin/bash www-data
chown www-data. /home/www-data
su - www-data
ssh-keygen -t rsa
(just press Enter key at every question)

In each monitored hosts:
-Modify the user www-data in each monitored hosts, create a home directory for it
-Commands in monitored hosts:
mkdir /home/www-data
usermod -d /home/www-data -s /bin/bash
chown www-data. /home/www-data
passwd www-data

(Give 2 times the password ‘www-data’ (no worry it will be deleted right after we are finished)
When all monitored hosts are modified as above then go back to the monitoring server
Commands in monitoring server:
su - www-data (only if not already logged-in as www-data)
ssh-copy-id clientHost_1_Name (Give the 'www-data' password)
ssh-copy-id clientHost_2_Name "" "" ""
ssh-copy-id clientHost_3_Name "" "" ""
........

Try the connection
IMPORTANT: use the same hostname exactly as it is given as hostname in cacti for every monitored host here as clientHost_1_Name. If you get a question like:
Are you sure you want to continue connecting (yes/no)?
Answer ‘yes’.
ssh clientHost_1_Name (if all ok then CTRL-D to exit the session on this remote host)
ssh clientHost_2_Name (if all ok then CTRL-D to exit the session on this remote host)
ssh clientHost_3_Name (if all ok then CTRL-D to exit the session on this remote host)
.......

Disable all password of www-data in all monitored hosts
Make sure you are back loggged in as ‘root’
Commands in all monitored hosts:
ssh clientHost_1_Name sed -i 's/www-data:/www-data:*/' /etc/shadow
ssh clientHost_2_Name sed -i 's/www-data:/www-data:*/' /etc/shadow
ssh clientHost_3_Name sed -i 's/www-data:/www-data:*/' /etc/shadow
.........

Download and Import the template in cacti interface:
http://public.itmatrix.eu/Cacti_templates/My_Processes/cacti_data_template_myprocessesmdt2.xml
http://public.itmatrix.eu/Cacti_templates/My_Processes/cacti_graph_template_myprocessesmgt2.xml





nb: link from : http://tipstricks.itmatrix.eu/?p=721

Rabu, 02 Juli 2014

Untuk melimit melalui layer 7, maka script yang harus di tambahkan yaitu :

/ip firewall layer7-protocol
add comment="" name=High regexp="^.*get.+\\.(exe|rar|iso|zip|7zip|0[0-9][1-9]|flv|mkv|avi|mp4|3gp|rmvb|mp3|img|dat|mov).*\$"
add comment="" name=Mid regexp="^.*get.+\\.(zip|rar|7z).*\$"
add comment="" name=End regexp="^.*get.+\\.(pdf|doc|docx|xlsx|xls|rtf|ppt|ppt).*\$"
add comment="" name=Video regexp="http/(0\\.9|1\\.0|1\\.1)[\\x09-\\x0d ][1-5][0-9][0-9][\\x09-\\x0d -~]*(content-type: video)"

Menggunakan Regular Expersion silahkan googling untuk penjelasanya.
High = File yg biasa berukuran besar dan paling sering didownload
Mid = File bertype zip rar 7z berukuran hanya sampai 10 MB jika lebih akan dilimit
End = File yg tidak ingin di limit
Video = Stream Video

Kedua tandai mangle


/ip firewall mangle
add action=mark-packet chain=forward comment="High Eks" disabled=no dst-address-list=!Bypass layer7-protocol=High new-packet-mark=High-Ext passthrough=no protocol=tcp
add action=mark-packet chain=forward comment="Mid Eks" connection-bytes=10485760-4294967295 disabled=no layer7-protocol=Mid new-packet-mark=Mid-Ext passthrough=no protocol=tcp
add action=mark-packet chain=forward comment="Low Eks" disabled=no layer7-protocol=End new-packet-mark=End-Ext passthrough=no protocol=tcp
add action=mark-packet chain=forward comment=Video disabled=no layer7-protocol=Video new-packet-mark=Video passthrough=no protocol=tcp src-address-list=!Bypass

Unttuk selanjutnya... di queue nya setting sendiri ya.. ^_^

Selasa, 10 Juni 2014

Creating an alias for an account

The following codes illustrate how you can setup an alias. This step is optional since we are going to configure virtual mail domains later in this howto. I have added this step to make sure you understand how you can do this in case it is required.
Create a user
sudo useradd -m -s /bin/bash sysadmin
sudo passwd sysadmin
Edit the alias table
Open the alias file with:
sudo vi /etc/aliases
Add the following code:
fmaster: sysadmin
To make your changes take effect type:
sudo newaliases

To test your changes send a mail to fmaster and check the mail in /home/sysadmin/Maildir/new folder.

Per User .forward Files

Users can control their own mail delivery by specifying destinations in a file called .forward in their home directories. The syntax of these files is the same as system aliases, except that the lookup key and colon are not present.
I will illustrate an example here:
Assume that you need to forward all the mails which come to the sysadmin account to an another account. Enter the following commands:
su - sysadmin
touch .forward
Then open the .forward file
vi .forward
Add the following code:
fossedu@example.com
Remember to use email address which exists in this exercise.

Now send a mail to sysadmin and mail should come to fossedu@example.com
With this approach, every hosted domain can have its own info etc. email address. However, it still uses Linux system accounts for local mailbox deliveries.
With virtual alias domains, each hosted address is aliased to a local UNIX system account or to a remote address. The example below shows how to use this mechanism for the fossedu.org and linuxelabs.com domains.
Inside the main.cf file, we tell it how to handle these virtual domains:
sudo postconf -e "virtual_alias_domains = fossedu.org linuxelabs.com"
sudo postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"
Edit the /etc/postfix/virtual file:
Add two Linux system accounts
sudo useradd -m -s /bin/bash sigiri
sudo useradd -m -s /bin/bash kala
Set passwords for the above users.
sudo passwd sigiri
sudo passwd kala
sudo vi /etc/postfix/virtual
Add the following code segment:
info@fossedu.org       sigiri
info@linuxelabs.com    kala
To create a Map Database type :
sudo postmap /etc/postfix/virtual
postmap is utility program that will convert /etc/postfix/virtual to /etc/postfix/virtual.db in Berkley DB format, so that Postfix can access the data faster.
Restart Postfix to make changes take effect:
sudo /etc/init.d/postfix restart

Send mails to both info@fossedu.org and info@linuxelabs.com and those mails should come to mailboxes of sigiri and kalarespectively.

Kamis, 08 Mei 2014

This is a script to remove automatically all the 404 Not found PPA's.Copy the below code and paste it into a file and name it as ppa-remove.

---
#!/bin/bash
sudo rm /tmp/update.txt; tput setaf 6; echo "Initializing.. Please Wait"
sudo apt-get update >> /tmp/update.txt 2>&1; awk '( /W:/ && /launchpad/ && /404/ ) { print substr($5,26) }' /tmp/update.txt > /tmp/awk.txt; awk -F '/' '{ print $1"/"$2 }' /tmp/awk.txt > /tmp/awk1.txt; sort -u /tmp/awk1.txt > /tmp/awk2.txt
tput sgr0
if [ -s /tmp/awk2.txt ]
then
  tput setaf 1
  printf "PPA's going to be removed\n%s\n" "$(cat /tmp/awk2.txt)"
  tput sgr0
  while read -r line; do echo "sudo add-apt-repository -r ppa:$line"; done < /tmp/awk2.txt > out
  bash out
else
  tput setaf 1
  echo "No PPA's to be removed"
  tput sgr0
fi

---

Give execute permission to the script

#sudo chmod +x ppa-remove

Copy and paste the ppa-remove file into /usr/bin directory.So that you can access it from anywhere.
Usage

sudo ppa-remove



reff :
http://askubuntu.com/questions/65911/how-can-i-fix-a-404-error-when-updating-packages

Rabu, 26 Maret 2014

The first thing you need to do is set up DNS records.

This is so anyone browsing from the internet can find your site using it’s domain name. Preferably you are running your own name server on ISPConfig3. If that is the case you need to go to your domain registrar’s site and change the name servers from whatever was set up as default to yours. (If you are not running your own name server you can create the DNS records with your registrar.)
Yours are likely to be ns1.youdomain.com and ns2.yourdomain.com.

Next you need to add the zone records in ISPConfig3. I would recommend you use the ‘wizard’ to assist you with this if you’re not experienced. That will set you up web and mail records. There is an article waiting to be developed here giving you more detail, but in essence the fields you need to complete after pressing the wizard button should be similar to this:
Client: If you have made a client for this domain select it here
Domain: This is the domain that you are about to register  -    myfirstsite.com
IP Address: This is IP address that your server is publicly visible from, eg 95.67.188.1.   (it is not 192.168.0.100  That is your internal lan address)
NS1: This is the first name server address that you set up eg ns1.yourserverdomain.com
NS2: This is the second name server address that you set up eg ns2.yourserverdomain.com
Email: pick an email you own
Click the button ‘Create DNS Record’.

Now when anyone looks up ‘myfirstsite.com’ or email to you that domain, it will send the request to your server.

Now you need to add ‘myfirstsite.com’

This will instruct IPSConfig3 to make the relevant changes to Apache (that’s the web server) and install the default site files.
Click on the tab marked ‘Sites’.
In the main body of the page click ‘+Add new website’

If it’s for a client, select the client in the drop down field.
Now complete the following fields:
Domain: myfirstsite.com        – just type the domain name, don’t include www
You can leave most of the fields blank for a basic static site.
In auto subdomain, I usually select *.  This creates the directive  so a browser could type anything prior to the domain name and get to your site, eg, www.myfirstsite.com. anyprefix.myfirstsite.com or even just myfirstsite.com.
Click ‘save’.

That should be it. Now when browsing to myfirstsite.com you should get a default index page displayed.
It will look like this


That’s it. See Further guides for setting up FTP settings to upload some content.

Selasa, 25 Maret 2014

Mbox vs Maildir: Mail Storage Formats

The Unix world has two ways of storing mail messages, the traditional mbox format and the newer maildir format. Postfix and Dovecot supports the two mail storage format so you can use any format, but I highly recommend you use the maildir format.
The Mbox Format

This is the traditional way of storing mail messages in the Unix world. In this format, a regular text file which serves as the mail user’s mailbox file is created.
Mbox storage format

Mbox storage format
Fig. 1: Mbox storage format
How Mbox works
Receiving and storing a mail

    Lock the mailbox.
    Append the header (usually “From [sender's email address] [date and time received]“) and the mail into the mailbox file.
    Unlock the mailbox.

Retrieving a mail

    Lock the mailbox.
    Locate and read the mail.
    Update the mail status flag.
    Unlock the mailbox.

Deleting a mail

    Lock the mailbox.
    Move the contents of the mailbox, beginning from the position right after the mail to be deleted until the end of the mailbox, into the position of the mail to be deleted.
    Reduce the size of the mailbox file by the size of the deleted mail.
    Unlock the mailbox.

Searching a mail

    Lock the mailbox.
    Search the mailbox.
    Unlock the mailbox.


Advantages

    Format is universally supported.
    Appending a new mail into the mailbox file is fast.
    Searching text inside a single mailbox file is fast.

Disadvantages

    Has file locking problems.
    Has problems when used with network file systems.
    Format is prone to corruption.


The Maildir Format

This is a new way of storing mail messages. In this format, a directory usually named Maildir is created for each mail user. Under this directory are three more directories named new, cur and tmp.
Maildir storage format
Maildir storage format
Fig. 2: Maildir storage format
How Maildir works
Receiving and storing a mail

    Create a unique file in the tmp directory.
    Write the mail into the newly created file.
    Move the completely written mail into the new directory.

Retrieving a mail

    Locate and read the mail.
    Move the mail from new into the cur directory and append the mail status flag into the filename.

Deleting a mail

    Delete the file containing the mail.

Searching a mail

    Search each and every mail file.


Advantages

    Locating, retrieving and deleting a specific mail is fast.
    Minimal to no file locking needed.
    Can be used on network file system.
    Immune to mailbox corruption (assuming the hardware will not fail).

Disadvantages

    Some filesystems may not efficiently handle a large number of small files.
    Searching text, which requires all mail files to be opened is slow.

- See more at: http://www.linuxmail.info/mbox-maildir-mail-storage-formats/#sthash.RiiHuAEN.dpuf

Menyadap chating Yahoo Messenger

Sebagai seorang network administrator harus mengerti semua mengenai trafik yang melintasi jaringan baik LAN maupun internet. Bukan nya mengajari hal – hal negatif, tetapi hanya untuk pengetahuan saja. Kita dapat menyadap percakapan chating yahoo messenger, tentu harus dilakukan di internet gateway atau router internet berbasis linux. untuk mudahnya kita pakai ubuntu.


apt-get  install ngrep
ngrep ‘ ‘ port 5050 -d eth1
hasil percakapan yang disadap:
T 98.136.48.36:5050 -> 192.168.0.99:1036 [AP]
YMSG…………qA.B4..budi_santosa24..5..axxx_zzd..14..invis atau offline nih..15..1339139996..63..;0..64..0..97..1..206..2..252../7AuzhUKNkeHQsE0e3/v5id6NzWq1w==
..429..000000007A0D4DBC..450..0..455../7AuzhUKNkeHQsE0e3/v5id6NzWq1w==…

kita juga bisa melihat saat user mengetikan keyboard:
T 98.136.48.36:5050 -> 192.168.0.99:1036 [AP]
YMSG…..:.K….qA.B4..budi_santosa24..5..axxx_zzd..13..0..14.. ..49..TYPING…

Perintah untuk menyimpan hasil di file
ngrep ‘ ‘ port 5050 -d eth1 -O filechating

Untuk membaca hasilnya

ngrep -I filechating












*> http://kurusetra.web.id/2012/06/15/menyadap-chating-yahoo-messenger/

Rabu, 19 Maret 2014

  1. At a command prompt, type Nslookup, and then press ENTER.
  2. Type server <IP address>, where IP address is the IP address of your external DNS server.
  3. Type set q=MX, and then press ENTER.
  4. Type <domain name>, where domain name is the name of an external mail domain, and then press ENTER. The mail exchanger (MX) resource record for the domain that you entered should be displayed. If the MX record is not displayed, DNS is not configured to resolve external domain names.
The following example shows how the DNS server for example.com resolves the IP address of the external domain contoso.com:
C:\> nslookup
Default Server: pdc.corp.example.com
Address: 192.168.6.13
> server 10.255.255.255
Default Server: dns1.example.com
Address: 10.255.255.255
> set q=mx
> contoso.com.
Server: dns1.example.com
Address: 192.168.10.10
contoso.com MX preference = 10, mail exchanger = mail1.contoso.com
contoso.com MX preference = 10, mail exchanger = mail2.contoso.com
contoso.com MX preference = 10, mail exchanger = mail3.contoso.com
mail1.contoso.com internet address = 192.168.255.011
mail2.contoso.com internet address = 192.168.255.012
mail3.contoso.com internet address = 192.168.255.013

Rabu, 12 Maret 2014

Install ZpanelX Web Hosting Control Panel on Ubuntu Server 12.04
================================================================

---> About Zpanel

Zpanel is free and open source web hosting control panel designed to work on platform Linux, Unix, Mac OSX and Windows OS based servers or computers. It easy to use and manage web hosting server for SOHO (Small Office Home Office) or professional servers.

ZpanelX support for unlimited resellers and  flawlessly integrates with MySQL Server, Apache2, hMailServer (on Microsoft Windows), Posfix (on Linux Distribution) and Filezilla (on Microsoft Windows) or ProFTPd (on Linux Distribution). For more detail about Zpanelx feature  you can check out @Zpanel_Feature_Page

---> Step-by-Step to Install ZpanelX 10.0.0 on Ubuntu Server 12.04

This guide will show Step-by-step to install Zpanelx 10 web hosting control panel  in ubuntu 12.04 LTS Server edition. There are two methods  to installing Zpanelx: Methods 1). Install automatically using script auto-installer . Methods 2) Install manually, direct download source Zpanelx then install and config manually. It is recommended that you only install ZPanelx 10 on a fresh installation of Ubuntu Server. On this case my IP Address : 192.168.56.2 and Hostname : preciseserver

---> Method 1 : Install automatically using script auto-installer

<-> Step 1. Login to your server  using ssh and make sure you have all the latest security updates for Ubuntu Server 12.04 by running following commands

$ sudo apt-get update

$ sudo apt-get upgrade


<-> Step 2. Download script Zpanelx10 auto-installer for Ubuntu 12.04. This script work on Ubuntu server 12.04 x64 and Ubuntu server 12.04 x86.

wget https://dl.dropbox.com/u/50880014/ZPX_ubuntu_12-04_auto_installer.v1.02.zip


<-> Step 3. Install package tofrodos  using apt-get command.

sudo apt-get install tofrodos

Tofrodos comprises one program, “fromdos” alias “todos”, which converts text files to and from these formats. Use “fromdos” to convert DOS text files to the Unix format, and “todos” to convert Unix text files to the DOS format.


<-> Step 4. Unzip ZPX_ubuntu_12-04_auto_installer.v1.02.zip then convert these script from DOS text files to the Unix format using fromdos command.

unzip ZPX_ubuntu_12-04_auto_installer.v1.02.zip

sudo fromdos ZPX_ubuntu_12-04_auto_installer.sh


<-> Step 5. Change the permission of the install script so it can be executed.

chmod +x ZPX_ubuntu_12-04_auto_installer.sh

Run the installation script to disable AppArmor daemon

sudo ./ZPX_ubuntu_12-04_auto_installer.sh

Reboot your computer

sudo init 6


<-> Step 6. After reboot, run again  installation script.

sudo ./ZPX_ubuntu_12-04_auto_installer.sh

This script ask for all of the required information (such as IP address, Hostname/domain and Mysql password)

===================================================
= Starting Auto Installer for ZPX on Ubuntu 12.04 =
===================================================
=-------------------------------------------------=
= By Xengulai (xengulai@xengulai.com) =
=-------------------------------------------------=
===================================================
Variable collection:
Enter Server Public IP Address: 192.168.56.2
Enter server name:
(this should be the reverse lookup of 192.168.56.2)
(ex. zeus.zpanelcp.com): preciseserver
Enter FQDN for ZPX (ex. panel.zpanelcp.com): preciseserver
Enter MySQL root password: reloaded
Updating Aptitude Repos: Done.
Creating initial folder structure: Done.
Downloading / Extracting ZPX From SF to Temp Directory at /opt/zpanel: Done.
Copying ZpanelX files to /etc/zpanel: Done.
Registering 'zppy' client: Done.
Installing main packages: Done.
Setting Zpanel MySQL access: Done.
Importing Zpanel Core Database: Done.
Setting up Apache configuration to work with ZPX: Done.
Setting up Network info for ZPX and Compiling Default VHOST: Done.
Configuring Postfix and Dovecot: Done.
Configuring Roundcube: Done.
Installing and Configuring ProFTPD: Done.
Installing and Configuring BIND: Done.
Compiling zsudo: Done.
Setting cron for daemon.php: Done.
Registering ZPPY Client: Done.
Removing temp files: Done.
Restarting all necessary services:
-- Apache2 Web Server Restarted Successfully
-- Postfix Server Restarted Successfully
-- Dovecot Server Restarted Successfully
-- ProFTPD Server Restarted Successfully
-- MySQL Server Restarted Successfully
-- Bind9 Server Restarted Successfully
Installing ballen/rustus zppy repo and modules:
-- gatekeeper: installed
-- system_logviewer: installed
-- kfm: installed
-- ftp_browser: installed
-- visitor_stats: installed
=====================================================================
= Installation and Configuration of ZPX on Ubuntu 12.04 is Complete =
=====================================================================
=====================================================================
= Install Log can be found at /home/precise/zpx_install.log
=====================================================================
=====================================================================
= Please REBOOT the server and open: =
= http://preciseserver/zpanel
= or =
= http://192.168.56.2/zpanel
= =
= USER: zadmin =
= PASS: password (Change on 1st login!) =
=====================================================================
=====================================================================
= This script is not written by official ZPX Support =
= Please do not ask them for official support on this =
=====================================================================
=...................................................................=
= By Xengulai (xengulai@xengulai.com) =
=...................................................................=


<-> Step 7. Download and Install post-installation patches/sql script

wget https://dl.dropbox.com/u/50880014/post-install_patches.zip

unzip post-install_patches.zip

mysql -u root -p YOUR_ROOT_MYSQL_PASSWORD < /home/precise/post-install_patches.sql

sudo cp -R /home/precise/panel/* /etc/zpanel/panel/*

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

---> Methods 2: Install Zpanelx manually


<-> Step 1. Same as the first step in Method 1, Make sure you have all the latest security updates for Ubuntu Server 12.04 by running following commands

sudo apt-get update

sudo apt-get upgrade


<-> Step 2. Disable and remove ApparMor daemon, run following commands

sudo /etc/init.d/apparmor stop

sudo update-rc.d -f apparmor remove

sudo apt-get remove apparmor

sudo shutdown -r now


<->Step 3. Download Zpanelx 10 for linux. Download it using wget command

wget https://dl.dropbox.com/u/50880014/zpanelx-master.tar.gz


<-> Step 4. Extract zpanelx-master.tar.gz anywhere and run file prepare.sh

sudo tar -zxvf zpanelx-master.tar.gz

cd zpanel-master/etc/build

sudo chmod +x prepare.sh


<-> Step 5. Now copy all file and folder in the directory zpanel-master into /etc/zpanel/panel

sudo cp -R ../../* /etc/zpanel/panel/


<->Step 6. Copy configuration file for ubuntu server 12.04 into directory /etc/zpanel/configs

sudo cp -R /etc/zpanel/panel/etc/build/config_packs/ubuntu_12_04/* /etc/zpanel/configs/


<-> Step 7. Set permisson phpmyadmin configuration file (config.ic.php)

chmod 644 /etc/zpanel/panel/etc/apps/phpmyadmin/config.inc.php


<-> Step 8. Install the base packages Apache,MySQL and PHP5

sudo apt-get install apache2 mysql-server libapache2-mod-php5 libapache2-mod-bw php5-common php5-suhosin php5-cli php5-mysql php5-gd php5-mcrypt php5-curl php-pear php5-imap php5-xmlrpc php5-xsl libdb4.8 zip webalizer


<-> Step 9. Set up zpanelx database config and import zpanel database

sudo nano /etc/zpanel/panel/cnf/db.php

$host = "localhost";
$dbname = "zpanel_core";
$user = "root";
$pass = "YOUR_ROOT_MYSQL_PASSWORD";

mysql -u root -p YOUR_ROOT_MYSQL_PASSWORD < /etc/zpanel/configs/zpanel_core.sql


<-> Step 10. Configure Apache2 :

To add the ZPanel generated Apache2 config, we need to add the following line:-

edit /etc/apache2/apache2.conf

comment out:

#Include sites-enabled/

add at bottom:

Include /etc/zpanel/configs/apache/httpd.conf

Set ZPanel Network info and compile the default vhost.conf by running following commands

sudo /etc/zpanel/panel/bin/setso –set zpanel_domain CONTROLPANEL.YOURDOMAIN.COM

sudo /etc/zpanel/panel/bin/setso --set zpanel_domain preciseserver

sudo /etc/zpanel/panel/bin/setso –set server_ip YOUR_PUBLIC_IP_ADDRESS

sudo /etc/zpanel/panel/bin/setso --set server_ip 192.168.56.2

sudo php /etc/zpanel/panel/bin/daemon.php


<-> Step 11. Install and configure postfix-dovecot

sudo apt-get install postfix postfix-mysql dovecot-mysql dovecot-imapd dovecot-pop3d dovecot-common libsasl2-modules-sql libsasl2-modules

sudo mkdir -p /var/zpanel/vmail

sudo chmod -R 777 /var/zpanel/vmail

sudo chmod -R g+s /var/zpanel/vmail

sudo groupadd -g 5000 vmail

sudo useradd -m -g vmail -u 5000 -d /var/zpanel/vmail -s /bin/bash vmail

sudo chown -R vmail.vmail /var/zpanel/vmail

mysql -u root -p YOUR_ROOT_MYSQL_PASSWORD < /etc/zpanel/configs/postfix/zpanel_postfix.sql

# Config Postfix Master.cf

echo "# Dovecot LDA" >> /etc/postfix/master.cf

echo "dovecot unix - n n - - pipe" >> /etc/postfix/master.cf

echo ' flags=DRhu user=vmail:mail argv=/usr/lib/dovecot/deliver -d ${recipient}' >> /etc/postfix/master.cf

Edit the following file and add mysql root and password, you can use nano editor

    sudo nano /etc/zpanel/configs/postfix/conf/dovecot-sql.conf
    sudo nano/etc/zpanel/configs/postfix/conf/mysql_relay_domains_maps.cf
    sudo nano /etc/zpanel/configs/postfix/conf/mysql_virtual_alias_maps.cf
    sudo nano /etc/zpanel/configs/postfix/conf/mysql_virtual_domains_maps.cf
    sudo nano /etc/zpanel/configs/postfix/conf/mysql_virtual_mailbox_limit_maps.cf
    sudo nano /etc/zpanel/configs/postfix/conf/mysql_virtual_mailbox_maps.cf
    sudo nano /etc/zpanel/configs/postfix/conf/mysql_virtual_transport.cf

sudo mv /etc/postfix/main.cf /etc/postfix/main.old

sudo ln /etc/zpanel/configs/postfix/conf/main.cf /etc/postfix/main.cf

sudo mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.old

sudo ln -s /etc/zpanel/configs/dovecot2/dovecot.conf /etc/dovecot/dovecot.conf

Edit file /etc/zpanel/configs/postfix/conf/main.cf

myhostname = YOUR_DOMAIN
mydomain   = YOUR_DOMAIN

Reboot your computer


<-> Step 12. Configure roundcube

mysql -u root -p YOUR_ROOT_MYSQL_PASSWORD < /etc/zpanel/configs/roundcube/zpanel_roundcube.sql

edit file /etc/zpanel/panel/etc/apps/webmail/config/db.inc.php

nano /etc/zpanel/panel/etc/apps/webmail/config/db.inc.php

Edit this line

$rcmail_config['db_dsnw'] = 'mysql://root:YOUR_ROOT_MYSQL_PASSWORD@localhost/zpanel_roundcube';


<-> Step 13. Install and configure FTP server ProFTPD

sudo apt-get install proftpd-mod-mysql (When asked what mode, choose 'stand-alone')

mysql -uroot -pYOUR_ROOT_MYSQL_PASSWORD < /etc/zpanel/configs/proftpd/zpanel_proftpd.sql

sudo groupadd -g 2001 ftpgroup

sudo useradd -u 2001 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser

Edit /etc/zpanel/configs/proftpd/proftpd-mysql.conf, replace with your credentials:

You can use your MySQL root account if you wish or create a new restricted user account as you wish!

SQLConnectInfo zpanel_proftpd@localhost root your_root_password

sudo mv /etc/proftpd/proftpd.conf /etc/proftpd/proftpd.conf.backup

sudo touch /etc/proftpd.conf

sudo echo "include /etc/zpanel/configs/proftpd/proftpd-mysql.conf" >> /etc/proftpd/proftpd.conf

sudo touch /var/zpanel/logs/proftpd

sudo chmod -R 644 /var/zpanel/logs/proftpd


<-> Step 14. Install and Configure BIND DNS server

sudo apt-get install bind9 bind9utils

sudo mkdir /var/zpanel/logs/bind

sudo touch /var/zpanel/logs/bind/bind.log

sudo chmod -R 777 /var/zpanel/logs/bind/bind.log

sudo echo "include \"/etc/zpanel/configs/bind/etc/log.conf\";" >> /etc/bind/named.conf

sudo echo "include \"/etc/zpanel/configs/bind/etc/named.conf\";" >> /etc/bind/named.conf

sudo ln -s /usr/sbin/named-checkconf /usr/bin/named-checkconf

sudo ln -s /usr/sbin/named-checkzone /usr/bin/named-checkzone

sudo ln -s /usr/sbin/named-compilezone /usr/bin/named-compilezone


<-> Step 15. Configure Zpanel Zsudo

Must be owned by root with 4777 permissions, or zsudo will not work!

sudo cc -o /etc/zpanel/panel/bin/zsudo /etc/zpanel/configs/bin/zsudo.c

sudo chown root /etc/zpanel/panel/bin/zsudo

sudo chmod +s /etc/zpanel/panel/bin/zsudo


<-> Step 16. Configure the CRON job for the zdaemon

sudo touch /etc/cron.d/zdaemon

sudo echo "*/5 * * * * root /usr/bin/php -q /etc/zpanel/panel/bin/daemon.php >> /dev/null 2>&1" >> /etc/cron.d/zdaemon

sudo chmod 644 /etc/cron.d/zdaemon


<-> Step 17. Registering the zppy client

sudo ln -s /etc/zpanel/panel/bin/zppy /usr/bin/zppy


<-> Step 18. Reboot your computer, if your already turn on. access zpanel from computer on your network



reff :







***** 
http://ubuntuserverguide.com/2012/11/how-to-install-zpanelx-web-hosting-control-panel-on-ubuntu-server-12-04.html
*****