Saturday, April 17, 2010

Resetting MySQL Root Password

This is what you can do to resetting your mysql root access in case you're forget it. I just copy and paste it from mysql official website. Use it wisely, guys :)

On any platform, you can set the new password using the mysql client (but this approach is less secure):
  1. Stop mysqld and restart it with the --skip-grant-tables option.
  2. Connect to the mysqld server with this command:

    shell> mysql
  3. Issue the following statements in the mysql client. Replace the password with the password that you want to use.

    mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass')
        ->                   WHERE User='root';
You should now be able to connect to MySQL as root using the new password.

Thursday, April 15, 2010

Building Cacti on Ubuntu Server 8.04 Hardy Heron

Although it seems difficult, after several trial and error on my Ubuntu Server 8.04 finally I can get my Cacti up and running :) I copy-paste from Cacti website installation document and editing several lines to suite Ubuntu. First of all, you need to install from repositories (including all dependencies):
- apache2
- php5
- php5-cli
- rrdtool
- snmp
- cacti sourse file from here, choose the latest version

Configure PHP
Please find the file /etc/php5/apache2/php.ini and make the following changes to it:
extension_dir = /etc/php.d
This will enable PHP to find more configuration directives in that very directory.

If you want to allow template importing, uncomment the following line:

file_uploads = On
 Activate the MySQL extension via /etc/php5/conf.d/mysql.ini
; Enable mysql extension module
Activate the SNMP extension via /etc/php5/conf.d/mysql.ini
; Enable snmp extension module

Configure the Webserver (Apache)
Please locate the PHP configuration file at /etc/apache2/httpd.conf
If using PHP 5, then add the following lines.
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
LoadModule php5_module modules/
# Cause the PHP interpreter to handle files with a .php extension.
AddHandler php5-script .php
AddType text/html .php
# Add index.php to the list of files that will be served as directory
# indexes.
DirectoryIndex index.php
Configure MySQL
Set a password for the root user
# mysqladmin --user=root password somepassword
# mysqladmin --user=root --password reload

Install and Configure Cacti
1. Extract the distribution tarball
# tar xzvf cacti-version.tar.gz

2. Create the MySQL database:
# mysqladmin --user=root create cacti

3. Import the default cacti database:

# mysql cacti < /path/to/cacti/cacti.sql

4. Optional: Create a MySQL username and password for Cacti.
# mysql --user=root mysql
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
mysql> flush privileges;

Edit /path/to/cacti/include/config.php and specify the database type, name, host, user and password for your Cacti configuration.
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";

Set the appropriate permissions on cacti's directories for graph/log generation. You should execute these commands from inside cacti's directory to change the permissions.
# chown -R cactiuser rra/ log/

(Enter a valid username for cactiuser, this user will also be used in the next step for data gathering)

Point your web browser to:


Log in the with a username/password of admin
. You will be required to change this password immediately. Make sure to fill in all of the path variables carefully and correctly on the following screen.

For Ubuntu Distro, I have found that crontab setting is a bit different. You must edit /etc/cron.d/cacti files in order the cron to be running (Usually we used crontab -e in any linux/unix to add cron job)

$ cat /etc/cron.d/cacti
*/5 * * * * root php /var/www/cacti/poller.php > /dev/null 2>&1 /var/log/cacti/poller-error.log

Monday, April 12, 2010

Using VMWare Workstation Port Forwarding

The scenario was setting up a Windows guest OS (with VMWare) on Ubuntu Server host, and allowing access to any services running on that Windows guest OS. At first, it is complicated to figure out how to do it. But, then, I realize that it is so simple, and only needs simple configuration.

One example is by allowing access to Windows remote desktop service. These are how to do it:

1. configure your Windows guest OS to use NAT for Network Adaptor settings (Used to share the host's IP address)

2. open the configuration file:
# vi /etc/vmware/vmnet8/nat/nat.conf
3. add this line:
# Forward Remote Desktop connections to Windows VM
3389 =
# Forward Remote Desktop connections to Windows VM
3389 =
4. restart VMware services
# sudo /etc/init.d/vmware restart
Then you can try to access remote desktop service on your Windows guest OS.

Friday, April 9, 2010

Ubuntu Apt Update With Cron-Apt On Ubuntu

I'm using cron-apt to do automatic apt update on my server. These are very simple steps on how to do it

1. Installing Cron-Apt from repository
# sudo apt-get install cron-apt
2. Edit config file
# sudo vi /etc/cron-apt/config
3. Make the cron-apt run on 8 am everyday
# sudo vi /etc/cron.d/cron-apt
0 8 * * * root test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt
Please notice that this cron-apt is not running apt-get upgrade. But I'd prefer that way, so I can examine the available updates and choose when to run it. You can execute it using this command:
# sudo apt-get dist-upgrade

Tuesday, April 6, 2010

Installing and Running Dynamips on PowerBook G4

This is how I manage to run Dynamips on my PowerBook G4, actually with a little confusion about the version I'm gonna use. It's because dynamips version I install only work with certain version of Dynagen.

  1. Install Macports; run the port -d selfupdate to rsync the archive.
  2. Install libpcap with port as well:
    # sudo port install libpcap
  3. Get the libelf source package, compile it with prefix into /usr/local
    # ./configure --prefix=/usr/local; make; sudo make install
  4. On Dynamips folder from where you unzipped the tarball:
    a. Edit Makefile to use the 'nojit' architecture

              # vi Makefile
                  PCAP_LIB=-L/opt/local/lib -lpcap

  5. Save the Makefile file, and do this:

              # make; sudo make install
Recently I just using the blog post above to install and using Dynamips with GNS3 in my MacBook Pro running Snow Leopard (Mac OS X 10.6.x).

Saturday, April 3, 2010

Interlude Of The Life

There's been an empty post for several month, it is due to many circumstances. One of them is that I decide to do so.. not write or post anything in my blog. But now it's time to start again. There's a lot to write. So, if you haven't read anything in my blog, start to do it.. or there would be a lot to catch :)