Wednesday, September 29, 2010

The ipcs Command

The ipcs command can be used to obtain the status of all System V IPC objects.

ipcs -q: Show only message queues

ipcs -s: Show only semaphores

ipcs -m: Show only shared memory

ipcs –help: Additional arguments

By default, all three categories of objects are shown. Consider the following sample output of ipcs:

—— Shared Memory Segments ——– shmid owner perms bytes nattch status

—— Semaphore Arrays ——– semid owner perms nsems status

—— Message Queues ——– msqid owner perms used-bytes messages 0 root 660 5 1

Here we see a single message queue which has an identifier of ``0''. It is owned by the user root, and has octal permissions of 660, or -rw-rw–. There is one message in the queue, and that message has a total size of 5 bytes.

The ipcs command is a very powerful tool which provides a peek into the kernel's storage mechanisms for IPC objects. Learn it, use it, revere it.

To remove objects below are the commands:

for i in `ipcs -m | grep zabbix | awk '{print $2}'`; do ipcrm -m $i; done → Shared Memory Segments

for i in `ipcs -s | grep zabbix | awk '{print $2}'`; do ipcrm -s $i; done → Semaphore Arrays

for i in `ipcs -q | grep zabbix | awk '{print $2}'`; do ipcrm -q $i; done → Message Queues

For Eg:

for i in `ipcs -m | grep zabbix | awk '{print $2}'`; do ipcrm -m $i; done

for i in `ipcs -s | grep zabbix | awk '{print $2}'`; do ipcrm -s $i; done

for i in `ipcs -q | grep zabbix | awk '{print $2}'`; do ipcrm -q $i; done

CentOS vs Ubuntu

Hi All

A few weeks ago, I had to setup a new production LAMP server to host a few of our client’s sites, medium size eCommerce websites. I wanted to share my experience as I came across the three big (and free) Linux distributions while I evaluated and setup the machines. I have previously setup Ubuntu Server 8.04 for our development and staging environment while researching the related family of North American Linux distributions: RedHat, Fedora and CentOS.

I’ll start with the positive: in the last few years Linux distributions in general have become main stream OS and most of the installation process is user friendly. Almost each distro offers the ’server’ edition of the OS which comes mostly configured with what a production LAMP server needs to have installed already. The installation packages are clearly labeled for i386 or x86_64 bit, and most even offer a net install which in CentOS case only requires downloading about 8.3MB of ISO file and the rest is done on the fly.

Now, let’s delve into the differences that affected my decisions, labeled according to key points and in order of importance to all of us:

Setup Efficiency: ROI(Return of Investment) and Learning Curve

I had the experience for setting up both Ubuntu server and CentOS server editions on two different machines. Both machines had similar configurations of two 250GB harddrives mirrored in software Raid1. The rest of the hardware setup is pretty much the standard Intel based processors. Both Ubuntu and CentOS had no problem in recognizing all the hardware on the machines and the setup process went pretty smoothly. The differences began showing after the initial setup: while CentOS shows an additional very helpful setup (NIC assignments, firewall, and services setup) Ubuntu had no such thing and showed the login prompt right after boot. What I found surprising is that Ubuntu required additional steps in order to download and install SSH using aptitude - if one chooses a server edition, shouldn’t it be setup for you by default?

Although aptitude is a great package management software, I have found that the server version of Ubuntu is just not mature enough or simply chooses the minimalistic approach which doesn’t it my understanding of a server distro. Many of the tasks that were performed by CentOS by default or had options for that during the install were missing in Ubuntu. At the end of the day, setting up Ubuntu took days while CentOS took hours. Did I say ROI? CentOS is the clear winner.

Package Management Systems

Ubuntu prides itself on apt-get and aptitude which builds itself on top of the debian package management system while CentOS, Fedora and RedHat, use the rpm and yum package management systems. After using all systems I can clearly say that I favor the yum and rpm package management systems.

First, with apt-get/apt-cache/aptitude I had to constantly refer back to the documentation on Ubuntu’s site and I still cannot remember which one do I use for searching, installing, upgrading, describing, or removing packages - do we really need the separation? With both yum and rpm simply provide a separate option and you are good to go, all the information is flowing into the terminal and it took me only one glance of ‘man yum’ to understand what and where.

Second, in the particular case of apache, vhosts, and extensinos, aptitude allows flexibility at the price of re-arranging the apache.conf and vhosts.conf into a collection of files and folders. Yum does a similar thing as well, however I still found yum’s method to keep the original httpd.conf mostly intact which allowed my familiarity with the basic apache configuration skill to take over and finalize install in no time. In my opinion, the deviation from the standard has no benefit whatsoever. The price of flexibility comes over familiarity but yet yum had the upper hand and ease of use.

