Tuesday, November 20, 2012

Unable to send email to own domain via GMail SMTP using Postfix

I've got Postfix setup on Ubuntu to send emails via GMail SMTP.  Somehow, it doesn't seem to recognize my domain's own users.  Postfix log as follows:


Nov 20 21:40:08 ubuntu postfix/qmgr[12418]: 1EA5A2040813: from=app@mydom.com, size=543, nrcpt=1 (queue active)
Nov 20 21:40:08 ubuntu postfix/local[8895]: 1EA5A2040813: to=app@mydom.com, relay=local, delay=0.14, delays=0.09/0/0/0.06, dsn=5.1.1, status=bounced (unknown user: "app")

The fix is really simple.  Remove or comment the following line in main.cf:

mydestination = $myhostname, $mydomain

Restart Postfix and you're ready to rock :)


Wednesday, October 31, 2012

Inconsistency detected by ld.so: dl-open.c

Cleaned my Ubuntu laptop with Ubuntu Tweak and was left with a weird error when using Chrome and Firefox.  Chrome stopped loading pages while Firefox crashed completely.  Found out the problem only after starting Firefox from the console.  Error string reported by FFX:

Inconsistency detected by ld.so: dl-open.c: 667: _dl_open: Assertion `_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT' failed!

Used strace on Firefox and obtained the following output:


open("/lib/x86_64-linux-gnu/tls/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/tls/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
open("/usr/lib/x86_64-linux-gnu/tls/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/tls/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=49152, ...}) = 0
open("/lib/tls/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/lib/tls/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls", 0x7fffdd0b6c00)        = -1 ENOENT (No such file or directory)
open("/lib/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64", 0x7fffdd0b6c00)     = -1 ENOENT (No such file or directory)
open("/lib/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/usr/lib/tls/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls", 0x7fffdd0b6c00)    = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/usr/lib/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=73728, ...}) = 0
munmap(0x7fde2d69b000, 121572)          = 0
writev(2, [{"Inconsistency detected by ld.so:"..., 33}, {"dl-open.c", 9}, {": ", 2}, {"667", 3}, {": ", 2}, {"_dl_open", 8}, {": ", 2}, {"Assertion `", 11}, {"_dl_debug_initialize (0, args.ns"..., 61}, {"' failed!\n", 10}], 10Inconsistency detected by ld.so: dl-open.c: 667: _dl_open: Assertion `_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT' failed!) = 141

libGL.so.1 is there but it just doesn't get recognized by ld.  After digging the web for a few hours, finally found the solution.  Re-install some packages:

sudo apt-get install --reinstall libgl1-mesa-glx:amd64 libgl1-mesa-glx:i386 libgl1-mesa-dri:amd64 libgl1-mesa-dri:i386

Haven't had such crazy stuff in Ubuntu for a while :)



Sunday, September 23, 2012

Formatting currency in Drupal Commerce

A project I've been involved in uses Drupal Commerce (DC) to manage currency and products.  Here's how to format "normal" values to be DC friendly.  Reason for doing so?  DC stores amount fields as INTEGER.  For instance, an amount of USD99 is stored as 9900 in the table.

There are several functions which you need to make this happen.

commerce_currency_decimal_to_amount(300, commerce_default_currency());

Thursday, August 2, 2012

Checking if Java/Solaris is 32 or 64 bit

To check if Solaris is 32 or 64 bit, use the following command:

$ isainfo -kv
64-bit sparcv9 kernel modules


To check if JRE in Solaris is 32 or 64 bit, use the following command:

$ java -d64 -version
execve(): No such fie or directory
Failed to start a 64-bit JVM process from a 32-bit JVM

Well, that's a complain :)

Tuesday, March 13, 2012

Controlling Mouse Speed in Ubuntu when System Settings Doesn't Cut It (aka xinput)

My laptop comes with a Targus cordless mouse which moves too fast even when both Accelleration and Sensitivity in Pointer Speed settings is set to the lowest in Ubuntu. 

There's another method to control input speed via the xinput command.

To begin, execute "xinput list" to obtain the list of inputs available:

mike@myhost:~$ xinput list
⎡ Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
⎜   ↳ SONiX Targus Soft-Touch Cordless Mouse      id=8    [slave  pointer  (2)]
⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
    ↳ Power Button                                id=6    [slave  keyboard (3)]
    ↳ Power Button                                id=7    [slave  keyboard (3)]
    ↳ Dell Dell USB Entry Keyboard                id=9    [slave  keyboard (3)]
    ↳ Dell WMI hotkeys                            id=10    [slave  keyboard (3)]

