How to enable SNMP Monitoring on Ubuntu Server 12.04.2

Install SNMPD 


$ sudo apt-get install snmpd

Create a backup file of snmpd.conf original file that we will edit later

$ sudo mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.ori

Create the new snmpd.conf file 

$ sudo vim /etc/snmp/snmpd.conf

Add the file with these lines

rocommunity public
syslocation "Your Location"
syscontact admin@domain.com

Then edit the /etc/default/snmpd file

$ sudo vim /etc/default/snmpd

Disable this line below by adding # in front of the line 

#SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'

And add a new line 

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'

Restart the SNMPD service

$ sudo /etc/init.d/snmpd restart
* Restarting network management services

Then you're done!

How to enable MySQL remote access on Ubuntu Server 12.04

By default MySQL on Ubuntu Server 12.04 can only be accessed from localhost (127.0.0.1). 

If we need to access it from another computer on the network, we must do the following step

Edit MySQL Configuration

$ sudo vim /etc/mysql/my.cnf

#comment out this line (add # in front of the line)
#bind-address           = 127.0.0.1

Restart the server

$ sudo service mysql restart
mysql stop/waiting
mysql start/running, process 13081

Then we need to add user info to the database

$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 77
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> grant all on [database_name].* to [user]@[ip_address] identified by '[password]'


Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye


That's all!

Reference:

http://ubuntuforums.org/showthread.php?t=799386

Installing and Configuring Freeradius + MySQL and Daloradius + MySQL on Ubuntu Server 12.04 for Mikrotik Hotspot/PPoE/PPTP (updated)

Installing and Configuring Freeradius

The first step is to Install Freeradius (ensure you already update your apt with apt-update)
$sudo apt-get install freeradius
 * Starting FreeRADIUS daemon freeradius                                 [ OK ] 
Setting up freeradius-utils (2.1.10+dfsg-3build2) ...

Then prepare the database for freeradius. Create database radius and assign username and password for accessing it. 

# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 51
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database radius; 
mysql> grant all on radius.* to radius@localhost identified by "thepassword";
Query OK, 0 rows affected (0.00 sec)

The next step was to insert the database schema and I realized that I could not find the database scheme in /etc/freeradius.

Obviously I should install freeradius-mysql package first. 

#apt-get install freeradius-mysql
Setting up freeradius-mysql (2.1.10+dfsg-3build2) ...
 * Reloading FreeRADIUS daemon freeradius                                [ OK ] 

Then insert the database scheme 

# mysql -u root -p radius < /etc/freeradius/sql/mysql/schema.sql 
Enter password:
# mysql -u root -p radius < /etc/freeradius/sql/mysql/nas.sql 
Enter password: 

Now we try to insert new user for testing purpose in database. 

# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 72
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use radius;
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
mysql> INSERT INTO radcheck (UserName, Attribute, Value) VALUES ('sqltest', 'Password', 'testpwd');
Query OK, 1 row affected (0.04 sec)

mysql> exit
Bye

The next step is we need to configure the Freeradius files. 

Edit /etc/freeradius/sql.conf file. Setting database type, login and password that we already setup before.

# vim /etc/freeradius/sql.conf
  
  database = mysql
  login = radius
  password = thepassword

  readclients = yes

Then edit the /etc/freeradius/sites-enabled/default file

# vim /etc/freeradius/sites-enabled/default 

    Uncomment sql on authorize{}
    # See “Authorization Queries” in sql.conf
    sql

    Uncomment sql on accounting{}
    # See “Accounting queries” in sql.conf
    sql

    Uncomment sql on session{}
    # See “Simultaneous Use Checking Queries” in sql.conf
    sql

    Uncomment sql on post-auth{}
    # See “Authentication Logging Queries” in sql.conf
    sql 
      
Then we edit /etc/freeradius/radiusd.conf file

# vim /etc/freeradius/radiusd.conf 

  #Uncomment #$INCLUDE sql.conf
  $INCLUDE sql.conf

