Graphing System Statistics with Grafana
Graphing System Statistics (the old fashioned way)
Since the mid 2000s system administrators who wanted to have a visual representations of their systems statistics had access to Graphite. This tool allows for elaborating graphs of values collected periodically to provide a representation of the data over time. Coupling this feature with collectd, which among many built-in supported metrics offer the possibility of sending system statistics to a central location running Graphite, allows to create a single portal for viewing statistics of your entire infrastructure easily. While this still remains a nice setup the graphical visualization capabilities of Graphite and rrdtool left some room for growth.
Enter Grafana
Grafana is a Graphite installation front-end that offers a very robust graphing/plotting library (provided by Flot) along with templates for creating similar displays for multiple datasets. Here you can see a comparison of the same dataset in both graphing libraries:
Graphite (rrdtool)
Grafana (Flot)
Data Analysis
Once you have setup collectd and Graphite to gather simple metrics from the servers you wish to monitor, you will easily have some basic instrumentation for …
visualization
Coding style guides across languages
Introduction
Before you can start programming production code in any programming language you should know a few things like syntax, purpose, coding standards, good practices. There is another thing that is really important too and can help developers that work with multiple projects and languages: coding style guides. This is just a set of rules that developers should take care about when writing code. They are not so different across various programming languages. In this article, I will sum up and list coding style guides for the most popular languages.
It’s not a crime to use different styling, but standardizing this helps in the process of creating software. When your team is using the same standard it’s much easier to read each other’s code.
There is one universal resource when it comes to programming style guides. Many of you will already have read it: the “Clean Code” book by Robert C. Martin.
Something else that should be mentioned here:
- When you don’t know how to write a structure, read guides.
- When you know how to write a structure but it’s different than standardized, ask other developers about it.
- When your structure is different than all the other structures made by …
programming tips
Perl’s CPAN is 20 years old
This is just a short note to celebrate the fact that the Comprehensive Perl Archive Network (CPAN) turned 20 years old yesterday!
CPAN began as a way to collect, mirror, and distribute open-source Perl packages. Over time it led to development of better packaging and module naming conventions; formed a community for feedback, testing, and contributions; and became one of the great strengths of the Perl world.
It is rare to find some needed functionality that is not available on CPAN. These days a more common problem is finding too much choice there, and needing to choose between several modules based on which are better maintained and supported on current versions of Perl, or kept current against external dependencies.
Perl does not get as much press these days as it once did, but it continues to thrive and improve. On that topic, our former co-worker Steph Skardal sent me an article called We’re still catching up to Perl by Avdi Grimm of Ruby fame. It is not an in-depth language comparison, just a brief observation to his fellow Rubyists that there is plenty to be learned from Perl. (Of course Perl has plenty to learn from Ruby and other languages …
perl programming
Usability: Don’t Make Me Think and a Bookmarklet
Hi! Steph here, former long-time End Point employee now blogging from afar as a software developer for Pinhole Press. While I’m no longer an employee of End Point, I’m happy to blog and share here.
I’m only about a quarter of the way into Don’t Make Me Think (Revised) by Steve Krug, but I can already tell it’s a winner. It’s a great (and quick) book about web usability, with both high level concepts and nitty gritty examples. I highly recommend it! Even if you aren’t interested in web usability but are a web developer, it’s still a quick read and would be invaluable to whomever you are coding for these days.
A Bookmarklet
The book inspired me to write a quick bookmarklet to demonstrate some high level concepts related to usability. Here’s the bookmarklet:
javascript:(function() {
var possible = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
$('*:not(iframe)').contents().filter(function() {
return this.nodeType == Node.TEXT_NODE && this.nodeValue.trim() != '';
}).each(function() {
var new_content = '';
for(var i = 0; i<this.nodeValue.trim().length; i++) {
new_content += possible.charAt(Math …books javascript tips
Bucardo replication from Postgres to sqlite and mariadb using pgbench
While Bucardo is known for doing “multi-master” Postgres replication, it can do a lot more than simple “master to master” replication (better known as “source to source” replication). As people have been asking for simple Bucardo Bucardo 5 recipes based on pgbench, I decided to present a few here. Since Bucardo allows any number of sources and targets, I will demonstrate a source-source-source-target replication. Targets do not have to be Postgres, so let’s also show that we can do source—MariaDB—SQLite replication. Because my own boxes are so customized, I find it easier and more honest when writing demos to start with a fresh system, which also allows you to follow along at home. For this example, I decided to fire up Amazon Web Services (AWS) again.
After logging in at https://aws.amazon.com, I visited the AWS Management Console, selected “EC2”, clicked on “Launch Instance”, and picked the Amazon Linux AMI (in this case, “Amazon Linux AMI 2015.03 (HVM), SSD Volume Type—ami-1ecae776”). Demos like this require very little resources, so choosing the smallest AMI (t2.micro) is more than sufficient. After waiting a couple of minutes for it …
database postgres replication
Streaming Replication time lag monitoring added to check_postgres
I almost let this one sneak past! Guess I need to do some lag monitoring on myself. About a month or so ago, a new version of check_postgres was released, and that includes a bit of code I wrote. While the patch has been available in the git checkout for a while, now that it’s in the official release and will start appearing in repos (if it hasn’t already) it’s probably worth writing up a quick note describing its reasoning and usage.
What’s the feature? Time-based replication monitoring in the hot_standby_delay action. This was something that had been a long-standing item on my personal TODO list, and happened to scratch the itch of a couple of clients at the time.
Previously it would only take an integer representing how many bytes of WAL data the master could be ahead of a replica before the threshold is crossed:
check_hot_standby_delay --dbhost=master,replica1 --critical=16777594This is certainly useful for, say, keeping an eye on whether you’re getting close to running over your wal_keep_segments value. Of course it can also be used to indicate whether the replica is still processing WAL, or has become stuck for some reason. But for the (arguably more common) problem of …
monitoring nagios postgres sysadmin
Not so popular JavaScript/HTML functionalities
There are multiple things in a front-end developer work that can be easily fixed by a native browser functions. Based on experience, JavaScript learning path for a big part of front-end developers is not perfect. Therefore, I will give you some examples, for some people as a reminder, for others as a new thing to think about. It is always good to learn, right?
document.execCommand
It lets you use built-in browser functions as you wish from JavaScript, simple functions to do simple things. execCommand is very useful when you work with text ranges selected by a user. It’s also popular that it comes together with a contentEditable HTML element attribute.
Practical examples
- You want to have redo button in your application, so when user will click on it, the latest changes will be discarded.
// after running just this, the latest user changes will be discarded (text input changes)
execCommand('redo', false, null);- You want to remove text after the cursor position.
// after running this script one character after the cursor
// position in a current element will be removed
execCommand('forwardDelete', false, null);There are more than 30 functions ( …
html javascript
How To: Big Beautiful Background Video
One pretty common request for every web developer is to “please, make our Stone age website look sleek and modern”. Well, no more head scratching about the meaning of “sleek” or “modern” (or “the Stone age” for some?). In times of the crisp and stunning visuals there’s no better way to make an impression than to use a big beautiful background video on the home page.
Paired with some impressive infinite scroll which I already covered here and a nice full-screen image gallery (which I will cover later), it will definitely help to bring your website up to date.
Lucky for us, there is a very popular library called BigVideo.js which is based on another well known library videojs, which is a wrapper around HTML5 <video> tag.
Converting the video.
To ensure the cross browser support, it’s best to supply the desired video in several formats. The most common formats to use are mp4, ogg and webm. Here is the browser support chart to give you a better idea of why it’s so important to use more than one format on your page.
There are a lot of ways to convert the file, but since I’m not particularly good with compression settings or codecs, I’m using the following easy workflow:
- Upload …
html javascript video




