Pages

Unixbhaskar's Blog

Thursday, December 8, 2011

Using kvm on Arch Linux to install CentOS 6

This is mighty interesting and damn easy thing to do for better way to use and test new releases.I am gonna show you how you can exploit the power of KVM with minimal fuss.So here we go:

I am sitting on Arch Linux and got to bring in the kvm thing into the box..so I went ahead and do this :


bhaskar@ArchLinux_12:24:23_Thu Dec 08:~> sudo pacman -S qemu-kvm
resolving dependencies...
looking for inter-conflicts...

Targets (2): vde2-2.3.1-1 qemu-kvm-0.15.1-1

Total Download Size: 1.96 MB
Total Installed Size: 10.31 MB

Proceed with installation? [Y/n] y
:: Retrieving packages from extra...
vde2-2.3.1-1-i686 177.1K 58.0K/s 00:00:03 [#####################################################################] 100%
qemu-kvm-0.15.1-1-i686 1829.6K 62.8K/s 00:00:29 [#####################################################################] 100%
(2/2) checking package integrity [#####################################################################] 100%
(2/2) checking for file conflicts [#####################################################################] 100%
....
.....



Then I add myself to the kvm group like below:


bhaskar@ArchLinux_12:26:58_Thu Dec 08:~> sudo /usr/sbin/usermod -G kvm -a bhaskar

bhaskar@ArchLinux_12:27:12_Thu Dec 08:~> id bhaskar
uid=1000(bhaskar) gid=1000(bhaskar) groups=1000(bhaskar),92(audio),78(kvm)



Next, I modprobe two kernel module to integrate with the system like below:



bhaskar@ArchLinux_12:27:58_Thu Dec 08:~> sudo /sbin/modprobe kvm-intel

bhaskar@ArchLinux_12:28:10_Thu Dec 08:~> sudo /sbin/modprobe kvm



And the result shows like this :


bhaskar@ArchLinux_12:28:24_Thu Dec 08:~> sudo /bin/lsmod | grep kvm*
kvm_intel 116373 0
kvm 294406 1 kvm_intel



Then,the final step ,oh btw I have the ISO image of CentOS6 already downloaded in my system, so it easy to use...

So I went ahead like this to boot it from that ISO file by kvm:


bhaskar@ArchLinux_12:39:04_Thu Dec 08:~> qemu-kvm -enable-kvm -cdrom /home/bhaskar/Downloads/CentOS-6.0-i386-bin-DVD.iso


And here is how it look like the initial screen:



So ,pretty easy..huh..you can pass hell lot of option to that command line of qemu-kvm to fine tune you instances.

Hope this will help.

Cheers!
Bhaskar

Tuesday, December 6, 2011

How to get over Mutt's saga of "Unknown variables"

I have wrote an article about Mutt here . Now I have changed the system and trying to build it to different system and I am getting this errors:


bhaskar@GentooLinux_15:01:02_Tue Dec 06:~> mutt
Error in /home/bhaskar/.muttrc, line 12: imap_user: unknown variable
Error in /home/bhaskar/.muttrc, line 13: imap_pass: unknown variable
Error in /home/bhaskar/.muttrc, line 45: message_cachedir: unknown variable
Error in /home/bhaskar/.muttrc, line 58: smtp_url: unknown variable
Error in /home/bhaskar/.muttrc, line 59: smtp_pass: unknown variable
Error in /home/bhaskar/.muttrc, line 60: too few arguments



Pretty ordinary!! huh...no so..I was bemused for sometime then discover that when I pull in Mutt on Gentoo it failed to activate those flags and hence causing problem, here is the evidence of lacking those facilities:


bhaskar@GentooLinux_15:22:37_Tue Dec 06:~> mutt -v
Mutt 1.5.21 (2010-09-15, Gentoo 1.5.21-r1)
Copyright (C) 1996-2009 Michael R. Elkins and others.
Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.
Mutt is free software, and you are welcome to redistribute it
under certain conditions; type `mutt -vv' for details.

System: Linux 3.0.6-gentoo (i686)
ncurses: ncurses 5.9.20110404 (compiled with 5.9)
hcache backend: GDBM version 1.8.3. 10/15/2002 (built Aug 2 2011 22:18:59)
Compile options:
-DOMAIN
-DEBUG
+HOMESPOOL -USE_SETGID +USE_DOTLOCK +DL_STANDALONE -USE_FCNTL +USE_FLOCK
-USE_POP -USE_NNTP -USE_IMAP -USE_SMTP
-USE_SSL_OPENSSL -USE_SSL_GNUTLS -USE_SASL -USE_GSS -HAVE_GETADDRINFO
-HAVE_REGCOMP +USE_GNU_REGEX +COMPRESSED
+HAVE_COLOR +HAVE_START_COLOR +HAVE_TYPEAHEAD +HAVE_BKGDSET
+HAVE_CURS_SET +HAVE_META +HAVE_RESIZETERM
+CRYPT_BACKEND_CLASSIC_PGP -CRYPT_BACKEND_CLASSIC_SMIME -CRYPT_BACKEND_GPGME
-EXACT_ADDRESS -SUN_ATTACHMENT
+ENABLE_NLS -LOCALES_HACK +HAVE_WC_FUNCS +HAVE_LANGINFO_CODESET +HAVE_LANGINFO_YESEXPR
+HAVE_ICONV -ICONV_NONTRANS -HAVE_LIBIDN +HAVE_GETSID +USE_HCACHE
-ISPELL
SENDMAIL="/usr/sbin/sendmail"
MAILPATH="Maildir"
PKGDATADIR="/usr/share/mutt"
SYSCONFDIR="/etc/mutt"
EXECSHELL="/bin/sh"
MIXMASTER="mixmaster"
To contact the developers, please mail to .
To report a bug, please visit http://bugs.mutt.org/.

dgc.subjrx
fg.smarttime
vvv.initials
vvv.quote
vvv.nntp
patch-1.5.20hg.pdmef.progress.vl.2
rr.compressed
patch-1.5.4.lpr.collapse_flagged Lukas P. Ruf


The minus(-) prepended variables are not activated..so I need to activate them,which is causing trouble.

Now I need to reinstall mutt with all those enabled..so here we go :

First I have to set some use flags in /etc/portage/package.use/mutt.use file:


mail-client/mutt imap smtp pop gnutls mbox gpg smime sasl


And off I go to fetch Mutt one more time with those flags enable:


bhaskar@GentooLinux_15:35:56_Tue Dec 06:~> sudo emerge -av mutt

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild R ] mail-client/mutt-1.5.21-r1 USE="berkdb crypt gdbm gnutls* gpg* imap* mbox* nls pop* sasl* smime* smtp* ssl -debug -doc -idn -nntp -qdbm -sidebar -tokyocabinet" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB

Would you like to merge these packages? [Yes/No] y



Look at the asterix appended values,which is exactly I did mentioned in the mutt.use file.


Now I can access Mutt without problem :)

Hope this will help.

Cheers!
Bhaskar

Thursday, October 27, 2011

How to update/upgrade Slackware packages from command line

Yep that is the case.Basically you need to follow just two steps to do that. I am going to show you that.I am doing it on Slackware 13.37 version.But the basic remain the same.So here we go:

First and foremost update the existing one; if any pending issue are there ,then it will get resolve.



root@Slackware:~# slackpkg update


It will pop up a TUI and ask for package updation,need to select and press ok.Once that operation done.Go to the next step by doing so..


root@Slackware:~# slackpkg upgrade patches


At the end of this operation it will ask you like this :


Searching for NEW configuration files

Some packages had new configuration files installed.
You have four choices:

(K)eep the old files and consider .new files later

(O)verwrite all old files with the new ones. The
old files will be stored with the suffix .orig

(R)emove all .new files

(P)rompt K, O, R selection for every single file

What do you want (K/O/R/P)?



Now it's your call to take,whether you want to do it by hand or the package manager do it for you. I had little to do this specific upgrade so I went for interactive way; like this :


Select what you want file-by-file

/etc/uniconf.conf.new - (K)eep
(O)verwrite
(R)emove
(D)iff
(M)erge
o

/etc/httpd/httpd.conf.new - (K)eep
(O)verwrite
(R)emove
(D)iff
(M)erge
0 -------------------> my selection

/etc/gconf/2/path.new - (K)eep
(O)verwrite
(R)emove
(D)iff
(M)erge
o -----------------------> my selection

/etc/gconf/2/evoldap.conf.new - (K)eep
(O)verwrite
(R)emove
(D)iff
(M)erge
o ------------------> my selection



But for huge upgrade, you should fall back to package manager to do the job for you.Or you are curious(you should be!) then do it by hand, and it will take some amount of time.

Hope this will help.

Cheers!
Bhaskar

Monday, October 17, 2011

Running google-chrome browser on Scientific Linux

You feel the title looks ordinary..yes it is and it;s my lack of observation caused this hindrance.


The problem: As far as I am concerned SL not come with google-repository with it. So I went ahead and installed it like most of the RH system do.Yep, SL is a clone of RH system.

The repo looks like below:


bhaskar@Scientific-Linux_11:22:47_Mon Oct 17:~> sudo cat /etc/yum.repos.d/google.repo
[sudo] password for bhaskar:
[google]
name=Google - i386
baseurl=http://dl.google.com/linux/rpm/stable/i386
enabled=1
gpgcheck=0
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub


and


bhaskar@Scientific-Linux_12:06:07_Mon Oct 17:~> sudo cat /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/i386
enabled=1
gpgcheck=1


Then as usual do the following to install it:

bhaskar@Scientific-Linux_12:06:33_Mon Oct 17:~> sudo yum install google-chrome-stable
Loaded plugins: refresh-packagekit
Setting up Install Process
Package google-chrome-stable-14.0.835.202-103287.i386 already installed and latest version
Nothing to do


So what's the big deal???

If I clicked my google-chrome icon on panel and menu it won't respond!!! irk..So the as usual get into the terminal and paved into the google-chrome dir..and try to fire from the terminal gave me some library not recognizing error..which I resolve by this:


sudo yum install zlib-devel jzlib



Now ,still it's not opening up!! why? After bit of search(and my lack of interest to digg it in the system,which is bad) reveal that in this thread that it is a SELinux ,which prohibiting it from running. You can find the thread here: http://code.google.com/p/chromium/issues/detail?id=87704

Okay, then the obvious next step it correct the SELinux tag for google-sandbox,as mentioned in the thread...


bhaskar@Scientific-Linux_12:17:22_Mon Oct 17:~> sudo chcon -t usr_t /opt/google/chrome/chrome-sandbox


Voila! it is working fine now..what a real laziness can do..very bad of me ahh


Hope this will help.

Cheers!
Bhaskar

Saturday, August 20, 2011

How to make USB modem work on Arch Linux

I think this topic is an uncanny one..YMMV. Anyway I have done it hundred times before and thought to share it with people.Plug in the USB modem and think it just work in GNU/Linux laptop is not the case(tell me the exception if you have come across one!!).

It basically require few thing to be checked out in the box,which are mandatory for the USB modem to work..which are:

1) You need to figure out whether usbserial driver is loaded into the system or not.But how do you detect that?(kidding!! I know all of you know that). Still give away the steps to do that:

A) at the terminal,please type the following:

sudo /sbin/lsmod |grep usbserial


and you should get a response like below:


bhaskar@bhaskar-laptop_09:47:44_Sat Aug 20:~> sudo /bin/lsmod | grep usbserial
usbserial 26639 4
usbcore 119644 9 uas,ums_realtek,usb_storage,uvcvideo,btusb,usbserial,xhci_hcd,ehci_hcd



Now if you don't get a response from that command,that means kernel haven't load the driver to detect the USB thing.So you need to do the following:


sudo /sbin/modprobe usbserial


It basically get that driver initialize into the system to work with it.So the story is not end here..read on..

Step number 2:

It is essentially driven by the UDEV thing..so until you make the UDEV aware of it..it will still hinder you from using it.

So how do you do that?

Now you need to go to the directory called /etc/udev/rules.d..it should be there already and you need to add a udev rule file to in this dir like below:

ACTION!="add", GOTO="ZTE_End"

# Is this the ZeroCD device?
SUBSYSTEM=="usb", SYSFS{idProduct}=="2000",
SYSFS{idVendor}=="191g, GOTO="ZTE_ZeroCD"

# Is this the actual modem?
SUBSYSTEM=="usb", SYSFS{idProduct}=="0001",
SYSFS{idVendor}=="191g", GOTO="ZTE_Modem"

LABEL="ZTE_ZeroCD"
# This is the ZeroCD part of the card, remove
# the usb_storage kernel module so
# it does not get treated like a storage device
#RUN+="/sbin/rmmod usb_storage"

LABEL="ZTE_Modem"
# This is the Modem part of the card, let's
# load usbserial with the correct vendor
# and product ID's so we get our usb serial devices
RUN+="/sbin/modprobe usbserial vendor=0x191g product=0xffff",
# Make users belonging to the dialout group
# able to use the usb serial devices.
MODE="660", GROUP="dialout"

LABEL="ZTE_End"


I think the file is almost self explain itself.Now you need to restart the network one more time and put in your USB modem into the usb socket.

Then fire the command at the terminal..I am assuming you have wvdial installed in the system..



sudo wvdial providername

The USBmodem should able to ring back to the ISP; that you have already configured and provide you dynamic ip and dns names..voila!!!

You are connected to the internet through the wireless modem on GNU/Linux.To automate the thing in my laptop I have wrote a very very ordinary and mundane script to invoke from command line to get connected to the internet.The script look like below:


#!/bin/bash

if [[ "$UID" = "0" ]]

then

echo " You have the super power to invoke this sript"
else
echo "Sorry, you don't have the power to run this script"
fi



echo
echo
echo " Let's check whether the usb modem is connected to system or not"
echo
echo

/usr/sbin/lsusb | gawk -F: ' { print $2"===>"$3 }'

echo
echo

echo "probing the usb modem...loading driver too....."

/sbin/modprobe usbserial vendor=0x191g product=0xffff

echo
echo

echo "Connecting to ISP...."
echo
echo

/usr/bin/wvdial ProvidernameISP &>/var/log/wvdial&

echo
echo

sleep 5

echo "PID of of the WvDial..."

ps -ef | grep wvdial

echo
echo

sleep 3
echo
echo
echo "Checking the connection...."

/bin/ping -c 3 google.com

echo
echo

echo " Looking for live stat....."
echo
echo

/usr/bin/vnstat -i ppp0 -l



O yeah, I have written some information about vnstat in some other blog.It is a nice utility to measure net bandwidth.

Hope this will help.

Cheers!
Bhaskar

Monday, July 4, 2011

Running Funtoo,SUSE and Slackware through OpenVZ on Fedora 15

In this article I will show you how to run different distros within virtual container.Actually the problem is my machine processor doesn't support virtualization..irk!!! so apart from running different GNU/Linux distros in different physical partitions from several years, now the the time has come to run it seperate space within same OS.

So here we go...first thing first..we need a technology to enable that..and that technology is called OpenVZ . Right? Now I have recently stumble over an article published here and followed those instruction to make it possible for me.

I am running this experiment on Fedora 15 .

Step 1;

Get OpenVZ repo into your machine:

bhaskar@bhaskar-laptop_12:55:46_Mon Jul 04:/etc/yum.repos.d> sudo wget http://download.openvz.org/openvz.repo
[sudo] password for bhaskar:
--2011-07-04 12:56:05-- http://download.openvz.org/openvz.repo
Resolving download.openvz.org... 64.131.90.11
Connecting to download.openvz.org|64.131.90.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3841 (3.8K) [text/plain]
Saving to: “openvz.repo”

100%[===================================================================================================================>] 3,841 --.-K/s in 0.007s

2011-07-04 12:56:21 (503 KB/s) - “openvz.repo” saved [3841/3841]

Step 2:

Get the key for it:
bhaskar@bhaskar-laptop_12:56:21_Mon Jul 04:/etc/yum.repos.d> sudo rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ

Step 3:

Search for the specific kernel related to OpenVZ:

bhaskar@bhaskar-laptop_13:01:59_Mon Jul 04:/etc/yum.repos.d> sudo yum search vzkernel
Loaded plugins: langpacks, presto, refresh-packagekit
google | 951 B 00:00
google-chrome | 951 B 00:00
http://mirror.switch.ch/ftp/mirror/rpmfusion/free/fedora/development/source/SRPMS/repodata/repomd.xml: [Errno 14] curl#6 - "Couldn't resolve host"
Trying other mirror.
rpmfusion-free-rawhide-source | 2.7 kB 00:00
rpmfusion-free-rawhide-source/primary_db | 79 kB 00:04
rpmfusion-free-updates | 2.7 kB 00:00
updates/metalink | 7.4 kB 00:00
updates | 4.7 kB 00:00
updates/primary_db | 2.1 MB 00:20
openvz-kernel-rhel6 12/12
updates/pkgtags | 31 kB 00:00
=================================================================== N/S Matched: vzkernel ===================================================================
vzkernel.i686 : The Linux kernel
vzkernel-debug.i686 : The Linux kernel compiled with extra debugging enabled
vzkernel-debug-devel.i686 : Development package for building kernel modules to match the debug kernel
vzkernel-devel.i686 : Development package for building kernel modules to match the kernel
vzkernel-firmware.noarch : Firmware files used by the Linux kernel
vzkernel-headers.i686 : Header files for the Linux kernel for use by glibc

Name and summary matches only, use "search all" for everything.

Step 4:

Install the Kernel:

bhaskar@bhaskar-laptop_13:04:24_Mon Jul 04:/etc/yum.repos.d> sudo yum install vzkernel.i686
[sudo] password for bhaskar:
Loaded plugins: langpacks, presto, refresh-packagekit
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vzkernel.i686 0:2.6.32-042stab018.1 will be installed
--> Processing Dependency: virtual-vzkernel-install >= 2.0.0 for package: vzkernel-2.6.32-042stab018.1.i686
--> Running transaction check
---> Package vzctl.i386 0:3.0.28.3-1 will be installed
--> Processing Dependency: vzctl-lib = 3.0.28.3-1 for package: vzctl-3.0.28.3-1.i386
--> Processing Dependency: vzquota >= 2.7.0-4 for package: vzctl-3.0.28.3-1.i386
--> Processing Dependency: libvzctl-0.0.3.so for package: vzctl-3.0.28.3-1.i386
--> Running transaction check
---> Package vzctl-lib.i386 0:3.0.28.3-1 will be installed
---> Package vzquota.i386 0:3.0.12-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================
Installing:
vzkernel i686 2.6.32-042stab018.1 openvz-kernel-rhel6 23 M
Installing for dependencies:
vzctl i386 3.0.28.3-1 openvz-utils 162 k
vzctl-lib i386 3.0.28.3-1 openvz-utils 186 k
vzquota i386 3.0.12-1 openvz-utils 82 k

Transaction Summary
=============================================================================================================================================================
Install 4 Package(s)

Total download size: 23 M
Installed size: 83 M
Is this ok [y/N]:
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 23 M
(1/4): vzctl-3.0.28.3-1.i386.rpm | 162 kB 00:01
(2/4): vzctl-lib-3.0.28.3-1.i386.rpm | 186 kB 00:01
(3/4): vzkernel-2.6.32-042stab018.1.i686.rpm | 23 MB 00:58
(4/4): vzquota-3.0.12-1.i386.rpm | 82 kB 00:01
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 367 kB/s | 23 MB 01:05
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vzctl-lib-3.0.28.3-1.i386 1/4
Installing : vzquota-3.0.12-1.i386 2/4
Installing : vzctl-3.0.28.3-1.i386 3/4
Installing : vzkernel-2.6.32-042stab018.1.i686 4/4

Installed:
vzkernel.i686 0:2.6.32-042stab018.1

Dependency Installed:
vzctl.i386 0:3.0.28.3-1 vzctl-lib.i386 0:3.0.28.3-1 vzquota.i386 0:3.0.12-1

Complete!

Step 6:

The Grub entry:

title OpenVZ-2.6.32-042stab018.1
root (hd0,5)
kernel /vmlinuz-2.6.32-042stab018.1 ro root=UUID=a2298586-fab5-42a5-a84e-276f9565fb37 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us
initrd /initramfs-2.6.32-042stab018.1.img

Step 7:

Installing some openvz tools:

bhaskar@bhaskar-laptop_13:44:13_Mon Jul 04:~> sudo yum install vzctl vzquota
[sudo] password for bhaskar:
Loaded plugins: langpacks, presto, refresh-packagekit
Setting up Install Process
Package vzctl-3.0.28.3-1.i386 already installed and latest version
Package vzquota-3.0.12-1.i386 already installed and latest version
Nothing to do

It is saying so because I have already installed those.

Step 8:

Need to change some kernel parameter:

bhaskar@bhaskar-laptop_13:47:37_Mon Jul 04:~> sudo sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.all.rp_filter = 1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.default.forwarding = 1


Step 9:

Change some variable in vz.conf

vi /etc/vz/vz.conf

and put in

NEIGHBOUR_DEVS=all


Step 10:

Here is the file , where you can disable selinux

selinux disable
/etc/sysconfig/selinux

Step 11:

I am putting different ostemplate I have downloaded from here

And here it looks like :

cd /vz/template/cache/

the place to put different os template

I putting there funtoo,suse,slackware there

bhaskar@bhaskar-laptop_13:52:31_Mon Jul 04:/lvm> sudo mv -v suse-11.4-x86.tar.gz /vz/template/cache/
`suse-11.4-x86.tar.gz' -> `/vz/template/cache/suse-11.4-x86.tar.gz'
removed `suse-11.4-x86.tar.gz'

bhaskar@bhaskar-laptop_13:53:06_Mon Jul 04:/lvm> sudo mv -v slackware-13.37-i486-minimal.tar.gz /vz/template/cache/
`slackware-13.37-i486-minimal.tar.gz' -> `/vz/template/cache/slackware-13.37-i486-minimal.tar.gz'
removed `slackware-13.37-i486-minimal.tar.gz'

bhaskar@bhaskar-laptop_13:53:30_Mon Jul 04:/lvm> sudo mv -v funtoo-openvz-i686-funtoo-current-2011-05-26.tar.xz /vz/template/c
`funtoo-openvz-i686-funtoo-current-2011-05-26.tar.xz' -> `/vz/template/cache/funtoo-openvz-i686-funtoo-current-2011-05-26.tar.xz'
removed `funtoo-openvz-i686-funtoo-current-2011-05-26.tar.xz'

DO NOT UNTAR those files ever.


Step 12:


VPS implementation for SUSE:

bhaskar@bhaskar-laptop_14:05:59_Mon Jul 04:~> sudo vzctl create 101 --ostemplate suse-11.4-x86 --config basic
[sudo] password for bhaskar:
Creating container private area (suse-11.4-x86)
Performing postcreate actions
Saved parameters for CT 101
Container private area was created

Step 13:

Run at boot

bhaskar@bhaskar-laptop_14:08:54_Mon Jul 04:~> sudo vzctl set 101 --onboot yes --save
Saved parameters for CT 101


Step 14:

fix a hostname

bhaskar@bhaskar-laptop_14:10:01_Mon Jul 04:~> sudo vzctl set 101 --hostname SUSE --save
Saved parameters for CT 101

Step 15:

saving ip address

bhaskar@bhaskar-laptop_14:11:57_Mon Jul 04:~> sudo vzctl set 101 --ipadd 127.0.0.2 --save
Saved parameters for CT 101


Step 16:

save some socks

bhaskar@bhaskar-laptop_14:13:32_Mon Jul 04:~> sudo vzctl set 101 --numothersock 120 --save
Saved parameters for CT 101

Step 17:

Save Nameserver

vzctl set 101 --nameserver 8.8.8.8 --nameserver 8.8.4.4 --nameserver 145.253.2.75 --save

Step 18:
vz start and set root password

bhaskar@bhaskar-laptop_14:15:26_Mon Jul 04:~> sudo vzctl start 101
Starting container ...
Container is mounted
Adding IP address(es): 127.0.0.2 192.168.2.167
Setting CPU units: 1000
Set hostname: SUSE
File resolv.conf was modified
Container start in progress...
bhaskar@bhaskar-laptop_14:16:19_Mon Jul 04:~> sudo vzctl exec 101 passwd
New Password:
Bad password: too short
Reenter New Password: suse
Changing password for root.
Password changed.


Step 19:

Enter into one the vz..ie. suse

bhaskar@bhaskar-laptop_14:18:00_Mon Jul 04:~> sudo vzctl enter 101
entered into CT 101
SUSE:/ #


Step 20:
Slackware snapshot

bhaskar@bhaskar-laptop_14:31:54_Mon Jul 04:~> sudo vzctl enter 102
entered into CT 102
root@Slackware13:/# uname -a
Linux Slackware13 2.6.32-042stab018.1 #1 SMP Fri Jun 10 20:04:40 MSD 2011 i686 Intel(R) Core(TM)2 Duo CPU T5450 @ 1.66GHz GenuineIntel GNU/Linux
root@Slackware13:/# ls
bin/ boot/ dev/ etc/ fastboot home/ lib/ media/ mnt/ opt/ proc/ root/ sbin/ srv/ sys/ tmp/ usr/ var/

Step 21:

Inside Funtoo!!

bhaskar@bhaskar-laptop_14:41:38_Mon Jul 04:~> sudo vzctl start 103
Starting container ...
Container is mounted
Adding IP address(es): 192.168.2.118
Setting CPU units: 1000
Set hostname: Funtoo
File resolv.conf was modified
Container start in progress...
bhaskar@bhaskar-laptop_14:41:52_Mon Jul 04:~> sudo vzctl enter 103
entered into CT 103
Funtoo / # ls
bin boot dev etc fastboot home lib libexec mnt opt proc root sbin sys tmp usr var


Step 22:

Here is the vz list:

bhaskar@bhaskar-laptop_14:42:49_Mon Jul 04:~> sudo vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
101 16 running 192.168.2.167 SUSE
102 4 running 192.168.2.117 Slackware13
103 2 running 192.168.2.118 Funtoo


Hope this will help.

Cheers!
Bhaskar

Tuesday, May 10, 2011

Cacti implementation on CentOS AMI

In this article I will show you some graphing solution through RRD tool along with Cacti.I can tell you it require lot of work to get thing going with Cacti for graphing.

So here we go:

For cacti installation on RHEL or CentOS we need below package to be installed in the system:

httpd
php
php-mysql
php-snmp
php-ldap (when using LDAP authentication)
php-xml
mysql
mysql-server
net-snmp (depending on the distro, net-snmp-utils may be required)


Step 1:

Fetch cacti from cacti.net

[bhaskar@Amazon-instances ~]$ wget -c http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
-2011-04-29 02:18:20- http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
Resolving www.cacti.net... 140.211.167.231, 173.225.179.10, 209.242.232.5
Connecting to www.cacti.net... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2236916 (2.1M) [application/x-gzip]
Saving to: `cacti-0.8.7g.tar.gz'

100%[===================================================================================>] 2,236,916 1.34M/s in 1.6s

2011-04-29 02:18:22 (1.34 MB/s) - `cacti-0.8.7g.tar.gz' saved [2236916/2236916]


Step 2:

Get the required software in the box:

[bhaskar@Amazon-instances ~]$ sudo yum install httpd php php-mysql php-snmp php-xml mysql mysql-server net-snmp

addons | 951 B 00:00
base | 2.1 kB 00:00
centosplus | 1.9 kB 00:00
epel | 3.7 kB 00:00
epel/primary_db | 3.7 MB 00:00
extras | 2.1 kB 00:00
rightscale-epel | 951 B 00:00
rightscale-epel/primary | 34 kB 00:00
rightscale-epel 118/118
updates | 1.9 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.3-31.el5.centos.4 set to be updated
addons/filelists | 196 B 00:00
base/filelists_db | 3.9 MB 00:00
centosplus/filelists_db | 2.2 MB 00:00
epel/filelists_db | 5.2 MB 00:00
extras/filelists_db | 212 kB 00:00
rightscale-epel/filelists | 36 kB 00:00
updates/filelists_db | 2.9 MB 00:00
---> Package mysql.i386 0:5.0.77-4.el5_4.2 set to be updated
--> Processing Dependency: perl(DBI) for package: mysql
---> Package mysql.x86_64 0:5.0.77-4.el5_4.2 set to be updated
---> Package mysql-server.x86_64 0:5.0.77-4.el5_4.2 set to be updated
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server
---> Package net-snmp.x86_64 1:5.3.2.2-7.el5_4.2 set to be updated
--> Processing Dependency: net-snmp-libs = 1:5.3.2.2-7.el5_4.2 for package: net-snmp
--> Processing Dependency: libnetsnmpmibs.so.10()(64bit) for package: net-snmp
--> Processing Dependency: libnetsnmptrapd.so.10()(64bit) for package: net-snmp
--> Processing Dependency: libnetsnmpagent.so.10()(64bit) for package: net-snmp
--> Processing Dependency: libnetsnmp.so.10()(64bit) for package: net-snmp
--> Processing Dependency: libsensors.so.3()(64bit) for package: net-snmp
--> Processing Dependency: libnetsnmphelpers.so.10()(64bit) for package: net-snmp
---> Package php.x86_64 0:5.2.4-RightScale set to be updated
--> Processing Dependency: php-cli = 5.2.4-RightScale for package: php
--> Processing Dependency: php-common = 5.2.4-RightScale for package: php
---> Package php-mysql.x86_64 0:5.2.4-RightScale set to be updated
--> Processing Dependency: php-pdo for package: php-mysql
---> Package php-snmp.x86_64 0:5.2.4-RightScale set to be updated
---> Package php-xml.x86_64 0:5.2.4-RightScale set to be updated
--> Processing Dependency: libexslt.so.0()(64bit) for package: php-xml
--> Processing Dependency: libxslt.so.1()(64bit) for package: php-xml
--> Running transaction check
---> Package libxslt.x86_64 0:1.1.17-2.el5_2.2 set to be updated
---> Package lm_sensors.x86_64 0:2.10.7-4.el5 set to be updated
---> Package net-snmp-libs.x86_64 1:5.3.2.2-7.el5_4.2 set to be updated
---> Package perl-DBD-MySQL.x86_64 0:3.0007-2.el5 set to be updated
---> Package perl-DBI.x86_64 0:1.52-2.el5 set to be updated
---> Package php-cli.x86_64 0:5.2.4-RightScale set to be updated
---> Package php-common.x86_64 0:5.2.4-RightScale set to be updated
---> Package php-pdo.x86_64 0:5.2.4-RightScale set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================
Installing:
httpd x86_64 2.2.3-31.el5.centos.4 updates 1.2 M
mysql i386 5.0.77-4.el5_4.2 updates 4.8 M
mysql x86_64 5.0.77-4.el5_4.2 updates 4.8 M
mysql-server x86_64 5.0.77-4.el5_4.2 updates 9.8 M
net-snmp x86_64 1:5.3.2.2-7.el5_4.2 updates 701 k
php x86_64 5.2.4-RightScale rightscale-epel 3.9 M
php-mysql x86_64 5.2.4-RightScale rightscale-epel 277 k
php-snmp x86_64 5.2.4-RightScale rightscale-epel 44 k
php-xml x86_64 5.2.4-RightScale rightscale-epel 328 k
Installing for dependencies:
libxslt x86_64 1.1.17-2.el5_2.2 base 488 k
lm_sensors x86_64 2.10.7-4.el5 base 527 k
net-snmp-libs x86_64 1:5.3.2.2-7.el5_4.2 updates 1.3 M
perl-DBD-MySQL x86_64 3.0007-2.el5 base 148 k
perl-DBI x86_64 1.52-2.el5 base 600 k
php-cli x86_64 5.2.4-RightScale rightscale-epel 2.7 M
php-common x86_64 5.2.4-RightScale rightscale-epel 365 k
php-pdo x86_64 5.2.4-RightScale rightscale-epel 163 k

Transaction Summary
=============================================================================================================================
Install 17 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 32 M
Is this ok [y/N]:y

Downloading Packages:
(1/17): php-snmp-5.2.4-RightScale.x86_64.rpm | 44 kB 00:00
(2/17): perl-DBD-MySQL-3.0007-2.el5.x86_64.rpm | 148 kB 00:00
(3/17): php-pdo-5.2.4-RightScale.x86_64.rpm | 163 kB 00:00
(4/17): php-mysql-5.2.4-RightScale.x86_64.rpm | 277 kB 00:00
(5/17): php-xml-5.2.4-RightScale.x86_64.rpm | 328 kB 00:00
(6/17): php-common-5.2.4-RightScale.x86_64.rpm | 365 kB 00:00
(7/17): libxslt-1.1.17-2.el5_2.2.x86_64.rpm | 488 kB 00:00
(8/17): lm_sensors-2.10.7-4.el5.x86_64.rpm | 527 kB 00:00
(9/17): perl-DBI-1.52-2.el5.x86_64.rpm | 600 kB 00:00
(10/17): net-snmp-5.3.2.2-7.el5_4.2.x86_64.rpm | 701 kB 00:00
(11/17): httpd-2.2.3-31.el5.centos.4.x86_64.rpm | 1.2 MB 00:00
(12/17): net-snmp-libs-5.3.2.2-7.el5_4.2.x86_64.rpm | 1.3 MB 00:00
(13/17): php-cli-5.2.4-RightScale.x86_64.rpm | 2.7 MB 00:00
(14/17): php-5.2.4-RightScale.x86_64.rpm | 3.9 MB 00:00
(15/17): mysql-5.0.77-4.el5_4.2.i386.rpm | 4.8 MB 00:00
(16/17): mysql-5.0.77-4.el5_4.2.x86_64.rpm | 4.8 MB 00:00
(17/17): mysql-server-5.0.77-4.el5_4.2.x86_64.rpm | 9.8 MB 00:00
-----------------------------------------------------------------------------------------------------------------------------
Total 20 MB/s | 32 MB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php-common 1/17
Installing : perl-DBI 2/17
Installing : mysql 3/17
Installing : net-snmp-libs 4/17
Installing : perl-DBD-MySQL 5/17
Installing : php-cli 6/17
Installing : php-pdo 7/17
Installing : httpd 8/17
warning: /etc/rc.d/init.d/httpd saved as /etc/rc.d/init.d/httpd.rpmorig
Installing : lm_sensors 9/17
Installing : net-snmp 10/17
Installing : libxslt 11/17
Installing : mysql 12/17
Installing : php-mysql 13/17
Installing : php-xml 14/17
Installing : php 15/17
Installing : php-snmp 16/17
Installing : mysql-server 17/17

Installed:
httpd.x86_64 0:2.2.3-31.el5.centos.4 mysql.i386 0:5.0.77-4.el5_4.2 mysql.x86_64 0:5.0.77-4.el5_4.2
mysql-server.x86_64 0:5.0.77-4.el5_4.2 net-snmp.x86_64 1:5.3.2.2-7.el5_4.2 php.x86_64 0:5.2.4-RightScale
php-mysql.x86_64 0:5.2.4-RightScale php-snmp.x86_64 0:5.2.4-RightScale php-xml.x86_64 0:5.2.4-RightScale

Dependency Installed:
libxslt.x86_64 0:1.1.17-2.el5_2.2 lm_sensors.x86_64 0:2.10.7-4.el5 net-snmp-libs.x86_64 1:5.3.2.2-7.el5_4.2
perl-DBD-MySQL.x86_64 0:3.0007-2.el5 perl-DBI.x86_64 0:1.52-2.el5 php-cli.x86_64 0:5.2.4-RightScale
php-common.x86_64 0:5.2.4-RightScale php-pdo.x86_64 0:5.2.4-RightScale

Complete!

Step 3:
Now unzipping the tarball we downloaded from the cacti site:

[bhaskar@Amazon-instances ~]$ tar -xvzf cacti-0.8.7g.tar.gz

[bhaskar@Amazon-instances ~]$ ls
cacti-0.8.7g cacti-0.8.7g.tar.gz


Step 4:

Move the cacti dir to short and convinient name

[bhaskar@Amazon-instances ~]$ mv cacti-0.8.7g cacti

[bhaskar@Amazon-instances ~]$ ls
cacti cacti-0.8.7g.tar.gz


Step 5:

Now move the cacti dir to the document root of the system:

[bhaskar@Amazon-instances ~]$ sudo mv -v cacti /var/www/html/
`cacti' -> `/var/www/html/cacti'


Step 6:

Addming Cacti group and user in the box:

[bhaskar@Amazon-instances ~]$ sudo /usr/sbin/groupadd cacti

Adding users for cacti:

[bhaskar@Amazon-instances ~]$ sudo /usr/sbin/useradd -g cacti amazoncacti

Adding password to the user:

[bhaskar@Amazon-instances ~]$ sudo /usr/bin/passwd amazoncacti
Changing password for user amazoncacti.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.



Step 7:

Chnage the ownership of few dir in the cacti base dir:

[bhaskar@Amazon-instances cacti]$ sudo /bin/chown -R amazoncacti rra/ log/

[bhaskar@Amazon-instances cacti]$ ls -ld rra log
drwxr-xr-x 2 amazoncacti bhaskar 4096 Dec 30 2009 log
drwxr-xr-x 2 amazoncacti bhaskar 4096 May 16 2010 rra


Step 8:

MySql admin password creation:

[bhaskar@Amazon-instances cacti]$ sudo /usr/bin/mysqladmin -u root password somethingsensible

Step 9:

Create Cacti database for use:

[bhaskar@Amazon-instances cacti]$ sudo /usr/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)


Step 10:

Sourcing the default sql file into cacti database like below:

mysql> source cacti.sql

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec

output snipped for the sake of bravity!!!

Step 11:

Now time to grant some priviledge to the cacti user to get into the database and fetch thing from it. From the mysql shell do follow:

mysql> GRANT ALL ON cacti.* TO amazoncacti@localhost IDENTIFIED BY 'somethingsensible';
Query OK, 0 rows affected (0.00 sec)

Refreshing the grant table:

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


Step 12:

Now time for edit some files within cacti directory..

[bhaskar@Amazon-instances cacti]$ sudo vim include/config.php

Here it looks like inside... and I have change the database username and password entry in it:

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "amazoncacti";
$database_password = "somethingsensible";
$database_port = "3306";



Step 13:

I am creating a cron job to polls for the infomration:

[root@Amazon-instances cacti]# crontab -e

[root@Amazon-instances cacti]# crontab -l
*/5 * * * * amazoncacti /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1


Step 14:

Some php tweaking for the betterment:

[root@Amazon-instances cacti]# sudo vim /etc/php.ini

In this file I have changed memory_limit variable 32M to 128M

Step 15:

Now we need to got to the web interface of it,by pressing the following url into the browser:

http://Amazon-instances.amazonaws.com/cacti/

Step 16:

Snmpwalk not found by the cacti installer so go ahead and installed more binaries:

[root@Amazon-instances ~]# yum install net-snmp-utils net-snmp-devel
addons | 951 B 00:00
base | 2.1 kB 00:00
centosplus | 1.9 kB 00:00
epel | 3.7 kB 00:00
extras | 2.1 kB 00:00
rightscale-epel | 951 B 00:00
updates | 1.9 kB 00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package net-snmp-devel.i386 1:5.3.2.2-7.el5_4.2 set to be updated
--> Processing Dependency: libnetsnmpagent.so.10 for package: net-snmp-devel
--> Processing Dependency: libnetsnmptrapd.so.10 for package: net-snmp-devel
--> Processing Dependency: elfutils-devel for package: net-snmp-devel
--> Processing Dependency: elfutils-libelf-devel for package: net-snmp-devel
--> Processing Dependency: libnetsnmpmibs.so.10 for package: net-snmp-devel
--> Processing Dependency: libsnmp.so.10 for package: net-snmp-devel
--> Processing Dependency: libnetsnmphelpers.so.10 for package: net-snmp-devel
--> Processing Dependency: libnetsnmp.so.10 for package: net-snmp-devel
--> Processing Dependency: rpm-devel for package: net-snmp-devel
--> Processing Dependency: lm_sensors-devel for package: net-snmp-devel
--> Processing Dependency: beecrypt-devel for package: net-snmp-devel
---> Package net-snmp-devel.x86_64 1:5.3.2.2-7.el5_4.2 set to be updated
---> Package net-snmp-utils.x86_64 1:5.3.2.2-7.el5_4.2 set to be updated
--> Running transaction check
---> Package beecrypt-devel.x86_64 0:4.1.2-10.1.1 set to be updated
--> Processing Dependency: beecrypt = 4.1.2-10.1.1 for package: beecrypt-devel
--> Processing Dependency: libbeecrypt.so.6()(64bit) for package: beecrypt-devel
---> Package elfutils-devel.x86_64 0:0.137-3.el5 set to be updated
--> Processing Dependency: elfutils-devel-static-x86_64 = 0.137-3.el5 for package: elfutils-devel
---> Package elfutils-libelf-devel.x86_64 0:0.137-3.el5 set to be updated
--> Processing Dependency: elfutils-libelf-devel-static-x86_64 = 0.137-3.el5 for package: elfutils-libelf-devel
---> Package lm_sensors-devel.x86_64 0:2.10.7-4.el5 set to be updated
---> Package net-snmp-libs.i386 1:5.3.2.2-7.el5_4.2 set to be updated
---> Package rpm-devel.x86_64 0:4.4.2.3-18.el5 set to be updated
--> Processing Dependency: sqlite-devel for package: rpm-devel
--> Processing Dependency: libselinux-devel for package: rpm-devel
--> Processing Dependency: nss-devel for package: rpm-devel
--> Running transaction check
---> Package beecrypt.x86_64 0:4.1.2-10.1.1 set to be updated
---> Package elfutils-devel-static.x86_64 0:0.137-3.el5 set to be updated
---> Package elfutils-libelf-devel-static.x86_64 0:0.137-3.el5 set to be updated
---> Package libselinux-devel.x86_64 0:1.33.4-5.5.el5 set to be updated
--> Processing Dependency: libsepol-devel >= 1.15.2-1 for package: libselinux-devel
---> Package nss-devel.x86_64 0:3.12.6-1.el5.centos set to be updated
--> Processing Dependency: nspr-devel >= 4.8.4 for package: nss-devel
---> Package sqlite-devel.x86_64 0:3.3.6-5 set to be updated
--> Running transaction check
---> Package libsepol-devel.x86_64 0:1.15.2-2.el5 set to be updated
---> Package nspr-devel.x86_64 0:4.8.4-1.el5_4 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================
Installing:
net-snmp-devel i386 1:5.3.2.2-7.el5_4.2 updates 1.9 M
net-snmp-devel x86_64 1:5.3.2.2-7.el5_4.2 updates 2.0 M
net-snmp-utils x86_64 1:5.3.2.2-7.el5_4.2 updates 187 k
Installing for dependencies:
beecrypt x86_64 4.1.2-10.1.1 base 87 k
beecrypt-devel x86_64 4.1.2-10.1.1 base 118 k
elfutils-devel x86_64 0.137-3.el5 base 62 k
elfutils-devel-static x86_64 0.137-3.el5 base 119 k
elfutils-libelf-devel x86_64 0.137-3.el5 base 24 k
elfutils-libelf-devel-static x86_64 0.137-3.el5 base 64 k
libselinux-devel x86_64 1.33.4-5.5.el5 base 149 k
libsepol-devel x86_64 1.15.2-2.el5 base 192 k
lm_sensors-devel x86_64 2.10.7-4.el5 base 81 k
net-snmp-libs i386 1:5.3.2.2-7.el5_4.2 updates 1.3 M
nspr-devel x86_64 4.8.4-1.el5_4 updates 111 k
nss-devel x86_64 3.12.6-1.el5.centos updates 233 k
rpm-devel x86_64 4.4.2.3-18.el5 base 1.3 M
sqlite-devel x86_64 3.3.6-5 base 257 k

Transaction Summary
=============================================================================================================================
Install 17 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 8.0 M
Is this ok [y/N]:y

Downloading Packages:
(1/17): elfutils-libelf-devel-0.137-3.el5.x86_64.rpm | 24 kB 00:00
(2/17): elfutils-devel-0.137-3.el5.x86_64.rpm | 62 kB 00:00
(3/17): elfutils-libelf-devel-static-0.137-3.el5.x86_64.rpm | 64 kB 00:00
(4/17): lm_sensors-devel-2.10.7-4.el5.x86_64.rpm | 81 kB 00:00
(5/17): beecrypt-4.1.2-10.1.1.x86_64.rpm | 87 kB 00:00
(6/17): nspr-devel-4.8.4-1.el5_4.x86_64.rpm | 111 kB 00:00
(7/17): beecrypt-devel-4.1.2-10.1.1.x86_64.rpm | 118 kB 00:00
(8/17): elfutils-devel-static-0.137-3.el5.x86_64.rpm | 119 kB 00:00
(9/17): libselinux-devel-1.33.4-5.5.el5.x86_64.rpm | 149 kB 00:00
(10/17): net-snmp-utils-5.3.2.2-7.el5_4.2.x86_64.rpm | 187 kB 00:00
(11/17): libsepol-devel-1.15.2-2.el5.x86_64.rpm | 192 kB 00:00
(12/17): nss-devel-3.12.6-1.el5.centos.x86_64.rpm | 233 kB 00:00
(13/17): sqlite-devel-3.3.6-5.x86_64.rpm | 257 kB 00:00
(14/17): net-snmp-libs-5.3.2.2-7.el5_4.2.i386.rpm | 1.3 MB 00:00
(15/17): rpm-devel-4.4.2.3-18.el5.x86_64.rpm | 1.3 MB 00:00
(16/17): net-snmp-devel-5.3.2.2-7.el5_4.2.i386.rpm | 1.9 MB 00:00
(17/17): net-snmp-devel-5.3.2.2-7.el5_4.2.x86_64.rpm | 2.0 MB 00:00
-----------------------------------------------------------------------------------------------------------------------------
Total 10 MB/s | 8.0 MB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : beecrypt 1/17
Installing : net-snmp-libs 2/17
Installing : beecrypt-devel 3/17
Installing : lm_sensors-devel 4/17
Installing : sqlite-devel 5/17
Installing : libsepol-devel 6/17
Installing : libselinux-devel 7/17
Installing : nspr-devel 8/17
Installing : net-snmp-utils 9/17
Installing : nss-devel 10/17
Installing : elfutils-libelf-devel 11/17
Installing : rpm-devel 12/17
Installing : elfutils-devel 13/17
Installing : elfutils-libelf-devel-static 14/17
Installing : net-snmp-devel 15/17
Installing : net-snmp-devel 16/17
Installing : elfutils-devel-static 17/17

Installed:
net-snmp-devel.i386 1:5.3.2.2-7.el5_4.2 net-snmp-devel.x86_64 1:5.3.2.2-7.el5_4.2
net-snmp-utils.x86_64 1:5.3.2.2-7.el5_4.2

Dependency Installed:
beecrypt.x86_64 0:4.1.2-10.1.1 beecrypt-devel.x86_64 0:4.1.2-10.1.1
elfutils-devel.x86_64 0:0.137-3.el5 elfutils-devel-static.x86_64 0:0.137-3.el5
elfutils-libelf-devel.x86_64 0:0.137-3.el5 elfutils-libelf-devel-static.x86_64 0:0.137-3.el5
libselinux-devel.x86_64 0:1.33.4-5.5.el5 libsepol-devel.x86_64 0:1.15.2-2.el5
lm_sensors-devel.x86_64 0:2.10.7-4.el5 net-snmp-libs.i386 1:5.3.2.2-7.el5_4.2
nspr-devel.x86_64 0:4.8.4-1.el5_4 nss-devel.x86_64 0:3.12.6-1.el5.centos
rpm-devel.x86_64 0:4.4.2.3-18.el5 sqlite-devel.x86_64 0:3.3.6-5

Complete!

Step 16:

So once the web interface installed the thing we are presented the login page into with default admin/admin username/password .Now I have change that password to like below:

username : admin

password : admin

Step 17:

Adding amazoncacti user to apache group:

[bhaskar@Amazon-instances ~]$ sudo /usr/sbin/usermod -G apache -a amazoncacti
[bhaskar@Amazon-instances ~]$ id amazoncacti
uid=503(amazoncacti) gid=503(cacti) groups=48(apache),503(cacti)


Step 18:

Installing new crontab for user amazoncacti for run the poller.php

[root@Amazon-instances html]# sudo su - amazoncacti
[amazoncacti@Amazon-instances ~]$ crontab -e
no crontab for amazoncacti - using an empty one
crontab: installing new crontab


Step 19:

Checking snmp work on localhost

[bhaskar@Amazon-instances log]$ sudo snmpwalk -v 1 localhost -c public
SNMPv2-MIB::sysDescr.0 = STRING: Linux Amazon-instances 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:34:28 EST 2008 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (142712) 0:23:47.12
SNMPv2-MIB::sysContact.0 = STRING: Root
SNMPv2-MIB::sysName.0 = STRING: Amazon-instances
SNMPv2-MIB::sysLocation.0 = STRING: AmazonCloud
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.2 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.3 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.4 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.6 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.7 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.8 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.5 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORDescr.6 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.8 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (0) 0:00:00.00
HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (30377320) 3 days, 12:22:53.20
End of MIB


Step 20.

Newly created snmpd.conf

[bhaskar@Amazon-instances log]$ sudo cp -v /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.05022011
`/etc/snmp/snmpd.conf' -> `/etc/snmp/snmpd.conf.05022011'
[bhaskar@Amazon-instances log]$ sudo mv -v snmpd.conf /etc/snmp/
`snmpd.conf' -> `/etc/snmp/snmpd.conf'


Step 21:

plugin installation

[bhaskar@Amazon-instances ~]$ wget -c http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7g-PA-v2.8.tar.gz
-2011-05-04 02:52:11- http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7g-PA-v2.8.tar.gz
Resolving mirror.cactiusers.org... 209.189.228.150
Connecting to mirror.cactiusers.org|209.189.228.150|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 207069 (202K) [application/x-gzip]
Saving to: `cacti-plugin-0.8.7g-PA-v2.8.tar.gz'

100%[===================================================================================>] 207,069 583K/s in 0.3s

2011-05-04 02:52:12 (583 KB/s) - `cacti-plugin-0.8.7g-PA-v2.8.tar.gz' saved [207069/207069]


Step 22:

Untar it:

[bhaskar@Amazon-instances ~]$ tar -xvzf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
cacti-plugin-arch/
cacti-plugin-arch/files-0.8.7g/
cacti-plugin-arch/files-0.8.7g/poller.php
cacti-plugin-arch/files-0.8.7g/host.php
cacti-plugin-arch/files-0.8.7g/utilities.php
cacti-plugin-arch/files-0.8.7g/lib/
cacti-plugin-arch/files-0.8.7g/lib/poller.php
cacti-plugin-arch/files-0.8.7g/lib/functions.php
cacti-plugin-arch/files-0.8.7g/lib/html.php
cacti-plugin-arch/files-0.8.7g/lib/auth.php
cacti-plugin-arch/files-0.8.7g/lib/api_device.php
cacti-plugin-arch/files-0.8.7g/lib/rrd.php
cacti-plugin-arch/files-0.8.7g/lib/plugins.php
cacti-plugin-arch/files-0.8.7g/lib/variables.php
cacti-plugin-arch/files-0.8.7g/lib/html_form.php
cacti-plugin-arch/files-0.8.7g/graphs_new.php
cacti-plugin-arch/files-0.8.7g/graph.php
cacti-plugin-arch/files-0.8.7g/auth_changepassword.php
cacti-plugin-arch/files-0.8.7g/user_admin.php
cacti-plugin-arch/files-0.8.7g/plugins/
cacti-plugin-arch/files-0.8.7g/plugins/index.php
cacti-plugin-arch/files-0.8.7g/images/
cacti-plugin-arch/files-0.8.7g/images/install_icon_disabled.png
cacti-plugin-arch/files-0.8.7g/images/disable_icon.png
cacti-plugin-arch/files-0.8.7g/images/install_icon.png
cacti-plugin-arch/files-0.8.7g/images/view_none.gif
cacti-plugin-arch/files-0.8.7g/images/uninstall_icon.gif
cacti-plugin-arch/files-0.8.7g/images/enable_icon_disabled.png
cacti-plugin-arch/files-0.8.7g/images/enable_icon.png
cacti-plugin-arch/files-0.8.7g/graphs.php
cacti-plugin-arch/files-0.8.7g/include/
cacti-plugin-arch/files-0.8.7g/include/global.php
cacti-plugin-arch/files-0.8.7g/include/global_form.php
cacti-plugin-arch/files-0.8.7g/include/top_header.php
cacti-plugin-arch/files-0.8.7g/include/top_graph_header.php
cacti-plugin-arch/files-0.8.7g/include/global_settings.php
cacti-plugin-arch/files-0.8.7g/include/auth.php
cacti-plugin-arch/files-0.8.7g/include/bottom_footer.php
cacti-plugin-arch/files-0.8.7g/include/config.php.dist
cacti-plugin-arch/files-0.8.7g/include/plugins.php
cacti-plugin-arch/files-0.8.7g/include/global_constants.php
cacti-plugin-arch/files-0.8.7g/include/global_arrays.php
cacti-plugin-arch/files-0.8.7g/graph_image.php
cacti-plugin-arch/files-0.8.7g/plugins.php
cacti-plugin-arch/files-0.8.7g/data_sources.php
cacti-plugin-arch/files-0.8.7g/index.php
cacti-plugin-arch/files-0.8.7g/auth_login.php
cacti-plugin-arch/pa.sql
cacti-plugin-arch/README
cacti-plugin-arch/LICENSE
cacti-plugin-arch/cacti-plugin-0.8.7g-PA-v2.8.diff

Step 23:

Took back up before applying the patch for plug in architechture

sudo cp -Rpv /var/www/html/cacti/ /var/www/html/cacti.orig

Step 24:

Copying file from PIA to actual cacti installation dir

[bhaskar@Amazon-instances ~]$ cd cacti-plugin-arch/

[bhaskar@Amazon-instances cacti-plugin-arch]$ ls
cacti-plugin-0.8.7g-PA-v2.8.diff files-0.8.7g LICENSE pa.sql README

[bhaskar@Amazon-instances cacti-plugin-arch]$ cd files-0.8.7g/

[bhaskar@Amazon-instances files-0.8.7g]$ ls
auth_changepassword.php graph_image.php graphs.php include plugins user_admin.php
auth_login.php graph.php host.php index.php plugins.php utilities.php
data_sources.php graphs_new.php images lib poller.php
[bhaskar@Amazon-instances files-0.8.7g]$


[bhaskar@Amazon-instances files-0.8.7g]$ sudo cp -Rv * /var/www/html/cacti/
`auth_changepassword.php' -> `/var/www/html/cacti/auth_changepassword.php'
`auth_login.php' -> `/var/www/html/cacti/auth_login.php'
`data_sources.php' -> `/var/www/html/cacti/data_sources.php'
`graph_image.php' -> `/var/www/html/cacti/graph_image.php'
`graph.php' -> `/var/www/html/cacti/graph.php'
`graphs_new.php' -> `/var/www/html/cacti/graphs_new.php'
`graphs.php' -> `/var/www/html/cacti/graphs.php'
`host.php' -> `/var/www/html/cacti/host.php'
`images/install_icon_disabled.png' -> `/var/www/html/cacti/images/install_icon_disabled.png'
`images/enable_icon.png' -> `/var/www/html/cacti/images/enable_icon.png'
`images/enable_icon_disabled.png' -> `/var/www/html/cacti/images/enable_icon_disabled.png'
`images/view_none.gif' -> `/var/www/html/cacti/images/view_none.gif'
`images/install_icon.png' -> `/var/www/html/cacti/images/install_icon.png'
`images/disable_icon.png' -> `/var/www/html/cacti/images/disable_icon.png'
`images/uninstall_icon.gif' -> `/var/www/html/cacti/images/uninstall_icon.gif'
`include/plugins.php' -> `/var/www/html/cacti/include/plugins.php'
`include/global_form.php' -> `/var/www/html/cacti/include/global_form.php'
`include/top_graph_header.php' -> `/var/www/html/cacti/include/top_graph_header.php'
`include/global_arrays.php' -> `/var/www/html/cacti/include/global_arrays.php'
`include/config.php.dist' -> `/var/www/html/cacti/include/config.php.dist'
`include/top_header.php' -> `/var/www/html/cacti/include/top_header.php'
`include/global.php' -> `/var/www/html/cacti/include/global.php'
`include/global_constants.php' -> `/var/www/html/cacti/include/global_constants.php'
`include/auth.php' -> `/var/www/html/cacti/include/auth.php'
`include/global_settings.php' -> `/var/www/html/cacti/include/global_settings.php'
`include/bottom_footer.php' -> `/var/www/html/cacti/include/bottom_footer.php'
`index.php' -> `/var/www/html/cacti/index.php'
`lib/plugins.php' -> `/var/www/html/cacti/lib/plugins.php'
`lib/rrd.php' -> `/var/www/html/cacti/lib/rrd.php'
`lib/variables.php' -> `/var/www/html/cacti/lib/variables.php'
`lib/api_device.php' -> `/var/www/html/cacti/lib/api_device.php'
`lib/poller.php' -> `/var/www/html/cacti/lib/poller.php'
`lib/html.php' -> `/var/www/html/cacti/lib/html.php'
`lib/functions.php' -> `/var/www/html/cacti/lib/functions.php'
`lib/auth.php' -> `/var/www/html/cacti/lib/auth.php'
`lib/html_form.php' -> `/var/www/html/cacti/lib/html_form.php'
`plugins' -> `/var/www/html/cacti/plugins'
`plugins/index.php' -> `/var/www/html/cacti/plugins/index.php'
`plugins.php' -> `/var/www/html/cacti/plugins.php'
`poller.php' -> `/var/www/html/cacti/poller.php'
`user_admin.php' -> `/var/www/html/cacti/user_admin.php'
`utilities.php' -> `/var/www/html/cacti/utilities.php'

step 25:

9. permission need to be chaged

[bhaskar@Amazon-instances cacti]$ ls -al
total 1100
drwxr-xr-x 13 amazoncacti cacti 4096 May 4 03:00 .
drwxr-xr-x 4 root root 4096 May 4 02:56 ..
-rw-r-r- 1 amazoncacti cacti 6199 Jul 9 2010 about.php
-rw-r-r- 1 amazoncacti cacti 5187 May 4 03:00 auth_changepassword.php
-rw-r-r- 1 amazoncacti cacti 13396 May 4 03:00 auth_login.php
-rw-r-r- 1 amazoncacti cacti 176144 Jul 9 2010 cacti.sql
-rw-r-r- 1 amazoncacti cacti 21643 Jul 9 2010 cdef.php
drwxr-xr-x 2 amazoncacti cacti 4096 Jul 9 2010 cli
-rw-r-r- 1 amazoncacti cacti 19760 Jul 9 2010 cmd.php
-rw-r-r- 1 amazoncacti cacti 6974 Jul 9 2010 color.php
-rw-r-r- 1 amazoncacti cacti 25025 Jul 9 2010 data_input.php
-rw-r-r- 1 amazoncacti cacti 35455 Jul 9 2010 data_queries.php
-rw-r-r- 1 amazoncacti cacti 58617 May 4 03:00 data_sources.php
-rw-r-r- 1 amazoncacti cacti 32871 Jul 9 2010 data_templates.php
drwxr-xr-x 5 amazoncacti cacti 4096 Jul 9 2010 docs
-rw-r-r- 1 amazoncacti cacti 6107 Jul 9 2010 gprint_presets.php
-rw-r-r- 1 amazoncacti cacti 3492 May 4 03:00 graph_image.php
-rw-r-r- 1 amazoncacti cacti 12667 May 4 03:00 graph.php
-rw-r-r- 1 amazoncacti cacti 7805 Jul 9 2010 graph_settings.php
-rw-r-r- 1 amazoncacti cacti 17409 Jul 9 2010 graphs_items.php
-rw-r-r- 1 amazoncacti cacti 39908 May 4 03:00 graphs_new.php
-rw-r-r- 1 amazoncacti cacti 60077 May 4 03:00 graphs.php
-rw-r-r- 1 amazoncacti cacti 10006 Jul 9 2010 graph_templates_inputs.php
-rw-r-r- 1 amazoncacti cacti 18526 Jul 9 2010 graph_templates_items.php
-rw-r-r- 1 amazoncacti cacti 26606 Jul 9 2010 graph_templates.php
-rw-r-r- 1 amazoncacti cacti 38470 Jul 9 2010 graph_view.php
-rw-r-r- 1 amazoncacti cacti 5840 Jul 9 2010 graph_xport.php
-rw-r-r- 1 amazoncacti cacti 58003 May 4 03:00 host.php
-rw-r-r- 1 amazoncacti cacti 20016 Jul 9 2010 host_templates.php
drwxr-xr-x 2 amazoncacti cacti 4096 May 4 03:00 images
drwxr-xr-x 4 amazoncacti cacti 4096 May 4 03:00 include
-rw-r-r- 1 amazoncacti cacti 2313 May 4 03:00 index.php
drwxr-xr-x 2 amazoncacti cacti 4096 Jul 9 2010 install
drwxr-xr-x 3 amazoncacti cacti 4096 May 4 03:00 lib
-rw-r-r- 1 amazoncacti cacti 15141 Dec 30 2009 LICENSE
drwxr-xr-x 2 amazoncacti cacti 4096 May 2 02:53 log
-rw-r-r- 1 amazoncacti cacti 2641 Jul 9 2010 logout.php
drwxr-xr-x 2 amazoncacti cacti 4096 May 4 03:00 plugins
-rw-r-r- 1 amazoncacti cacti 25848 May 4 03:00 plugins.php
-rw-r-r- 1 amazoncacti cacti 4304 Jul 9 2010 poller_commands.php
-rw-r-r- 1 amazoncacti cacti 2243 Jul 9 2010 poller_export.php
-rw-r-r- 1 amazoncacti cacti 17909 May 4 03:00 poller.php
-rw-r-r- 1 amazoncacti cacti 48 Dec 30 2009 README
drwxr-xr-x 5 amazoncacti cacti 4096 Dec 30 2009 resource
drwxr-xr-x 2 amazoncacti cacti 4096 May 3 11:45 rra
-rw-r-r- 1 amazoncacti cacti 7233 Jul 9 2010 rra.php
drwxr-xr-x 2 amazoncacti cacti 4096 May 3 11:11 scripts
-rw-r-r- 1 amazoncacti cacti 8270 Jul 9 2010 script_server.php
-rw-r-r- 1 amazoncacti cacti 353 Dec 30 2009 script_server.pl
-rw-r-r- 1 amazoncacti cacti 4995 Jul 9 2010 settings.php
-rw-r-r- 1 amazoncacti cacti 6086 Jul 9 2010 templates_export.php
-rw-r-r- 1 amazoncacti cacti 6526 Jul 9 2010 templates_import.php
-rw-r-r- 1 amazoncacti cacti 19435 Jul 9 2010 tree.php
-rw-r-r- 1 amazoncacti cacti 44603 May 4 03:00 user_admin.php
-rw-r-r- 1 amazoncacti cacti 64999 May 4 03:00 utilities.php

Now should file below command:

[bhaskar@Amazon-instances cacti]$ sudo chown -R amazoncacti:cacti *
[bhaskar@Amazon-instances cacti]$ ls -al
total 1100
drwxr-xr-x 13 amazoncacti cacti 4096 May 4 03:00 .
drwxr-xr-x 4 root root 4096 May 4 02:56 ..
-rw-r-r- 1 amazoncacti cacti 6199 Jul 9 2010 about.php
-rw-r-r- 1 amazoncacti cacti 5187 May 4 03:00 auth_changepassword.php
-rw-r-r- 1 amazoncacti cacti 13396 May 4 03:00 auth_login.php
-rw-r-r- 1 amazoncacti cacti 176144 Jul 9 2010 cacti.sql
-rw-r-r- 1 amazoncacti cacti 21643 Jul 9 2010 cdef.php
drwxr-xr-x 2 amazoncacti cacti 4096 Jul 9 2010 cli
-rw-r-r- 1 amazoncacti cacti 19760 Jul 9 2010 cmd.php
-rw-r-r- 1 amazoncacti cacti 6974 Jul 9 2010 color.php
-rw-r-r- 1 amazoncacti cacti 25025 Jul 9 2010 data_input.php
-rw-r-r- 1 amazoncacti cacti 35455 Jul 9 2010 data_queries.php
-rw-r-r- 1 amazoncacti cacti 58617 May 4 03:00 data_sources.php
-rw-r-r- 1 amazoncacti cacti 32871 Jul 9 2010 data_templates.php
drwxr-xr-x 5 amazoncacti cacti 4096 Jul 9 2010 docs
-rw-r-r- 1 amazoncacti cacti 6107 Jul 9 2010 gprint_presets.php
-rw-r-r- 1 amazoncacti cacti 3492 May 4 03:00 graph_image.php
-rw-r-r- 1 amazoncacti cacti 12667 May 4 03:00 graph.php
-rw-r-r- 1 amazoncacti cacti 7805 Jul 9 2010 graph_settings.php
-rw-r-r- 1 amazoncacti cacti 17409 Jul 9 2010 graphs_items.php
-rw-r-r- 1 amazoncacti cacti 39908 May 4 03:00 graphs_new.php
-rw-r-r- 1 amazoncacti cacti 60077 May 4 03:00 graphs.php
-rw-r-r- 1 amazoncacti cacti 10006 Jul 9 2010 graph_templates_inputs.php
-rw-r-r- 1 amazoncacti cacti 18526 Jul 9 2010 graph_templates_items.php
-rw-r-r- 1 amazoncacti cacti 26606 Jul 9 2010 graph_templates.php
-rw-r-r- 1 amazoncacti cacti 38470 Jul 9 2010 graph_view.php
-rw-r-r- 1 amazoncacti cacti 5840 Jul 9 2010 graph_xport.php
-rw-r-r- 1 amazoncacti cacti 58003 May 4 03:00 host.php
-rw-r-r- 1 amazoncacti cacti 20016 Jul 9 2010 host_templates.php
drwxr-xr-x 2 amazoncacti cacti 4096 May 4 03:00 images
drwxr-xr-x 4 amazoncacti cacti 4096 May 4 03:00 include
-rw-r-r- 1 amazoncacti cacti 2313 May 4 03:00 index.php
drwxr-xr-x 2 amazoncacti cacti 4096 Jul 9 2010 install
drwxr-xr-x 3 amazoncacti cacti 4096 May 4 03:00 lib
-rw-r-r- 1 amazoncacti cacti 15141 Dec 30 2009 LICENSE
drwxr-xr-x 2 amazoncacti cacti 4096 May 2 02:53 log
-rw-r-r- 1 amazoncacti cacti 2641 Jul 9 2010 logout.php
drwxr-xr-x 2 amazoncacti cacti 4096 May 4 03:00 plugins
-rw-r-r- 1 amazoncacti cacti 25848 May 4 03:00 plugins.php
-rw-r-r- 1 amazoncacti cacti 4304 Jul 9 2010 poller_commands.php
-rw-r-r- 1 amazoncacti cacti 2243 Jul 9 2010 poller_export.php
-rw-r-r- 1 amazoncacti cacti 17909 May 4 03:00 poller.php
-rw-r-r- 1 amazoncacti cacti 48 Dec 30 2009 README
drwxr-xr-x 5 amazoncacti cacti 4096 Dec 30 2009 resource
drwxr-xr-x 2 amazoncacti cacti 4096 May 3 11:45 rra
-rw-r-r- 1 amazoncacti cacti 7233 Jul 9 2010 rra.php
drwxr-xr-x 2 amazoncacti cacti 4096 May 3 11:11 scripts
-rw-r-r- 1 amazoncacti cacti 8270 Jul 9 2010 script_server.php
-rw-r-r- 1 amazoncacti cacti 353 Dec 30 2009 script_server.pl
-rw-r-r- 1 amazoncacti cacti 4995 Jul 9 2010 settings.php
-rw-r-r- 1 amazoncacti cacti 6086 Jul 9 2010 templates_export.php
-rw-r-r- 1 amazoncacti cacti 6526 Jul 9 2010 templates_import.php
-rw-r-r- 1 amazoncacti cacti 19435 Jul 9 2010 tree.php
-rw-r-r- 1 amazoncacti cacti 44603 May 4 03:00 user_admin.php
-rw-r-r- 1 amazoncacti cacti 64999 May 4 03:00 utilities.php

Step 26:

patching the cacti installation dir for PIA

Upon dry run we get this:

[bhaskar@Amazon-instances cacti]$ sudo patch -p1 -N --dry-run < /home/bhaskar/cacti-plugin-arch/cacti-plugin-0.8.7g-PA-v2.8.diff
patching file auth_changepassword.php
patching file auth_login.php
Hunk #3 FAILED at 279.
1 out of 4 hunks FAILED -- saving rejects to file auth_login.php.rej
patching file data_sources.php
patching file graph_image.php
patching file graph.php
patching file graphs_new.php
patching file graphs.php
patching file host.php
patching file images/disable_icon.png
patching file images/enable_icon_disabled.png
patching file images/enable_icon.png
patching file images/install_icon_disabled.png
patching file images/install_icon.png
patching file images/uninstall_icon.gif
patching file images/view_none.gif
patching file include/auth.php
patching file include/bottom_footer.php
patching file include/config.php
Hunk #1 succeeded at 30 with fuzz 1.
patching file include/global_arrays.php
patching file include/global_constants.php
patching file include/global_form.php
patching file include/global.php
patching file include/global_settings.php
patching file include/plugins.php
patching file include/top_graph_header.php
patching file include/top_header.php
Hunk #1 FAILED at 22.
1 out of 4 hunks FAILED -- saving rejects to file include/top_header.php.rej
patching file index.php
patching file lib/api_device.php
patching file lib/auth.php
patching file lib/functions.php
patching file lib/html_form.php
patching file lib/html.php
patching file lib/plugins.php
patching file lib/poller.php
patching file lib/rrd.php
patching file lib/variables.php
patching file plugins/index.php
patching file plugins.php
patching file poller.php
patching file user_admin.php
patching file utilities.php

Step 26:

problem.....we need to get those two file from old location if we go ahed and do the patching

let's go:

[bhaskar@Amazon-instances cacti.orig]$ sudo cp -pv include/top_header.php /var/www/html/cacti/include/
`include/top_header.php' -> `/var/www/html/cacti/include/top_header.php'

[bhaskar@Amazon-instances cacti.orig]$ sudo cp -pv auth_login.php /var/www/html/cacti/
`auth_login.php' -> `/var/www/html/cacti/auth_login.php'


So failed patched files are copied back to modified dir.

Step 27:

Applying patched for PIA in the database

[bhaskar@Amazon-instances cacti-plugin-arch]$ sudo mysql -u amazoncacti -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1156
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cacti |
| test |
+--------------------+
3 rows in set (0.00 sec)

mysql> use cacti;
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> source pa.sql
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

mysql>


Step 28:

Downloading plug ins

[bhaskar@Amazon-instances ~]$ wget -c http://cactiusers.org/downloads/discovery.gzip
-2011-05-04 04:58:19- http://cactiusers.org/downloads/discovery.gzip
Resolving cactiusers.org... 209.189.228.151
Connecting to cactiusers.org|209.189.228.151|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://mirror.cactiusers.org/downloads/plugins/discovery-0.8.5.tar.gz [following]
-2011-05-04 04:58:21- http://mirror.cactiusers.org/downloads/plugins/discovery-0.8.5.tar.gz
Resolving mirror.cactiusers.org... 209.189.228.150
Connecting to mirror.cactiusers.org|209.189.228.150|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 30377 (30K) [application/x-gzip]
Saving to: `discovery-0.8.5.tar.gz'

100%[===================================================================================>] 30,377 --.-K/s in 0.1s

2011-05-04 04:58:21 (219 KB/s) - `discovery-0.8.5.tar.gz' saved [30377/30377]


Step 29:

Unzip it

[bhaskar@Amazon-instances ~]$ tar -xvzf discovery-0.8.5.tar.gz
discovery/README
discovery/index.php
discovery/discover.sql
discovery/setup.php
discovery/discover_template.php
discovery/findhosts.php
discovery/discover.php
discovery/images/index.php
discovery/images/tab_discover.gif
discovery/config.php
discovery/LICENSE

Step 30:

move the plug in dir to cacti's plugin dir

[bhaskar@Amazon-instances ~]$ sudo mv -v discovery /var/www/html/cacti/plugins/
`discovery' -> `/var/www/html/cacti/plugins/discovery'


Step 31:

Activate the plug in:

put a line like this in /var/www/html/cacti/include/config.php

$plugins[] = 'discovery';

### For every extra downloaded plug in we need to put up a line like this.

Now time for some graph..disk usage:




Here is another one memory usage:




Here one for the cpu usage;





Here something for eth0 and processes;





Hope this will help. Cacti is certainly not the easiest graphing solutions..but very cool to have one.

Cheers!
Bhaskar

Tuesday, April 19, 2011

Drush: A command line Drupal site manipulator

In this article I will touch a software called Drush, which essentially do the things like gems do for Ruby or easy_install does for python.

I have installed drupal and using this command line utility I will show you how you can get things going on drupal without going into the web interface.

So here we go:

I am assuming drush has been installed in the GNU/Linux box by you people already;if not get it installed.Say I need to know the status of php conf file and drush version ;here is how you can get it:



bhaskar@bhaskar-laptop_15:34:32_Tue Apr 19:~> sudo /usr/bin/drush status
[sudo] password for bhaskar:
PHP configuration : /etc/php5/cli/php.ini
Drush version : 3.3



Now if you want know the backend database information,then do



bhaskar@bhaskar-laptop_15:45:12_Tue Apr 19:/var/www/drupal> sudo /usr/bin/drush sql-conf
Array
(
[driver] => mysql
[username] => drupal
[port] =>
[host] => localhost
[database] => drupaldb
)




Right..cool ,now say you are curious to know modules comes with drupal about their status:



bhaskar@bhaskar-laptop_15:45:14_Tue Apr 19:/var/www/drupal> sudo /usr/bin/drush sm
Package Name Type Status Version
CCK Content (content) Module Enabled 6.x-2.9
CCK Content Copy (content_copy) Module Enabled 6.x-2.9
CCK Content Permissions (content_permissions) Module Enabled 6.x-2.9
CCK Fieldgroup (fieldgroup) Module Enabled 6.x-2.9
CCK Node Reference (nodereference) Module Enabled 6.x-2.9
CCK Number (number) Module Enabled 6.x-2.9
CCK Option Widgets (optionwidgets) Module Enabled 6.x-2.9
CCK Text (text) Module Enabled 6.x-2.9
CCK User Reference (userreference) Module Enabled 6.x-2.9
Core - optional Aggregator (aggregator) Module Enabled 6.20
Core - optional Blog (blog) Module Enabled 6.20
Core - optional Blog API (blogapi) Module Enabled 6.20
Core - optional Book (book) Module Not installed 6.20
Core - optional Color (color) Module Enabled 6.20
Core - optional Comment (comment) Module Enabled 6.20
Core - optional Contact (contact) Module Enabled 6.20
Core - optional Content translation (translation) Module Not installed 6.20
Core - optional Database logging (dblog) Module Enabled 6.20
Core - optional Forum (forum) Module Enabled 6.20
Core - optional Help (help) Module Enabled 6.20
Core - optional Locale (locale) Module Not installed 6.20
Core - optional Menu (menu) Module Enabled 6.20
Core - optional OpenID (openid) Module Enabled 6.20
Core - optional Path (path) Module Enabled 6.20
Core - optional PHP filter (php) Module Enabled 6.20
Core - optional Ping (ping) Module Enabled 6.20
Core - optional Poll (poll) Module Enabled 6.20
Core - optional Profile (profile) Module Enabled 6.20
Core - optional Search (search) Module Enabled 6.20
Core - optional Statistics (statistics) Module Enabled 6.20
Core - optional Syslog (syslog) Module Enabled 6.20
Core - optional Taxonomy (taxonomy) Module Enabled 6.20
Core - optional Throttle (throttle) Module Enabled 6.20
Core - optional Tracker (tracker) Module Enabled 6.20
Core - optional Trigger (trigger) Module Enabled 6.20
Core - optional Update status (update) Module Enabled 6.20
Core - optional Upload (upload) Module Enabled 6.20
Core - required Block (block) Module Enabled 6.20
Core - required Filter (filter) Module Enabled 6.20
Core - required Node (node) Module Enabled 6.20
Core - required System (system) Module Enabled 6.20
Core - required User (user) Module Enabled 6.20
Other Bluemarine (bluemarine) Theme Disabled 6.20
Other Chameleon (chameleon) Theme Disabled 6.20
Other Garland (garland) Theme Enabled 6.20
Other Marvin (marvin) Theme Disabled 6.20
Other Minnelli (minnelli) Theme Disabled 6.20
Other Pushbutton (pushbutton) Theme Disabled 6.20



Let's say you want to install some module right? Go ahead and install it like below:



bhaskar@bhaskar-laptop_15:48:23_Tue Apr 19:/var/www/drupal> sudo /usr/bin/drush dl diff
Project diff (6.x-2.1) downloaded to /var/www/drupal/sites/all/modules/diff. [success]



Here I have installed a module called "Diff",which basically do adds a tab for sufficiently permissioned users. The tab shows all revisions like standard Drupal but it also allows pretty viewing of all added/changed/deleted words between revisions.

But installing module will not sufficient, we need to activate or enable them, so you need to do like below:


bhaskar@bhaskar-laptop_15:51:41_Tue Apr 19:/var/www/drupal> sudo /usr/bin/drush en diff
The following projects will be enabled: diff
Do you really want to continue? (y/n): y
diff was enabled successfully. [ok]



Cool...isn't it!!! Now we are going to refresh the database from command line like below;



bhaskar@bhaskar-laptop_15:55:03_Tue Apr 19:/var/www/drupal> sudo /usr/bin/drush rf
Refreshing update status information ...
Done.



Last but not the least to run a cron related to drupal like below:



bhaskar@bhaskar-laptop_15:58:01_Tue Apr 19:/var/www/drupal> sudo /usr/bin/drush cron
Cron run successfully. [success]




Hope this will help.

Cheers!
Bhaskar