To test our configuration, first we must stop the freeradius service (if already running) 
# /etc/init.d/freeradius stop
 * Stopping FreeRADIUS daemon freeradius                                 [ OK ]

Then run this command to run freeradius in debugging mode. If there is no error, you are good to go.
#freeradius -X

On a new shell or window we tested the connection

$ radtest sqltest testpwd localhost 18128 testing123
Sending Access-Request of id 65 to 127.0.0.1 port 1812
User-Name = "sqltest"
User-Password = "testpwd"
NAS-IP-Address = 127.0.1.1
NAS-Port = 18128
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=65, length=20

The test running well with Accept response from the server.

To enable Mikrotik device to access our server we need to add client in clients.conf file.

#vim /etc/freeradius/clients.conf

client 10.0.0.0/8 {

        secret = testingpassword
        shortname = testing
        nastype= mikrotik
}

*note: we need to stop freeradius -X and then running it again to test our configuration

Update (Jan 27, 2013):  If we want to add specific value for Mikrotik, we need to add mikrotik dictionary

#vim /etc/freeradius/dictionary 


Then add this line below


$INCLUDE  /usr/share/freeradius/dictionary.mikrotik


Mikrotik Configuration

We need to configure our Mikrotik devices to use our new radius server.  We need to login to Mikrotik device and configure the radius in Radius menu. 

Below image is an example of our configuration. 


*Note: we increase timeout settting to 3000ms to enable invalid login notifications. (not working with default 300ms)

Daloradius Installation 

First, we need to download daloradius file 

$wget http://downloads.sourceforge.net/project/daloradius/daloradius/daloradius0.9-9/daloradius-0.9-9.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fdaloradius%2Ffiles%2F&ts=1345296201&use_mirror=nchc

Rename and extract the file 

# tar xvfz daloradius-0.9-9.tar.gz
# mv daloradius-0.9-9 daloradius

Move the file to the web server directory. In this case I use apache on Ubuntu so the location is at /var/www

# mv daloradius-0.9-9 daloradius
# mv daloradius /var/www

Then we need to setup the database. Because already setup the freeradius using MySQL, so we don't need new database. All we need to do is to import the daloradius scheme into our existing radius database.

# cd /var/www/daloradius/contrib/db
# mysql -u root -p radius < mysql-daloradius.sql

After database successfully altered, we need to configure the daloradius setting.

#vim /var/www/daloradius/library/daloradius.conf.php

Change the database password 

$configValues['CONFIG_DB_PASS'] = 'thepassword';

Then we can try to access daloradius using http://ipaddressoftheserver/daloradius

*Note: In my installation, i had a problem because I didn't have php5-gd php-pear and php-db packages installed on my Ubuntu server. 

To deal with this problem you can install the packages using

# apt-get install php5-gd php-pear php-db 



References, 

Mastaqim (2012), http://www.mastaqim.web.id/2012/08/install-freeradius-mysql-ubuntu-server.html
Daud (2012), http://daud.rasadigital.com/install-daloradius-di-ubuntu-server/


Server optimization for high traffic web systems using multiple retry and learning timeout patterns

Excerpt

A webpage typically will be as slow as the slowest request in the page. So if for a high traffic website like Yahoo! frontpage has lots of such possibly slow external apis, it could hold webserver processes and also effect user experience. Multiple Retry is a feature meant to optimize server resource utilization and efficiently use webserver processes/threads.

Description

Server optimization for high traffic web systems using multiple retry and learning timeout patterns.
Multiple Retry is a feature meant to optimize system resource utilization while still allowing a webpage to accommodate requests that might take a long time for the responses to come back. It uses two open source technologies Squid and Traffic Server (recently open sourced by Yahoo! under apache license).
The main principle behind it is to delegate the request to an offline proxy system such as SQUID to perform the actual request. This allows the initial request to use a very small timeout but yet the proxy system will continue to wait for the request to complete and then cache the response once it comes back. A subsequent request or ‘retry request’ is made to check the data in the proxy system cache instead of the actual source. The timed out request sends the squid key back to the client to track the availability of the resource quickly without going through the normal web server route.

