Friday Apr 03, 2009

Maybe I reinvented the wheel. Here's quick&dirty perl to convert 'truss -df' output. Unfortunately, this doesn't work if only "-d" is given. Here's how this works:

$ truss -df cat
Base time stamp:  1238745134.0279  [ Fri Apr  3 16:52:14 JST 2009 ]
16881:   0.0000 execve("/usr/bin/cat", 0xFFBFFDC4, 0xFFBFFDCC)  argc = 1
16881:   0.0051 resolvepath("/usr/lib/ld.so.1", "/lib/ld.so.1", 1023) = 12
16881:   0.0055 resolvepath("/usr/bin/cat", "/usr/bin/cat", 1023) = 12
16881:   0.0058 stat("/usr/bin/cat", 0xFFBFFBA0)                = 0
[...]

$ truss -d -f cat 2>&1 | ~kinoue/trusstimestamp.pl
Base time stamp:  1238745453.9931  [ Fri Apr  3 16:57:33 JST 2009 ]
16895:   16:57:33.9931  execve("/usr/bin/cat", 0xFFBFFDC4, 0xFFBFFDCC)  argc = 1
16895:   16:57:33.9996  resolvepath("/usr/lib/ld.so.1", "/lib/ld.so.1", 1023) = 12
16895:   16:57:34.0018  resolvepath("/usr/bin/cat", "/usr/bin/cat", 1023) = 12
16895:   16:57:34.0024  stat("/usr/bin/cat", 0xFFBFFBA0)                = 0
[...]

I hope this isn't necessary with truss on OpenSolaris. Linux's strace can do this. So, I think this has been on enhancement list. Here's perl.
#!/usr/bin/env perl
line: while (<>) {
    if ($. == 1) {
        @Fld = split(' ', $_, -1);
        $base = $Fld[3];
        print $_;
        next line;
    }
    if (m/^([0-9\/]*:[\t ]*)([0-9.]*)([\t ].*)$/o) {
        unless ($2) {
            print $_;
            next line;
        }
        my $seconds = $base + $2;
        ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($seconds);
        $subsec = substr($seconds, index($seconds, '.'));
        printf ("%s%02d:%02d:%02d%s %s\n",$1,$hour,$min,$sec,$subsec,$3);
        next line;
    }
}

Friday Mar 27, 2009

Internet ArchiveSunMDを利用するというニュースが発表されました。

Internet Archive Forums: View Post
it is a modular datacenter that sits outside in a shipping container. This
3Petabyte (3 million gigabyte) datacenter will handle the 500 requests
per second

私も過去に何度か使ったことがありましたが日本語のページは全て以下のように文字化けしていた記憶しかありません。

"�r�W�l�X�A�i���X�g"

ですので私は勝手にInternet Archiveはアーカイブする際に間違った文字コード変換をしていると思い込んでいました。このような勘違いは私だけではなかったようです。

http://web.archive.org/web/20041013012904/www.bumpofchicken.com/info.htmlの文... - Yahoo!知恵袋
/www.bumpofchicken.com/以下のサイトは元々charsetでShift_JIS指定していたのに、
アーカイブしているサイトhttp://web.archive.org/はUTF-8だもんで文字化ける。

実際にはページ内容そのものはコード変換なしでアーカイブされていたようで、過去に文字化けしていたページをさきほど見たところ文字化け問題は解消されていました。

以前はこの問題に対処するためのGreasemonkeyスクリプトやProxomitronフィルターが使われていたようですが今は不要になっています。

Internet Archiveでの文字化けを解消するGreasemonkeyスクリプトとオミトロンの設定 | Web scratch
毎回Internet Archiveveのウェイバックマシン (Wayback Machine)を利用するときに
text/html; charset=UTF-8
と勝手に追加してしまうことで、日本のサイトの多くはSJISとかに設定しているので文字化けが発生します。

Wednesday Mar 25, 2009

My NetBeans which was installed as part Java CAPS 6 started acting a little weird. I want to troubleshoot it.
  1. First thing I did is to look in log file. In Java CAPS case, it's ${CAPS6}/.netbeans/caps/var/log/messages.log. There were not many lines in there. I need to increase log level.
  2. I thought increase log level only for NetBeans stuff should be fine. So, I gave this extra option on start.
    $ netbeans -J-Dorg.netbeans.level=FINEST
  3. Well, it failed to start. This is from the tail of messages.log
    FINER [org.netbeans.core.startup.NbInstaller]: Delegating resource java/util/logging/ from null for org.netbeans.core
    java.lang.ClassCircularityError: java/util/logging/LogRecord
    SEVERE [org.openide.util.RequestProcessor]
    java.lang.ClassCircularityError: java/util/logging/LogRecord
            at org.netbeans.core.NbErrorManager.publish(NbErrorManager.java:74)
            at org.netbeans.core.startup.TopLogging$LookupDel.publish(TopLogging.java:750)
            at java.util.logging.Logger.log(Logger.java:472)
            at java.util.logging.Logger.doLog(Logger.java:494)
            at java.util.logging.Logger.log(Logger.java:517)
            at org.netbeans.core.startup.TopLogging$LgStream.run(TopLogging.java:730)
            at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561)
    [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)
  4. So, I added another option.
    $ netbeans -J-Dorg.netbeans.level=FINEST -J-Dorg.netbeans.core.startup.NbInstaller.level=FINE
  5. I went a little fanatic and added 3 options. This failed with a different error spitted out to stdout/stderr. Looks like I need extra tweaking to enable this many logs.
    $ netbeans -J-Dorg.level=FINEST -J-Dcom.level=FINEST -J-Djavax.level=FINEST -J-Djava.level=FINEST -J-Dorg.netbeans.core.startup.NbInstaller.level=FINE 
    java.lang.StackOverflowError
            at java.util.ResourceBundle.findBundleInCache(ResourceBundle.java:1540)
            at java.util.ResourceBundle.findBundle(ResourceBundle.java:1313)
            at java.util.ResourceBundle.findBundle(ResourceBundle.java:1292)
            at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1234)
            at java.util.ResourceBundle.getBundle(ResourceBundle.java:715)
            at java.util.logging.Level.getLocalizedName(Level.java:223)
            at org.netbeans.core.startup.TopLogging$NbFormatter.print(TopLogging.java:527)
  6. I excluded org.netbeans and this time, it started OK.
    $ netbeans -J-Dorg.level=CONFIG -J-Dcom.level=FINEST -J-Djavax.level=FINEST -J-Djava.level=FINEST


Setting FINE log level high up in the hierarchy makes NetBeans slow. To find specific classes you are interested, this FINE level log may help. Or , there may be such a list already. __OR__ one can create such a list somehow, like Michael did for Java CAPS 5.


Tuesday Mar 17, 2009

About once a month, I google for references to my blog to gain a new knowledge. This time, I found one in VMWare forum.

VMware Communities: ESX 3.5 P2V Solaris 10 Sunfire X4100 ...
i'm in the midst of finishing up my DR project and the last two pieces rely on migrating 3 physical servers to my ESX farm.

which lead to another thread in the forum:

VMware Communities: vmconverter sun solaris 10 ...
I have succesful convert a Sun Solaris 10 fysical machine with the VMconverter 3.03 boot cd.


Looks like P2V of Solaris10 is quite commonplace. It also looks like that VMware converter's "Cold cloning" can clone Solaris10, which costs $$. If one wants to try P2V without paying, using free backup/restore boot-CD  may work, which I documented in my past entry.

Monday Jan 26, 2009

Thanks to all who commented on my past entry.

Migrating VMware->VirtualBox: Windows XP/2003 guest
For Windows XP/2003, I made only 2 changes and they booted successfully.
And I'm sorry I don't have answers to all of the questions.

I find Jason's comment interesting.

this worked great on VBox 2.1.2! With the comments from Robert, the guest did speed up noticeably and was finally able to P2V a Windows host into a usable Virutal Box guest.

I wonder how Jason P2V'ed his Windows. Either used VMware's tool or backup/restore or ... ?

Monday Dec 08, 2008

I decided to follow what my colleagues are doing. Monitoring heart rate while running.

Miles to go ...: Heart Rate Monitors and Marathon Training
I'm planning to buy a heart rate monitor (HRM) to assist me. Read here to see why heart monitoring is beneficial
Bringing some science into running : Interconnectedness of all things
heart rate thresholds not to go above. So for longer distances taking much longer than an hour stay below 156 beat per minute and with 171 as my max heart rate

As I wrote before in this entry, all my heart rate data are stored in MySQL tables. This includes data from 2 sessions to know 2 kinds of 'heart rate'.
  1. Maximum Heart Rate(MHR)
    I did pretty hard work out in which I climbed up stairs for 100 meters twice.
  2. Resting Heart Rate(RHR)
    I measured my heart rate while I was still in bed after 6 hours sleep.
So, here's my MHR and RHR, retrieved by a SQL statement.
mysql> select max(cast(MaxHR as UNSIGNED)),min(cast(AverageHR as UNSIGNED)) from tracklapmaster where AverageHR!=0;
+------------------------------+----------------------------------+
| max(cast(MaxHR as UNSIGNED)) | min(cast(AverageHR as UNSIGNED)) |
+------------------------------+----------------------------------+
|                          185 |                               46 |
+------------------------------+----------------------------------+

Wednesday Dec 03, 2008

I recently purchased Globalsat GH-625. It had a CD-ROM in the box and I was surprised to find that MySQL is included in it. Yes, you guessed it right. The software uses MySQL to store my running/bicycling/walking logs, including latitude/longtitude/altitude, heart rate, lap time.

MySQL is used from the application as 'Embedded', as opposed to 'Deeply Embedded' (Yeah, I learned these are the correct parlance in MySQL world at recent user conference). So..., I can access it from 'mysql' client tool like below. I hope I can
do schema analysis to find entity relationships soon. I think MySQL has a cool tool to do it.

