Category: Software

  • psmisc 22.13, gjay 0.3.1-2 and son 2.0

    Two updates for Debian today.

    I’m the upstream for psmisc and 22.13 finally got released, which also meant 22.13-1 Debian package got released too. There was some delay to it (see below why) but it is now out.  Unless you run a mips or superH architecture, there is not really any exciting changes, but should make it compile for those two architectures and then at least get the mips buildd underway so the versions all line up.

    Secondly, gjay had two minor bug fixes and was updated.  If the analysis daemon kept playing music instead of looking at it or the vorbis files were not being recognised, then this new version will help there.  The mpg123 command line patch will be rolled into the upstream too.

    I’m also working on getting gjay to work with the Exaile player.  If you want it to work with your player the easiest thing is to send me patches or code snippets that do the following:

    • Detect your player is running
    • Can give me the currently played song, preferably the filename of it. Exaile doesn’t so I’ll put it a kludge to guess it from title and artist
    • Remotely send a playlist to your player and get the player to start

    Last of all, my second son was born last week. It’s back to those night feeds again and is probably why I’ve not written as much code as I normally would; but I wouldn’t change that either.

  • Manually calculating process times

    Most of the time you can trust the times you see in programs such as ps and top within Linux, but there are those other times where you just want to check what is going on.

    First up, if you’re using a FreeBSD system and the procps Linux tools, you’re out of luck because a lot of the procfs is broken.  You’re almost guaranteed to get wierd results.

    Jiffies and Hertz
    The first thing to find is your jiffies.  This is the number of clock ticks per second.  There are two main ways of doing it.

    The first, and more difficult way is to add up the cpu numbers in /proc/stat, divide it by the first number in /proc/uptime and divide it by the number of cpus.

    My cpu line in /proc/stat looks like:

    cpu  1267430 145826 552700 137029699 905086 8295 17885 0 0

    and my /proc/uptime is:

    695317.99 1370303.58

    I’ve got 2 cpus on this system so the calculation is:

    (1267430  + 145826 + 552700 + 137029699 + 905086 + 8295  + 17885 + 0 + 0 )  / 695317.99 / 2

    which equals 100.

    The second way is to use getconf, with the command “getconf CLK_TCK” which again on this system gives you 100.

    We call this value “Hertz” and is usually 100 or 1024 though for some architectures it is other values.

    Start Time
    For each process the procfs has the start time, but it is expressed as the number of jiffes since the computer was booted.  If we want to know the real “wall clock” time a process is started we have to start with number of seconds since epoch (for example using the time() function) subtract the number of seconds since the computer was booted and add the process start time from procfs.

    The seconds since boot is the first value in /proc/uptime:

    696141.85 1371857.53

    The 22nd item in a procfs PID stat file is the number of jiffes since boot when the process started. We have to divide it by Hertz to calculate the number of seconds.
    27139 (bash) S 11942 27139 27139 34821 5200 4202496 5500 25537 0 14 40 16 18 15 20 0 1 0 69446639 23433216 1378 18446744073709551615 4194304 5082140 14073724008 6512 140737240085456 140127945249678 0 65536 3686404 1266761467 0 0 0 17 1 0 0 0 0 0

    To get the start time, take the current time, subtract the boot time and add the process start time.

    perl -e ‘$nowstr = localtime(time() – 696141.85 + 69446639 / 100); print $nowstr, “n”;

    Mon Jul 12 22:20:07 2010

    Unless you are very quick, you will have to take a few seconds off because the time() function will be now, while the values from the proc files will be a few seconds earlier as it takes time for you to cut and paste.

    1
  • Helping Free Software: Translations

    Well the latest version of PSmisc is almost finished, so I pushed the tar archive up to the spot for the translators, waiting for the updates before it gets released.

    It reminded me that perhaps a lot of people don’t know how their programs get translated. Perhaps there are some that could even contribute.  The nice thing about the translation systems is that you don’t need to know programming to help.

    PSmisc uses the translation project as its method.  The program itself uses gettext for the translation part which makes a single text file called a POT file.  A translator takes this text file and makes a po file, such as it.po for the Italian translation and then translates, which basically means editing the file, reading each first line of a set and writing the translation on the second line.

    For the programmer, once it is setup it is pretty simple to use, just mark your translatable lines and follow some simple rules, mainly about not embedding too much in a string.  I’ve used this system for years for quite a few of my programs and there is little added work for me.

    Unfortunately,  translating is hard work and should be a long-term commitment.  Having a look at the translation project’s Translation Matrix and you can see that some languages do suffer, though there are some very good results there too.  Particular kudos goes to the Vietnamese group which I think is just Clytie who does a marvellous job and is often the first translation file I get.

    For the Debian project, there are many places where translations can occur.  There doesn’t seem to be a centralised place for this, but some of the places they use translation work are:

  • Does your program use gethostbyname() ?

    There has been some discussion on the Debian IPv6 list about how the function gethostbyname() has changed.  The manual page says this function is obsolete and with good reason.

    A new feature of the function is that if a hostname has both IPv4 and IPv6 entries then the order of the return values is not predefined.  In fact it used to be you’d get the IPv4 addresses first, then the IPv6.  That has now changed and with the more recent glibc you will get an IPv6 address first.  Quite often old code doesn’t even check the address family or the size of address structure but just copies the relevant 4 bytes.  You then get the first part of an 16-byte IPv6 address wedged into a 4-byte IPv4 address structure which basically means you get a mess.

    The fix is pretty simple by changing the system call from gethostbyname() and using getaddrinfo() instead.  If you only want the IPv4 addresses, perhaps because other parts of the code have not been checked or changed, then set the hints variable to return only IPv4 addresses.

    If one of your packages is starting to play up and unable to connect to certain remote places and is instead trying to get to some “random” address, have a quick check for gethostbyname(). A quick grep across the source code may save a lot of debugging time.

     

  • JFFNMS 0.8.5 released

    After my usual battle with PHP and database exports, jffnms 0.8.5 is now released. This program is a network management system written in PHP.  The worst part about the whole maintaining process for it would have to be is the release.

    Why is it so difficult to track changes within a database and PHP code? You don’t get that nice compile-time versus run-time error problems and the database is just diabolical to keep up to date with what you have changed.  Someone needs to invent a git for database states!

    Looking around other PHP based programs, I don’t think anyone else has solved this issue. Well, its out there, enjoy it or not and if you have comments about the program let me know.

  • VMware at last

    Well I suppose its a bit heretical running something such as VMware, but its an important piece of software at my workplace, it also allows me to run some important VMKs or modules.  But at first it just wouldn’t compile.

    And then I found this wonderful blog about Installing VMware on Ubuntu and it worked wonderfully. The author patched the code and it all installed nicely.

    The next problem was one of the services would not start. Port 8308 would refuse to work and when I went to the management screen and said Service Unavailable.  I tracked this down to the Java program dying at socket binding time.

    The absolute first thing you should check if you are having TCP/IP problems with Java is the sysctl path net.ipv6.bindv6only which you can check with
    sysctl net.ipv6.bindv6only.

    If it is 1, it might mean bad Java code network problems. And in fact this time it was the problem, changing it to 0 and the Java daemon started and stayed running and all was good.

    Incidently if you use the Cisco ASA firewall Java client and it dies, use this trick for it too.  On Debian systems, edit the file /etc/sysctl.d/bindv6only and set that option to 0.  I don’t think its the fault of the key, but bad Java code (but is there anything but bad Java code?)

  • dh-make updated to 0.52 and its remaining bugs

    I’ve made a quick release of dh-make, now up to 0.52.  Besides a minor dh_make.1 manual page fix this release will put the right value in the debian/source/format file.  0.51 will make it a native source package no matter what flags you use.

    If you get weird lintian errors about native source formats and version numbers wrong on your brand-new Debian package you just made, you might of been bitten by this bug.

    That leaves a few bugs left, there are two I need help with:

    • Bug 328692 – If you have a plan ASCII name like me, then your name looks fine in the dh-make generated man pages. This bug requires converting names that aren’t plain ASCII (e.g. that use UTF-8) into something groff understands. Someone suggested decomposed unicode but unicode and groff are pretty much a black art to me, let alone combining them.
    • Bug 533117 – This one is all about making dh-make make your python packages.  You’ll need to understand the new debhelper v7 rules files.  Again, python is not something I use so the bug is stuck here.
  • Gjay Updated

    After a long time of testing and just plain other non-software writing stuff, I’m happy to announce Gjay 0.3.0 is released.  This is my first release of Chuck Groom’s code and hopefully it will work for you too.

    The Debian packages will be out shortly after some building and testing.  If you have a 64-bit computer it now works with 64 bits fine (ie on my amd64).

    It still needs some work, I’d like it to interact with more than audacious as the sound player. Also if you know how to in one of the sound libraries stream wav, ogg or mp3 files correctly I’d like to hear from you.  Currently gjay just uses the same old fork to mpg321 method, but idealy I’d like it to use the libraries directly.

  • procps: Third time lucky

    OK, ok, i got a chroot and pbuilder now. So that should, I hope stop any more FTBFS bugs about missing depdendencies.

    procps got uploaded that fixes some important bugs, but mainly they were small fiddly things. About the most significant enhancement was pmap now has a real working -x flag.  It looks a lot like some of the other pmap programs out there and shows the RSS and Dirty bytes per map. Let me know if its useful or not.

    However there still is 48 bugs in the package, so if you’re feeling game wander over to procps bug page and have a look around, but here are some more interesting ones, such as why would a process start time be earlier than the boot time? Bug 408879 has this problem

    Now, a nice can of worms is in a Linux system, what is free memory?  What should the “free” program report?  Currently free just reports what it sees in /proc, but in Bug 565518 should the slab count be taken out?  I certainly won’t be making any Debian-specific changes here as you could get different numbers depending on your distribution, or even worse the age of you Debian system.

    procps is also my first attempt at using git-buildpackage which I found very helpful. There was one problem with it and that is how it works with the quilt patch program. If the quilt patches are applied, git doesn’t know this and says all the files have changed. I know its how these two programs are supposed to work but its a little annoying.

  • Manilla, Git and Gjay

    Work doesn’t often send to me places as great as Manilla in the Philippines, but here I am.  It’s a reasonably modern place and to me feels more like America than Asia in so many ways, posssibly because of its history.  One thing is for sure, noone follows road rules here.  Red lights are a suggestion and a zebra crossing is just some painted lines that you do need to stop at.

    As for food, it’s not that different, in fact this sad lot is about what was different:

    • McSpaghetti – Was supposedly sugar coated spaghetti but actually was very tame, my son would of loved it.
    • Wow Steak from KFC – Neither Wow nor Steak, like a big chicken nugget with gravy and rice
    • Halo Halo – A dessert drink which was sugared or preserved fruit, milk and ice.

    Generally though the food has been pretty good but nothing I could get at home.

    Good news about Gjay, the previous maintainer said it was ok for SourceForge to hand over the control of the program to me so I’ve set it up in git and started working on it.  Most of the work was getting the code up-to-date to the later gtk APIs and making it work with audacious instead of xmms.  It’s almost ready for (re)initial release and there is even an ITP ready to go.

    Git is a rather interesting and new (for me at least) version control system.  I’ve been using cvs for more years than I’d care to think about and svn but while it is a bit different as you’d expect I haven’t had it get in my way.  In fact I’ve been so impressed with Git I have put a few other projects into it, mainly with the collab maintence Debian project for a few of my packages.