Third, setting up a package that requires dependencies is equally good in both systems: they both do a very good job of finding the dependencies, looking their download sources, installing and setting it all up. However, I did find that yum had the best reporting system and after it gathered all the information it showed a useful status report while asking permission to proceed - this is valuable for sys admins and it does save time. Once more, yum feels like a more mature package management system.

Production OS? Stability vs Cutting Edge

Here is where I wanted to introduce a bit of the feeling after setting it up. At the end of the day, when all is setup and configured, the feeling from the CentOS system was much more secure and I knew exactly what is installed and what is not. Conversely, Ubuntu server did not give me that worm fuzzy feeling that ‘all is good’ and if I needed to make a change, I would have to refer to documentation first before I touch the server.

If we see in datacenter's Linux Admin who manage production linux clusters on a regular basis, they all point to CentOS or RedHat due to stability and performance record. In other words, you won’t get the latest cutting edge packages like Ubuntu or Fedora - but it is guaranteed to be much less flawed.

Conclusion

The bottom line is that distro preference is a personal decision. Personal to the individual who administers the systems and personal to the organization. We’ve chosen CentOS over Ubuntu, Fedora, and RedHat. The only option I see that might change is adopting RedHat due to the technical support that is offered for a fee. Hands down, CentOS provided the fastest configuration time, lowest learning curve, better ROI, superior package management system, and a good fuzzy feeling of stability.

Thanks to CentOS, we can get back to our main passion: Web Development…

Reliance Net Connect on Ubuntu 9.04 by using ZTE MG880 Modem (without wvdial)

Hi All

If you google around for configuring your reliance USB modem on ubuntu 9.04 then almost all links will lead to wvdial configuration. But there
is also another way of doing it with out touching wvdial is by using pppconfig.

To avoid confusion and errors please copy and paste commands.Here we go...

1. Firstly we will have to find out modem vendor id and product id. Use the following command to find it.

sudo lsusb -v

You can see output like this...
Bus 005 Device 007: ID 19d2:fffd
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.01
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 16
idVendor 0x19d2
idProduct 0xfffd
bcdDevice 0.00
iManufacturer 1 ZTE, Incorporated
iProduct 2 ZTE CDMA Tech
iSerial 3 Serial Number
........

Note down id Vendor and id Product some where.

2. Loading kernal module with vendor id and product id.

sudo gedit /boot/grub/grub.cfg --->> for Ubuntu 9.04

In the grub.cfg file add the following lines at the end of kernal line (Not in the next line)

usbserial.vendor=0x19d2 usbserial.product=0xfffd (Replace the the values with your's)

### BEGIN /etc/grub.d/10_linux ### set root=(hd0,3)
search --fs-uuid --set 126317bd-2dd9-4016-8e65-df85fda33a34
menuentry "Ubuntu, linux 2.6.28-11-generic" {
linux /boot/vmlinuz-2.6.28-11-generic root=UUID=126317bd-2dd9-4016-8e65-df85fda33a34 ro quiet splash usbserial.vendor=0x19d2 usbserial.product=0xfffd
initrd /boot/initrd.img-2.6.28-11-generic
}
menuentry "Ubuntu, linux 2.6.28-11-generic (single-user mode)" {
linux /boot/vmlinuz-2.6.28-11-generic root=UUID=126317bd-2dd9-4016-8e65-df85fda33a34 ro single
initrd /boot/initrd.img-2.6.28-11-generic
}

3. Reboot/Restart your computer.

4. Close all terminal. Open new terminal and type

sudo pppconfig

in the new (below) window select Create and give ok...

Type provider name (say reliance) and give ok

Select Dynamic and give ok

Select PAP and give ok

Enter your Reliance Number and give ok

Password is same as your Reliance Number, enter it and give ok

Do not change Modem Speed

Select Tone and give ok

Enter #777 and give ok

Enter yes

Select Manual and give ok

Give your modem port. In my (most of the) case it is /dev/ttyUSB0

Now all set. Ensure Everything is fine. Select Finished then ok

Finally in the last wind select Quit and give ok

Now you have configured your modem successfully and all set to connect.

5. To establish internet connection type the following command in terminal...

sudo pon reliance

6. Ensuring connection is established use this command...

ifconfig
Now you should see entry like this...
ppp0 Link encap:Point-to-Point Protocol
inet addr:123.239.41.80 P-t-P:220.224.134.12 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:3429 errors:23 dropped:0 overruns:0 frame:0
TX packets:3683 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:2309338 (2.3 MB) TX bytes:731534 (731.5 KB)

Once the connection is established you can close the terminal.

7. To disconnect...

sudo poff reliance

Extra
In case if you want to monitor internet speed then install pppstatus package (sudo apt-get install pppstatus) and type sudo pppstatus in the terminal.

That's all I have to do get Internet running on my laptop