RASPBERRY PI AND OFFICIAL NFL SCORE BOARD API

Now that I’ve got my hands on a Raspberry Pi 3 Model B Motherboard , I decided nows a good time to play around with the 16x2 LCD Module Controller HD44780 I had laying around (I’ve had this thing since December 2015). A live NFL (National Football League) score board seemed fitting as the season just started. I found a really good write up on raspberrypi-spy.co.uk about wiring up the controller and Pi, here is the diagram I used:

read more
SENSORTAG TEMPERATURE READINGS IN PYTHON

I wanted to wrap up my previous post TI SensorTag Temperature Readings ) with a little python example, thus this write is going to be short and sweet. Using the bluepy python library (written by Ian Harvey) I’ve been able to to capture temperature readings, then covert them to Fahrenheit. To demonstrate I captured a couple temperature samples, a few while sitting on my desk, and a few held up to my air condition vent:

read more
TELEGRAF AND MISSING CPU INTERRUPTS

As I’ve been playing around with Telegraf and Grafana , I’ve noticed CPU interrupts and context switches are not apart of the standard metric gathering. We know vmstat shows this information, and can be shown it in a easy processable list form: $ vmstat -s 1016888 K total memory 497920 K used memory 184412 K active memory 173296 K inactive memory 518968 K free memory 70276 K buffer memory 86416 K swap cache 522236 K total swap 88460 K used swap 433776 K free swap 18175 non-nice user cpu ticks 0 nice user cpu ticks 17799 system cpu ticks 172172 idle cpu ticks 7214 IO-wait cpu ticks 0 IRQ cpu ticks 2412 softirq cpu ticks 0 stolen cpu ticks 227755 pages paged in 986944 pages paged out 2353 pages swapped in 121572 pages swapped out 458705 interrupts 1467529 CPU context switches 1461773910 boot time 3456 forks I decided to hack together a little exec plugin for Telegraf using a Python script, running the script will get you standard out JSON:

read more
PYTHON TRACEROUTE STYLE TOOL

Recently, while talking with a some techies I was asked to explain how traceroute works. I was quick to answer what results I expect back from the command, and how to understand that data, but for the life of me I was having issues recalling how TTL works at the foundation. Later that week I spent some time reading up on it, and click, it all came back. To reinforce this I decided to write some code.

read more
PROCESS ELASTICSEARCH JSON ON THE SHELL

Lets throw security out the window for a moment. Say we store user accounts with clear text passwords in Elasticsearch , what is the easiest way to use the results in a shell script? We can begin by creating two accounts, one for admin and one for john :

curl -XPUT localhost:9200/site/people/1?pretty=True -d ' {"name": "admin", "password": "secret", "admin": "true"} ' { "_index" : "site", "_type" : "people", "_id" : "1", "_version" : 1, "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "created" : true } # curl -XPUT localhost:9200/site/people/2?

read more
TELEGRAF LAPTOP BATTERY PLUGIN

Wanted to expand a little on my previous blog post Custom Telegraf Plugin , and decided to do a simple battery monitor. The end result looks something like this: I decided to read from the file /sys/class/power_supply/BAT0/capacity on my Ubuntu 14.04 machine, this file merely shows the current battery percent:

cat /sys/class/power_supply/BAT0/capacity 62 All that is needed is a little Python script for converting this output to JSON, my script outputs like this:

read more
CUSTOM TELEGRAF PLUGIN

I just started looking to InfluxDB and Telegraf for collecting data on a Linux machine, then visualizing it with Grafana . I’ve historically used collectd , statsite , and graphite to accomplish the same sort of task, but wanted to see how some of the new software compares. I’m running a Ubuntu 14.04 LTS virtual machine, so feel free to follow along. I managed to install the packages from the InfluxDB ubuntu repositories :

read more
CHECK SSL CERTIFICATE'S EXPIRATION

If you ever want to quickly check the expiration date on your HTTPS server’s SSL certificate all you need is OpenSSL , luckily most of your Linux and OSX workstations will already have it installed. openssl s_client -showcerts -connect domain.com:443 </dev/null 2>/dev/null \ | openssl x509 -noout -dates You should get back a nice and tidy response with a notBefore and a notAfter date: notBefore=Mar 13 00:00:00 2015 GMT notAfter=Mar 12 23:59:59 2018 GMT

read more
POSTGRESQL VACUUM SCRIPT

PostgreSQL does have a built in auto vacuum , but sometimes you just want a small script that can be ran through Jenkins to perform the vacuum for you. Wanted to share with you guys a small Python script I wrote that will perform a VACUUM VERBOSE ANALYZE on every table within a database. You will need to get psycopg2 installed from PyPi first: pip install psycopg2 At which point you should be able to use the below script with the correct environment variables to vacuum your database:

read more
RASPBERRY PI – CLEVERBOT VOICE COMMUNICATION

Using my first generation Raspberry Pi and a few USB / analog devices, i’ve been able to create (a rather slow) cleverbot voice communicator. The reason for the slow down is initialization and listening on the USB microphone, but other than that everything works as expected. #!/usr/bin/env python import speech_recognition as sr import pyttsx import cleverbot print 'Initializing, please wait…' # define our cleverbot cb = cleverbot.Cleverbot() # speech recognizer setup r = sr.

read more