Archive for the ‘Open Source’ Category

Twittipy 0.2

Friday, September 19th, 2008

I’m on a very brief break and hacked on my Twitter notifier for a couple of minutes. To tell you the truth, a couple of bugs have been ironed out a week after I posted the first version. It has been working so well, I didn’t bother playing around with the code.

Twittipy now prompts for your username and password. If you want it to save to the config file, just uncomment some of the lines. I’m not comfortable with the password saved in a file and I haven’t thought of a way to encrypt them. By the way, Pidgin saves passwords in plain text too. The login prompt is old code from a wxPython experiment some time ago (and it ain’t pretty).

After you get authenticated, an icon will appear in your system tray. To exit Twittipy, right-click on the icon.

Download it here.

Install Wine 1.1.4 on Fedora 9 + Google Chrome Comments

Sunday, September 14th, 2008

I love Wine! No offense to the GIMP folks but I still use Photoshop 7 and when I found out that it now works out of the box with Wine, it gained my trust. Here’s how to install Wine 1.1.4 on Fedora 9.

  1. Check if you have wine installed.
    $ rpm -qa | grep wine
  2. Uninstall the old version.
    $ sudo yum -y remove wine
  3. Download the latest build from Koji. The following is the i386 build.
    $ wget http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/i386/wine-twain-1.1.4-1.fc9.i386.rpm \
    http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/i386/wine-capi-1.1.4-1.fc9.i386.rpm \
    http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/src/wine-1.1.4-1.fc9.src.rpm \
    http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/i386/wine-jack-1.1.4-1.fc9.i386.rpm \
    http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/i386/wine-nas-1.1.4-1.fc9.i386.rpm \
    http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/i386/wine-core-1.1.4-1.fc9.i386.rpm \
    http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/i386/wine-ldap-1.1.4-1.fc9.i386.rpm \
    http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/i386/wine-cms-1.1.4-1.fc9.i386.rpm \
    http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/i386/wine-cms-1.1.4-1.fc9.i386.rpm \
    http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/i386/wine-tools-1.1.4-1.fc9.i386.rpm \
    http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/i386/wine-desktop-1.1.4-1.fc9.i386.rpm \
    http://koji.fedoraproject.org/packages/wine/1.1.4/1.fc9/i386/wine-esd-1.1.4-1.fc9.i386.rpm
  4. Install the RPMs.
    $ sudo rpm -Uvh wine-*
  5. Confirm installation.
    $ rpm -qa | grep wine

I upgraded to the lastest version of Wine just to get Google Chrome running on Linux even if I already read that it’s slow and SSL support is absent. I followed this guide.

I almost got it running but it was really slow (see screenshot below). I also have V8 compiled but when I tried to play around with it, I didn’t know what to do even with the interactive console.

Screenshot

My invaluable thoughts on Chrome:

  • I think it’s great that it uses Webkit. Not really sure if it’s faster than Gecko but at least testing with Webkit is more fun now.
  • You can drag a tab in and out of the window. That’s cool but I couldn’t pin the window to stay on top.
  • The developer tools are almost as great as those provided by Firefox extensions (i.e. Firebug).

Pidgin: Invisible Buddies + Some Thinking

Friday, July 11th, 2008

Pidgin: Invisible Buddies

This is me amused with little things.

On a side-note, I think it’s about time to get a new laptop. It’s not that my current laptop needs more juice. It works just fine for my needs and brought me great fortune in the past 4 years from college requirements to enterprise software.

Fedora 7 just reached its end of life and I get this OCD that I have outdated software. With the urge to upgrade but no place to backup my files (strange, all of my drives are full), I think a new laptop is the answer.

An extra hard disk would be a lot cheaper but I’m weighing the extra convenience that I’ll get with a more modern laptop. For instance, if I had a newer wireless card with 802.11g (yes, my laptop is 802.11b!), I’ll be using drivers with WPA support and higher transfer rates. With a DVD combo drive (vs a CD-ROM drive), better RAM, graphics card, and processor, makes me convinced that it’s, err, about time.

I’ll be getting an HP/Compaq because all of our laptops at home that carry the same brand are still alive. Also, it won’t be anything fancy. Just a boring normal laptop and it won’t be a tablet like I wished before. The TX2000 and TX2500 are available locally though.

There will be one busy weekend soon.

Twittipy: A pynotify and pycurl experiment

Friday, June 27th, 2008

It’s been a drag since Twitter IM went down. I had a very brief “play” time the other night that gave birth to Twittipy. It’s a Twitter notifier written in python with pynotify and pycurl.

Running Twittipy

  1. Create a configuration file in your home directory (~/.twittipy)
  2. Set your Twitter username/email and password in the configuration file.
    Example:
    [general]
    username = johnsmith
    password = unhackable
  3. Make Twittipy executable
    $ chmod u+x twittipy.py
  4. Fire it up!
    $ ./twittipy.py &

Twittipy requires Python 2.5, pycurl and pynotify. If it complains of missing modules, you probably didn’t meet the requirements.

Roadmap

I did some googling and found other stuff to try that could improve Twittipy.

  • Port for other platforms (Windows with pywin32 and KDE via wxPython)
  • Icon at the notification area or system tray (via wxPython)
  • Encrypt or obfuscate password in config file and/or if password is not found in the config file, prompt and store in memory.
  • Make use of the other methods of the Twitter API.

Download it here. There are two more options in the config file, update_interval and last_update. The former defaults to 4 minutes and the latter to the current time.

I’m quite satisfied with it. The notifications of pynotify are less obtrusive than an IM message. There’s one noticeable quirk where a tweet repeats. We’ll fix that for the next release.

Comments are welcome and please check out tweetyPy as well (not mine but also an academic project).

Finch

Wednesday, June 11th, 2008

Pidgin kept crashing when I tried tunneling through a remote machine. After minutes of googling around, I found Finch, a command-line version of Pidgin! It used to be called Gaim-text. Really cool!

Finch

Insert to Asterisk’s Queue Log When a Member Is Called

Friday, April 4th, 2008

Asterisk’s queue_log can come in handy in many cases (queues in Asterisk can be called ACD). There are systems that go as far as depending solely on the queue_log to operate (including mine).

Every now and then requests requirements for a feature to tell if a call in the queue is being transferred to a queue member (an agent) comes up. I had a workaround that used an AGI script but it didn’t work all the time. I’ve been digging around the source code so that it’s inserted into queue_log instead. After three attempts of hacking one friggin’ line of C code, I finally did it. My sincerest apologies to my COMPRO1 and COMPRO2 professors.

You may get the patch for asterisk-1.4.19 over here.

P.S. I know that watching the queue_log isn’t much of a good idea. I only stole the concept and I wasn’t aware of AMI at that time. Migration plans are on the way.

myssh 0.2

Wednesday, January 2nd, 2008

Finally got the motivation to port this to Python. I don’t want to go through everything again so just read the original post. I also added myssh_print and myssh_flush. The former, if not provided with a label, prints all the profiles. The latter removes a profile.

Download (myssh_0_2.tar.gz 8.1K)

Plug: Asterisk Philippine Users’ Group (APUG)

Thursday, September 27th, 2007

APUG

For those interested in VoIP, Asterisk, IP-PBXs, and all that hyped technology, feel free to join the discussion at APUG. Shiny Asterisk logo by yours truly.

Asterisk is the world’s leading open source telephony engine and tool kit. Offering flexibility unheard of in the world of proprietary communications, Asterisk empowers developers and integrators to create advanced communication solutions…for free.

Newbies, developers, hardware vendors and trolls (gulp!) are very much welcome.

MySQL Woes

Tuesday, July 31st, 2007

I was having problems with slow queries last night and I noticed that MySQL, even with two other CPUs available, just stuck to one processor. I did a little googling and found out that MySQL is not that multi-threaded.

