
Can you monitor your typing speed and accuracy with Zabbix? Of course you can!
Why?
For some time now, I have felt that the external keyboard I use at home makes me a clumsy typer. Whenever I type with my Linux laptop or Mac keyboard, I feel like I make less typos than with the otherwise comfortable external keyboard. To make the testing more scientific, time to summon good old typespeed and hook it with Zabbix.
What's typespeed?
It's a really old command line game where words just keep on scrolling from left to right and you have to type them correctly before they reach the right side of the window. The game begins with just one or few words scrolling by slowly, but quickly becomes very chaotic as the pace and the number of words climbs up.
First, you choose your wordlist:

Then the game begins like this

... but then changes quite a bit

And when you are done, you get the final score

Finally, you get to type your name and see the high score list.

The high score file format
The game makes it very easy to parse the scores. It stores the score file in a text file -- for example, on Debian the file can be found at /var/games/typespeed.score --and the format looks like this.
pi@raspberrypi /v/games [1]> cat typespeed.score
453 612 67 ExtKeyboard words.eng default 12374 1726433297
"How is that easy?", I see you wondering. Well, luckily the game documentation explains the file format, here's some direct copy-paste.
Field | Name | Meaning ------+----------------+----------------------------------------------- 1 | score | How many points has the player gathered? 2 | total count | How many characters has the player entered? 3 | enter offset | Count of enter/space pressed to finish a word 4 | name | What name has the player? 5 | word list | What word list was in use? 6 | rule set | Which rule set was in use? 7 | duration | How long lasted game session? (hundreds of seconds) 8 | sinit | Value used to fill in random number generator Example: 227 229 39 Tobias words.unix rule.classic 5600 0 This means that player "Tobias" played word list "words.unix" with rule set "rule.classic". Further more it is easy to tell that no cheat mode was in use, because an enter offset of 39 exists. In cheat mode, this value would be 0, because no enter/space has to be pressed. The value for random number generator is unknown (0). This means that this entry has been converted with convert. The score of player "Tobias" was 227, with 229 characters typed in total. The game lasted 56 seconds. With these information, cps, tcps and typo ratio can be calculated: cps = (score + enter offset) / duration * 100 tcps = (total count + enter offset) / duration * 100 typo ratio = (1 - (score + enter offset) / (total count + enter offset)) * 100
Fantastic! Time to enter this to my Zabbix.
Taking this to Zabbix
To get the results to Zabbix, I created a new template called Typespeed and then added a new Zabbix agent item thats just log[/var/games/typespeed.score] so Zabbix tails that score file.

and on Preprocessing tab, added Discard unchanged so Zabbix would not bother to add any unchanged values between the games.

using that item as master item, created bunch of dependent items

these dependent items then parse the individual fields using regular expressions

... with the final and worst regexp being
^[0-9]+\s+[0-9]+\s+[0-9]+\s+\w+\s+[\w\.]+\s+\w+\s+[0-9]+\s+([0-9]+)
After these steps, we have the data flowing to Zabbix.

Calculating cps, tcps, typo ratio
The game documentation shows the maths how to calculate characters per second (without enter/space), characters per second (with space/enter), and typo ratio.
Calculating these in Zabbix is trivial thanks to its Calculated items type, something that I have not been covering here too often.

(1-(last(//typespeed.score)+last(//typespeed.enteroffset))/
(last(//typespeed.totalcount)+last(//typespeed.enteroffset))) *100
Dashboard time
With all these bits and pieces in place, I can now create a dashboard and see how I'm doing. Now the only thing left is then to start doing some testing. Benefit of doing this in Zabbix compared to pure command line typespeed high score list is that with Zabbix I can bring in more variables to consider: time of day when I'm typing, the music I'm listening to.... I'll get back to this, or maybe let y'all know in the Zabbix Summit what's the conclusion for this little experiment.
If this blog post woke up your interest, feel free to download the Zabbix 7.0 template for typespeed I just released.

Add new comment