From the output above, it's quite obvious which input device we'll be working with (id=8 if you can't spot it).  Next, we'll move on to list down the device properties:

mike@myhost:~$ xinput list-props 8
Device 'SONiX Targus Soft-Touch Cordless Mouse':
        Device Enabled (143):   1
        Coordinate Transformation Matrix (145): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        Device Accel Profile (260):     0
        Device Accel Constant Deceleration (261):       1.000000
        Device Accel Adaptive Deceleration (262):       1.000000
        Device Accel Velocity Scaling (263):    10.000000
        Evdev Axis Inversion (264):     0, 0
        Evdev Axes Swap (266):  0
        Axis Labels (267):      "Rel X" (153), "Rel Y" (154)
        Button Labels (268):    "Button Left" (146), "Button Middle" (147), "Button Right" (148), "Button Wheel Up" (149), "Button Wheel Down" (150), "Button Horiz Wheel Left" (151), "Button Horiz Wheel Right" (152), "Button Side" (524), "Button Extra" (525), "Button Unknown" (259), "Button Unknown" (259), "Button Unknown" (259), "Button Unknown" (259)
        Evdev Middle Button Emulation (269):    0
        Evdev Middle Button Timeout (270):      50
        Evdev Wheel Emulation (271):    0
        Evdev Wheel Emulation Axes (272):       0, 0, 4, 5
        Evdev Wheel Emulation Inertia (273):    10
        Evdev Wheel Emulation Timeout (274):    200
        Evdev Wheel Emulation Button (275):     4
        Evdev Drag Lock Buttons (276):  0

To properly "decelerate" the mouse pointer, we'll need to play around with 2 properties:
  • Device Accel Constant Deceleration (261)
  • Device Accel Adaptive Deceleration (262)
To update a property value, use the "--set-prop" option like below:
mike@myhost:~$ xinput --set-prop 8 261 4
Note the values used:
  • 8: device id
  • 261: property id
  • 4: value of the property to be set
Setting both property value to 4 works for me; YMMV.

Have fun tweaking your input :)



Tuesday, February 21, 2012

Using Python minidom module for XML generation

Creating an XML document in Python using the minidom module is quite straightforward.  For simplicity sake, I'll base the code on Hadoop's XML config file.

import sys
from xml.dom.minidom import Document

doc = Document()

configuration = doc.createElement("configuration")

xsl = doc.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"configuration.xsl\"")

doc.appendChild(xsl)

prop = doc.createElement("property")

# START LOOP HERE
name = doc.createElement("name")
name_text = doc.createTextNode("my name")
name.appendChild(name_text)

prop.appendChild(name)

value = doc.createElement("value")
value_text = doc.createTextNode("my value")
value.appendChild(value_text)

prop.appendChild(value)
# END LOOP HERE

configuration.appendChild(prop)

doc.appendChild(configuration)

print doc.toprettyxml()

The output is as follows:

<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
    <property>
        <name>
            my name
        </name>
        <value>
            my value
        </value>
    </property>
</configuration>

Friday, February 17, 2012

Scrollback in GNU Screen

This has always evaded me: How do you do scroll up the screenbuffer when using screen?  Found the answer right here:

http://www.linuxscrew.com/2008/11/14/faq-how-to-scrollback-in-gnu-screen/

I've tried the Ctrl + A + [ method; but not Ctrl + Esc as I'm using Windows as my main machine and Ctrl + Esc can also be used as the Windows key.

Just hope I remember this :)

Thursday, February 16, 2012

Measuring network throughput with iperf

The iperf tool has been around for ages and yeah, I've been late to the game :)

To install iperf in Ubuntu, it's a simple apt-get away:
$ sudo apt-get install iperf
To run the test, you'll need 2 machines.  One to act as the server and the other as the client.  Start by starting the server:
$ iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
If there are no errors, we can then start the test by executing iperf in the client machine:
$ iperf -c server -t 10
------------------------------------------------------------
Client connecting to server, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.0.100 port 40913 connected with 192.168.0.101 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec    164 MBytes    138 Mbits/sec
The argument -t 10 states that we want the test to run for only 10 seconds. 

There are other options which you can play with like:

    -d ==> Do a bidirectional test simultaneously
    -u ==> use UDP rather than TCP
   
View the list of options by executing:
$ iperf --help
There's also a GUI wrapper written in Java for iperf available at http://code.google.com/p/xjperf/.  It offers a nice GUI which allows you to choose different options to run iperf with and also displays output from iperf in a nice graph: