Friday, November 13, 2015

Centralized async logging from VBS scripts

Borrow a page out of the snowplow book and log asynchronously from any script with a GET request to a central system.

In Visual Basic Script:

URLGet "" & WshNetwork.ComputerName & "/" & activity & "/message/" & strValue

Function URLGet(URL)
  Set Http = CreateObject("Microsoft.XMLHTTP")
  Http.Open "GET",URL,True
End Function

And get analytics for free on top of your scripts with logstash (or snowplow).

Tuesday, October 27, 2015

Fun with Postgresql and ZFS

I will show how to use ZFS instant snapshotting and cloning functionality to effortlessly clone a running postgres database regardless of its size.


Install your Linux OS of choice then ZFS and Postgres. I use Centos 7 but most commands used in this post are distro-indipendent.

Create a zfs pool called tank or use whatever name suits you. In the pool create a filesystem called pgdata. For the sake of following a minimalist ZFS best practice apply the following settings:

zfs set compression=lz4 tank/pgdata
zfs set xattr=sa tank/pgdata

Friday, August 14, 2015

Simple is beautiful: Guava LoadingCache

Cache is king.

Database lookups can be expensive and RAM prices have been falling for years to the point that developers don't care anymore (ops do, btw).
So what if you could use those gigabytes of RAM for caching expensive queries or frequently used data? If you are a Java developer chances are that you came across Ehcache, Spring cache, or perhaps rolled your own.
Disclaimer: not the Guava stuff described in this post

Grails bundles Ehcache because it can be used by Hibernate and also has a plugin which allows to cache methods just by annotating them. Unfortunately Ehcache has some quirks and with the stock configuration it will also not allow parallel deployment (I documented a fix here on this blog).

An alternative cache implementation that I recently had a chance to use is the Guava LoadingCache. The implementation is so elegant that it will make you want to use it everywhere! Basically you build a cache, configure TTL and size (optional) and supply a loader callback that will be invoked whenever an entry cannot be found in the cache. Example here.

Assuming you are accessing the cache implementation directly, no more complex if-peek-then-return-else-load-put-return. From now on just:


An additional benefit is that Guava does not carry dependencies, is OSGi-ready, and will keep your project lighter.

Sunday, April 19, 2015

Detect missed executions with OpenNMS

Everyone knows that OpenNMS is a powerful monitoring solution, but not everyone knows that since version 1.10 circa it embeds the Drools rule processing engine. Drools programs can then be used to extend the event handling logic in new and powerful ways.

The following example shows how OpenNMS can be extended to detect missed executions for recurring activities like backups or scheduled jobs.

Saturday, April 18, 2015

9 months with WIFIWEB

WIFIWEb is a local WDSL internet provider. Since I moved last year I have been a customer with their WDSL Max 10 profile.

This is the pingdom report for the last 9 months:

Applications sensitive to latency and micro-interruptions (like Remote Desktop) would from time to time drop the connection.

Bandwidth-wise results varied over the period, but except for one time when I had to call to fix a performance issue, the experience was pretty smooth with a download speed consistently in a 6~8 Mb/s window.
The 1Mb upload speed was always achieved.

Call quality using free VOIP softphones (sflphone or linphone) was generally bad, but I dont't know how much the fault lies with software or the connection.

Verdict: recommended.

Tuesday, April 14, 2015

RUNDECK job maintenance

Learn more about Rundeck.

Now that I have a fair number of jobs scheduled by Rundeck, how do I periodically prune the job execution history and keep only the last, say, 30 executions for each job?

Thursday, April 02, 2015

OpenNMS performance: tune Jrobin RRD file strategy

One of the nice aspects of OpenNMS is that, out of the box, it will collect a lot of data from most snmp-enabled resources. The downside is that such collection is I/O heavy (iops, not throughput).

Even on moderate installations with hundreds of nodes it is enough to swamp even the fastest disk subsystem (except for those with controllers supported by large write caches). A symptom is that I/O wait will be quite high on the opennms box itself.
I/O Wait before and after switch jrobin backend from FILE to MNIO