September 30, 2017

Fixing rsync error: error in rsync protocol data stream

I use rsync (wrapped in a script) to back up the data to a Western Digital MyCloud device from my Fedora system. At times I have seen rsync errors "rsync error: error in rsync protocol data stream (code 12) at io.c(226) [sender=3.1.2]" during backup.


As the error was appearing sporadically, it was not a configuration or setup issue. Finally I tried passing protocol parameter to rsync and it worked. The rsync in my Fedora system uses protocol 31 by default and the one in WD device supports 30 by default. Setting --protocol=30 didn't help but setting protocol to 26 resolved the problem. I've been running rsync using protocol 26 for few weeks and haven't seen the errors.



July 29, 2017

vnstat : Recovering from error "Invalid database daily date order"

I use vnstat to keep track of the network traffic statistics in my Fedora system. Through a web interface, it can show some nice charts. Couple of weeks ago when I was trying to see the stats, it was not loading properly. I initially suspected SELinux but executing vnstat from command line proved that there was some problem with vnstat itself. I got the error "Error: enp1s0: Invalid database daily date order: 1494518195 (3) < 1509896072 (4)"
I couldn't find anything helpful to resolve the issue. All I could do was to downgrade vnstat to previous version. As I have configured dnf to retain the cache, the downgrade was bit easy. The downside was that whenever I was updating the system, I had to pass -x vnstat to dnf command so that it will skip updating it.

From the time stamps that appeared in the error message, I thought that the date format was flipped and instead of May-11, Nov-5 was entered in the database creating the problem. The vnstat database is a binary one but vnstat supports exporting and importing the database. Reading the vnstat manual page gave enough information to export and import the data to a new database.

The following steps were taken to export the data from old database, fix it and then import it to new database.

Create a local configuration file for vnstat.
Copy the /etc/vnstat.conf to a local folder and change the DatabaseDir to point to that local folder.

Copy the vnstat database to the local directory. Export the data file using the command

vnstat -i wlp3s0 --exportdb > wlp3s0.db 
 
Update the incorrect time stamps in the exported file.
For example, date -d "2017-05-21" "+%s" will give the time stamp in required format.

Create a new db

vnstat --config ./vnstat.conf  --create -i wlp3s0

Import the modified data

vnstat --config ./vnstat.conf  -i wlp3s0 --importdb wlp3s0.db --force
 
Check the correctness day / month wise data

vnstat --config ./vnstat.conf  -i wlp3s0 -d 
vnstat --config ./vnstat.conf  -i wlp3s0 -m

Stop vnstat and copy the new file to /var/lib/vnstat

sudo systemctl stop vnstat.service
sudo cp ~/vnstat/wlp3s0 /var/lib/vnstat

Update vnstat using sudo dnf upgrade vnstat. I could see that the new version of vnstat was working without problem with the updated db. Started the vnstat using sudo systemctl start vnstat.service and vnstat was back in action.

The downside was that the data for almost two months were not captured by vnstat. My weekly backup was not configured to capture this data. Lesson learned and I quickly set up an automated backup for the dynamic files using anacron. However, I am yet to figure out a way to validate the sanity of the dynamic data.

May 11, 2017

History from Free Dictionary and Aard2 Android Dictionary apps

I use Free Dictionary and Aard2 for in my Android phone to look up the meaning of words. If you ever need to get the list of words that were looked up in these apps from a Linux system, you may find this useful.


The first step would be to enable connect the phone to the computer and enable USB debugging.

Free Dictionary

adb shell run-as org.freedictionary cat shared_prefs/FreeDictionary.xml | 
xmlstarlet sel -T -t -v /map/string | tr ',' '\n' 

Aard2 Dictionary
Things are bit complicate for Aard2 as I found that it does not support run-as command.

adb backup -f ./aard2.ab -apk itkach.aard2
java -jar abe.jar unpack aard2.ab  aard2.tar
tar -O -xvf  aard2.tar apps/itkach.aard2/r/app_history 2>
  /dev/null | jq -r '.key'

April 4, 2017

Naming Rights in Action

പശ്ചിമഘട്ടത്തിൽ കണ്ടെത്തിയ പുതിയ മരഞണ്ടിന്റെ ശാസ്ത്രനാമം : കാണി മരഞണ്ട്. സംശയിക്കേണ്ട, മലയാളം തന്നെ. കാണി വിഭാഗക്കാരുടെ സഹായത്തോടെ മലയാളി ഗവേഷകർ കണ്ടു പിടിച്ചതുകൊണ്ടാണ് കാണി മരഞണ്ടെന്നു പേരു കൊടുത്തത്.
വാർത്ത ഇവിടെ :
https://phys.org/news/2017-04-species-tree-crab-western-ghats.html

ഇങ്ങനെ ഓരോന്ന് സ്വന്തമായി കണ്ടുപിടിച്ചാൽ മലയാളത്തിലൊക്കെ പേരിടാം. ഹാർഡ്‌‌വെയർ അബ്സ്റ്റ്രാക്ഷൻ ലെയർ നമ്മൾ മലയാളികളാണ് കണ്ടുപിടിച്ചിരുന്നത്/ ഉണ്ടാക്കിയിരുന്നതെങ്കിൽ അതിനെ ശശിപാളി (കടപ്പാട്: +Subin PT) [1] അല്ലെങ്കിൽ കിടുതാപ്പ് മറ (കടപ്പാട്: വിനയാന്വിതനായി ഞാൻ) എന്നൊക്കെ വിളിക്കാമായിരുന്നു.

[1] https://plus.google.com/u/0/+SubinPT/posts/ZgNd2HzyKz9

September 16, 2016

March of Progress

I came across a chapter on Thomas Henry Huxley while reading The Book of Science edited by John Carey. The description about his book Man's Place in Nature piqued my curiosity. The frontispiece of the book showed a queue of skeletons with man at the front followed by skeletons of Gorilla, Chimpanzee, Orangutan and Gibbon. Wait a second, haven't I seen something similar elsewhere? I didn't know the name of the picture and for some reason I thought it was called "The Ascent of Man". Soon after establishing https connection to certain servers (Googling in plain English) there came the answer - the picture I was looking for is called "The March of Progress" and it is from the book Early Man by F. Clark Howell. This explains why I take a long time to finish books on Science. Apparently the popular version we see all over is the folded version of the original.

Carey did add something interesting about Huxley in the note on his debate with a Bishop on theory of evolution. During the debate the Bishop asked certain question about Huxley's ancestors. Huxley gave a befitting answer. However the gem is Huxley's reaction on the death of this Bishop due to the fall from horseback. "For once reality and his brain came into contact, and the result was fatal."