I’m currently working with about 70 instances, all versions, different configs and settings, different loads. (Sometimes more than 7000qps)

Basically, here are the facts:

MySQL relies on NTPL or PTHREADS to handle it’s concurrent processing, and this in itself is a design flaw. Real transactional databases use multiple processes and multiple threads within those processes. Using linux threads can push a small percentage of the load to other processors/cores but it’s not anywhere near what a real multi-process application can do

If you’re lucky, your top will have the “H” option which shows threads as fake separate processes. If you’ve got enough connections per second, you’ll see mysql throw off a few threads to a different processor, but your MPSTAT will show that only one of the cores is doing most of the work (based on interupts per second, which is more accurate than load average or any other variable in top) In fact, the majority of the load on the other cores comes from the operating system services (kjournald, syslogd, …)

MySQL was designed as a simple single-process database app that sits on the same server as php and apache, so if you’re running a typical LAMP blog site or zencart on one server, this is more than enough

If you install PostgreSQL, Oracle, Sybase, basically any real database application, you’ll see dramatic difference in how the workload is distributed. The CPU cores do about the same number of interupts per second

I’ve tested mysql on every platform, and the outcome is always the same. A Sun T2000 box with 32 cores, regardless of mysql config, thread library, or version, will show activity on only one core from MySQL (even with hundreds of open connections)

Anything more than a single core CPU is completely useless for a database server running mysql. If you want to spend money on what really matters, get a decent fiber storage array with a fast controller

The conclusion: If you want to leverage multiple CPUs on a server running nothing but a database application, don’t use MySQL. Otherwise get a single core pizzabox and a fast disk controller and you’re all set

If this is true, can I setup another instance of MySQL on the same machine and have it replicate?

I listened to the July 21st episode of FLOSS Weekly the other night and the topic was Postgresql. This is exactly what Josh Berkus was talking about. I should try playing with Postgresql again. Table partitioning sounds like a huge lifesaver and I could sure use the extra data types.

Google, on the other hand, uses MySQL in a couple of apps. They use a huge cluster of mid-range machines with large memory. I’m after utilizing the other available CPUs.

Links

How to Install Munin on CEntOS

Thursday, June 14th, 2007

Munin is a monitoring tool for servers. It uses RRDtool to log and graph data from your servers. The plugin API is very easy to grasp. Actually, I haven’t read the API documentation yet. I just looked at the output of the plugins and it looks easy to achieve. The data can be accessed through the web.

This guide will walk you through installing and configuring Munin on CEntOS 4.3/4.4 x86. The steps are pretty much the same for later releases of CEntOS, Red Hat, Fedora [Core] and/or Red Hat-based installations.

Munin works by polling your servers for the data hence two applications, Munin and Munin Node. The former periodically gathers data (cronned) and the latter serves the data to the former. Please refer to the following for our example configuration. You can make up a domain if you want Munin to group your servers similar to the live demo.

Munin “Graph Server” - alpha.sample.net (192.168.1.1)
A Munin Node - bravo.sample.net (192.168.1.2)

1. Installing and Configuring Munin