How to set environment variables in Mac OS X Lion (For PHPunit purpose)

In my recent web application development, I need PHPUnit to run in my Macbook Pro Mac OS Lion X Lion. In my previous post I installed PHPUnit using PHP pear on XAMPP. 

Now I need to run it without evoking all the the path to the XAMPP bin files located at /Applications/XAMPP/xamppfiles/bin

So I need to set the environment variabel setting location in my Mac OS X Lion. We can do this with two easy steps.  

First: Open /etc/path files with terminal:

$ sudo vim /etc/path 

Second: Add /Applications/XAMPP/xamppfiles/bin to the bottom of the file. In my Mac, it look like this: 
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/Applications/XAMPP/xamppfiles/bin
~                                  

That's All

Installing PHPUnit on XAMPP Mac OS Lion


How to Install PHPUnit on XAMPP installed on Mac OS X Lion: 

First you need to add the phpunit channel: 

$ sudo /Applications/XAMPP/xamppfiles/bin/pear channel-discover pear.phpunit.de
Adding Channel "pear.phpunit.de" succeeded
Discovery of channel "pear.phpunit.de" succeeded

$ sudo /Applications/XAMPP/xamppfiles/bin/pear channel-discover pear.symfony-project.com
Adding Channel "pear.symfony-project.com" succeeded
Discovery of channel "pear.symfony-project.com" succeeded


Then Install Pear PHPUnit with the following command:
$ sudo /Applications/XAMPP/xamppfiles/bin/pear install phpunit/PHPUnitDid not download optional dependencies: phpunit/PHP_Invoker, use --alldeps to download automatically
phpunit/PHPUnit can optionally use package "phpunit/PHP_Invoker" (version >= 1.1.0)
downloading PHPUnit-3.6.10.tgz ...
Starting to download PHPUnit-3.6.10.tgz (118,595 bytes)
..........................done: 118,595 bytes
downloading YAML-1.0.6.tgz ...
Starting to download YAML-1.0.6.tgz (10,010 bytes)
...done: 10,010 bytes
install ok: channel://pear.symfony-project.com/YAML-1.0.6
install ok: channel://pear.phpunit.de/PHPUnit-3.6.10


References:
http://jeffreybarke.net/2010/08/how-to-install-phpunit-with-mamp/

Mengatasi Masalah Logon Message "The terminal server has exceeded the maximum number of allowed connections"


Seringkali ketika kita mengakses Microsoft Windows Server secara remote, tulisan "The terminal server has exceeded the maximum number of allowed connections" muncul. Sehingga kita tidak bisa mengakses komputer tersebut secara remote, ini situasi yang tidak mengenakkan bagi Administrator yang mengandalkan Remote Desktop Connection untuk mengakses servernya.

Sebenarnya pesan itu disebabkan karena server membatasi koneksi remote yang aktif. Apabila pada saat kita melakukan Remote Desktop dan mengakhirinya dengan hanya menekan tombol close, tanpa melakukan logout terlebih dahulu. Maka Windows akan mencatat bahwa masih ada user yang terkoneksi. Dan jumlah koneksi inipun dibatasi jumlahnya.

Walaupun pembatasan dilakukan pada sesi Remote Desktop, pada sesi console banyaknya user yang melakukan remote tidak dibatasi. Oleh karena itu kita bisa melakukan trik berikut ini apabila terjadi masalah.

Klik Windows -> Run

Kemudian ketikan mstsc /v:00.00.00.00 /f -console

Dimana 00.00.00.00 merupakan IP address dari komputer yang anda ingin remote.

Perintah ini akan menggunakan sesi console untuk masuk ke dalam komputer yang anda remote dan setelah itu anda dapat membuka Terminal Service Manager untuk mereset user yang "nyangkut" tadi.

Selamat Mencoba!


Referensi: