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