In this section, we set it up on alpha.sample.net

  1. Add the RPMforge repository.
    rpm -Uhv http://apt.sw.be/packages/rpmforge-release/rpmforge-release-0.3.6-1.el4.rf.i386.rpm
    This step is optional if your Linux distribution has the packages in its default repositories. For other versions and architectures, click here.
  2. Install munin.
    yum -y install munin

  3. Change the ownership of the Munin web docroot to munin.
    chown -R munin:munin /var/www/munin
  4. The default configuration file (in version 1.2.5-1) the value for the web docroot points to the wrong directory. Replace the value of htmldir from /var/www/html/munin to /var/www/munin at /etc/munin/munin.conf (line 7).
  5. Restart Apache and Cron
    service httpd restart && service crond restart
  6. You can check if it’s working through your browser (i.e. http://192.168.1.1/munin/). You will get a 404 (not found) if you don’t supply a trailing slash.

2. Add a Node

In this section, we will configure bravo.sample.net.

  1. Add the RPMforge repository (see 1.1).
  2. Install Munin Node.
    yum -y install munin-node
  3. Configure. Edit /etc/munin/munin-node.conf with your favorite text editor.
    • Allow the graph server (alpha.sample.net/192.168.1.1) to poll the node.
      allow ^192\.168\.1\.1$
    • If your server doesn’t report the correct hostname, add the following line
      host_name bravo.sample.net
    • If your servers have two interfaces and on the same LAN (e.g. one for Internet and another for LAN), you can configure the node to bind and listen on the local interface by changing the value of host (line 13) from * to the local IP of the node.
  4. Start munin-node and set to start on bootup.
    service munin-node start
    chkconfig munin-node on
  5. Edit Munin’s configuration on the graph server (/etc/munin/munin.conf).
    [bravo.sample.net]
    address 192.168.1.2
    use_node_name yes

Wait for at least 5 minutes for the new node to appear. You can also install the node on the graph server. The default node configuration will work out of the box.

3. Install/Activate Some Plugins

This section should familiarize you with the plugin installation routine. Plugins are installed in the nodes.

  • Apache
    1. Create a symbolic link to the Apache plugins (stored in /usr/share/munin/plugins) in the plugin folder.
      ln -s /usr/share/munin/plugins/apache_* /etc/munin/plugins/

    2. Enable server status reports. Add the following to Apache’s configuration file.
      ExtendedStatus On
      <Location /server-status>
      SetHandler server-status
      Order Deny,Allow
      Deny from all
      Allow from 127.0.0.1
      </Location>
    3. Restart Apache and the node
      service httpd restart && service munin-node restart
  • Asterisk
    1. Download the plugins for your Asterisk version from here.
    2. Extract them to /usr/share/munin/plugins.
    3. Make the files executable
      chmod 755 /usr/share/munin/plugins/asterisk_*

    4. Configure Asterisk Manager by adding/changing the following in /etc/asterisk/manager.conf
      [general]
      enabled = yes
      port = 5038

      [munin]
      secret = somepassword
      permit = 127.0.0.1 ;if this doesn’t work, use the local IP
      write = system,call,log,verbose,command,agent,user

    5. Add the following to the plugin configuration file in /etc/munin/plugin-conf.d/munin-node
      [asterisk_*]
      env.username munin
      env.secret somepassword
    6. Reload Asterisk’s configuration and restart the node.
      asterisk -rx reload >> /dev/null && service munin-node restart
  • MySQL
    1. Create a symbolic link to the MySQL plugins (stored in /usr/share/munin/plugins) in the plugin folder.
      ln -s /usr/share/munin/plugins/mysql_* /etc/munin/plugins/
    2. If your root user has a password (or want to use a different user), edit the plugin configuration file in /etc/munin/plugin-conf.d/munin-node and uncomment line 16 by removing the leading hash (#). Then change the parameters that will be used when mysqladmin is run.
    3. Restart the node
      service munin-node restart
  • MTR
    1. Make sure you have the latest version of MTR.
      yum -y install mtr && yum -y update mtr
    2. Download the plugin here (direct link)
    3. Extract to /usr/share/munin/plugins
    4. Make the file executable.
      chmod 755 /usr/share/munin/plugins/mtr100_
    5. Create a symbolic link to the plugin (stored in /usr/share/munin/plugins) in the plugin folder. Append the host that you want to query to the link of the name.
      ln -s /usr/share/munin/plugins/mtr100_ /etc/munin/plugins/mtr100_somehost.com
    6. To add another host to query, just create another symbolic link.
    7. Add the following to the plugin configuration file in /etc/munin/plugin-conf.d/munin-node
      [mtr100_*]
      timeout 60
    8. Restart the node
      service munin-node restart

4. Links