bash-3.2$ /c/e/Program\ FilesW2K3/GSsport/MySQL/bin/mysql -u root -ppassword --port=3308
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 59
Server version: 5.0.51a-community-nt MySQL Community Edition (GPL)
mysql> use globalsatgh615
Database changed
mysql> show tables;
+--------------------------+
| Tables_in_globalsatgh615 |
+--------------------------+
| tbllogin                 |
| tracklapmaster           |
| tracklappoints           |
| trackmaster              |
| trackmaster2             |
| trackpoints              |
| waypointmaster           |
+--------------------------+
mysql> desc trackmaster2;
+--------------+------------------+------+-----+---------+----------------+
| Field        | Type             | Null | Key | Default | Extra          |
+--------------+------------------+------+-----+---------+----------------+
| TrackID      | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| TrackName    | varchar(45)      | NO   |     | NULL    |                |
| StartTime    | varchar(12)      | NO   |     | NULL    |                |
| Duration     | varchar(35)      | NO   |     | NULL    |                |
| Distence     | varchar(12)      | NO   |     | NULL    |                |
| Calories     | varchar(12)      | NO   |     | NULL    |                |
| MaxSpeed     | varchar(12)      | NO   |     | NULL    |                |
| MaxHearRate  | varchar(12)      | NO   |     | NULL    |                |
| AvgHeartRate | varchar(12)      | NO   |     | NULL    |                |
| NoOfPoints   | varchar(12)      | NO   |     | NULL    |                |
| Status       | int(10) unsigned | NO   |     | NULL    |                |
| UID          | int(10) unsigned | NO   |     | NULL    |                |
| ActivityID   | int(10) unsigned | NO   |     | 0       |                |
| NoOfLaps     | varchar(12)      | NO   |     | NULL    |                |
| AUpheight    | varchar(12)      | NO   |     | NULL    |                |
| ADownheight  | varchar(12)      | NO   |     | NULL    |                |
+--------------+------------------+------+-----+---------+----------------+
mysql> select TrackID,TrackName,Distence,MaxHearRate,NoOfPoints,NoOfLaps from trackmaster2;
+---------+------------+----------+-------------+------------+----------+
| TrackID | TrackName  | Distence | MaxHearRate | NoOfPoints | NoOfLaps |
+---------+------------+----------+-------------+------------+----------+
|       1 | 2008-11-24 | 7139     | 0           | 2155       | 15       |
|       2 | 2008-11-29 | 0        | 185         | 1          | 2        |
|       3 | 2008-11-30 | 11507    | 0           | 3488       | 23       |
+---------+------------+----------+-------------+------------+----------+
mysql> desc tracklapmaster;
+---------------+---------------------+------+-----+---------+-------+
| Field         | Type                | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+-------+
| TrackMasterID | int(10) unsigned    | NO   | PRI | 0       |       |
| LapNo         | int(10) unsigned    | NO   | PRI | 0       |       |
| AccruedTime   | varchar(45)         | NO   |     | NULL    |       |
| TotalTime     | varchar(45)         | NO   |     | NULL    |       |
| TotalDistance | varchar(45)         | NO   |     | NULL    |       |
| Calory        | varchar(45)         | NO   |     | NULL    |       |
| MaximunSpeed  | varchar(45)         | NO   |     | NULL    |       |
| MaxHR         | varchar(45)         | NO   |     | NULL    |       |
| AverageHR     | varchar(45)         | NO   |     | NULL    |       |
| NoOfPoints    | varchar(45)         | NO   |     | NULL    |       |
| Status        | tinyint(3) unsigned | YES  |     | 1       |       |
| startIndex    | int(10)             | NO   |     | 0       |       |
| endIndex      | int(10)             | NO   |     | 0       |       |
+---------------+---------------------+------+-----+---------+-------+
mysql> select TrackMasterID,count(*),avg(NoOfPoints) from tracklapmaster group by TrackMasterID;
+---------------+----------+-----------------+
| TrackMasterID | count(*) | avg(NoOfPoints) |
+---------------+----------+-----------------+
|             1 |       15 |           143.6 |
|             2 |        2 |               0 |
|             3 |       23 | 151.60869565217 |
+---------------+----------+-----------------+
mysql> desc tracklappoints;
+---------------+------------------+------+-----+---------+-------+
| Field         | Type             | Null | Key | Default | Extra |
+---------------+------------------+------+-----+---------+-------+
| TrackMasterID | int(10) unsigned | NO   | PRI | 0       |       |
| SLNo          | int(10) unsigned | NO   | PRI | NULL    |       |
| Latitude      | varchar(18)      | NO   |     | NULL    |       |
| Longitude     | varchar(18)      | NO   |     | NULL    |       |
| Altitude      | varchar(18)      | NO   |     | NULL    |       |
| Speed         | varchar(18)      | NO   |     | NULL    |       |
| HeartRate     | varchar(18)      | NO   |     | NULL    |       |
| IntervalTime  | varchar(18)      | NO   |     | NULL    |       |
| Status        | int(10) unsigned | NO   |     | 0       |       |
+---------------+------------------+------+-----+---------+-------+

Friday Nov 14, 2008

At Sun, we can logon to SunRay servers, which is Solaris10, but us mere mortal employees are not given 'crontab' privelege.

I have a task which I run everyday at 3PM and I have been running it in a terminal interactively every day. Today, I learned that I was very stupid... Even the 'man' page says 'at' can be an alternative to crontab.
$ man at 2>/dev/null | ggrep -B 4 -A 6 crontab
     Example 3: Self-rescheduling a Job

     To have a job reschedule itself,  at  can  be  invoked  from
     within  the  at-job.  For  example,  this "daily-processing"
     script named my.daily runs every day (although crontab is  a
     more appropriate vehicle for such work):

     # my.daily runs every day
     at now tomorrow < my.daily
     daily-processing


To run "daily-processing*" everyday, starting from today and now, do ...

$ cat > misc/my.daily
# my.daily runs every day
at now tomorrow < misc/my.daily
daily-processing_1.sh
daily-processing_2.sh
daily-processing_3.sh
^D
$ sh misc/my.daily

This blog copyright 2009 by Katsumi Inoue