Skip to content

Raspberry Pi Security Camera

If you are like me you have a set of things that stay in the office all the time. For example, tape dispenser, scissors, whiteboard makers, etc. These items have a do-not-leave-the-office rule so that you can find them during when hours when needed. However, you find yourself in need of knowing who keeps taking the office-only items out of the office. In my case I’d be in a phone call (often conference) with a customer and need to jot something down on the whiteboard and all 10 dry-erase pens would be missing. Nothing like trying to be a professional and you have to excuse yourself to go ask your kids where something is! As a workaround, I do hide one marker, but still I want to know who keeps breaking the keep-it-in-the-office rule! Well thanks to Linux, a Raspberry Pi, and a webcam, we can create our own customization security camera for the home office.

We have two main choices here: we can use our own Linux install and install the components we need or we can use a purpose-built distribution. I have tried both and they each have their own pros and cons. Currently I am using a purpose-built distribution called meyeos. meyeos is Debian-based (Raspian) Linux distribution that uses Motion for the back-end and motionEye for the front-end, providing a easy to use web interface with lots of configuration options.

The first step is to download meyeos onto your Linux workstation. Once downloaded, you can use the included writeimage.sh to install onto your microsd card. Example usage:

# ./writeimage.sh -d /dev/mmcblk0 -i “


The first boot takes a few minutes (I think about 4 on a B) depending on how fast your device is. After it is up and running you can access it via your web browser of choice by going to meye-XXXX, where the Xs represent the digits of your Raspberry Pis serial number which are printed on the board. If you don’t know what the serial number is because you already put your Pi in a case, you can look for the IP in your router’s DHCP logs.

Configuration is very simple and there are little “i” icons next to things that may not be obvious that include further information. I have mine setup to upload to a dropbox location so that I can access the images from anywhere. There are lots of things that can be configured and tweaked including overclocking. I tend to prefer motion activated still images over videos and so I have mine configured to favor that.

Once you are up and running you should be able to view a live feed of the camera and depending on your configuration you may be able to see images being added to your dropbox directory.

Now we put our security camera in a location that gives the best view of the office. For me that location is in the corner of the room facing my desk on the same wall as the door. Now we tell everyone of the new camera and wait a few days until something goes missing. As soon as it does, we can check the upload folder for our photo evidence to identify the culprit!

PostgreSQL on a Raspberry Pi 3 64-bit with Binary Streaming Replication

In my home office I run PostgreSQL with streaming binary replication between two servers. I don't need streaming replication in my home office, but it is a good way to learn the system and it's also nice having the ability to switch which server is the master during upgrades. After a hardware failure in my VM server I decided it was really stupid to have both the master and slave on the same physical machine. My database needs are small as I only use mediawiki, zabbix, and a few other minor things so I decided to look at using a Raspberry Pi 3 in 64-bit mode as a database server. I was also curious if PostgreSQL could replicate between two different architectures: aarch64 (arm 64-bit) and amd64 (x86_64) as the endianness is the same and the bitness is as well. I'm always on the lookout for new projects involving Raspberry Pis, Linux, and other related things and thought this might be a fun thing to try. I run Gentoo on all of my Linux machines and I also refuse to use SystemD and instead use OpenRC which means you'll need to adjust a few commands here and there if you use something else!

There is a Gentoo guide that covers installing on the Raspberry Pi 3 in 64-bit mode and is a separate beast from the normal install guide for other Raspberry Pis due to complications with getting the Pi3 into 64-bit mode.

Once you have your Pi3 up and running the first we need is to keyword the version of PostgreSQL we want to use by creating a file in /etc/portage/package.keywords/postgresql:

=app-eselect/eselect-postgresql-1.2.1 ~arm64
=dev-db/postgresql-9.5.5 ~arm64


Next we want to select the use flags we want to incorporate:

dev-db/postgresql nls pam python readline server ssl threads zlib


Gentoo has a great quickstart guide that you should look over before continuing to see if you need any additional settings.

Then install PostgreSQL as you normally would:

emerge -av =dev-db/postgresql-9.5.5


On my setup I have a slightly different datadir than the Gentoo default due to migration(s) from other distros and systems, so I had to edit /etc/conf.d/postgresql and change the line 'DATA_DIR="/var/lib/postgresql/9.3/data' to 'DATA_DIR="/var/lib/postgresql/9.3/main"'. If you are doing a fresh install you will not likely need to change this.

Now we need to initialize the database:

emerge --config dev-db/postgresql:9.5.5


If you need to make changes to the default configs, now is the time to do so. For me I had existing configs to copy over.

For streaming replication I followed the official streaming replication guide and official binary replication guide to get it all up and running on my previous setup.

Finally, we will set postgresql to start at boot and start the service:

rc-update add postgresql-9.5 default

service postgresql-9.5 start


We can check the status on the master with the following psql command:

postgres=# select * from pg_stat_replication;
pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | backend_xmin | state | sent_location | write_location | flush_location | replay_location | sync_priority | sync_state
-------+----------+-------------+------------------+----------------+-----------------+-------------+-------------------------------+--------------+-----------+---------------+----------------+----------------+-----------------+---------------+------------
30872 | 19764 | replication | walreceiver | 192.168.13.203 | | 38556 | 2017-04-12 03:52:50.486721-07 | | streaming | 15C/A80133C0 | 15C/A80133C0 | 15C/A8012E38 | 15C/A8012E38 | 0 | async
(1 row)


That's about all there is to it!

Raspberry Pi 2 as a Zabbix Server

I was running a Zabbix server in a VM with 4G of RAM and 4 CPUs. One day I was looking at resources being utilized and realized the VM was way overkill. This was on my mind for a while and one day I was wanting to migrate several VMs off of one physical server to another and one of those happened to be the Zabbix server and I thought it would be nice to put that on it’s own dedicated machine and not on the same hardware it was being used to monitor. Plus, I’m always on the lookout for new projects involving Raspberry Pis, Linux, and other related things.

My monitoring needs are low: I monitor a total of 30 devices/VMs/machines. I use PostgreSQL as my database of choice which is running on its own VM, this is important for this project as it removes one of the resource consumers leaving us with only needing to run Zabbix and Apache.

At this point in time it no longer makes sense to do a new install using Zabbix 2.x, so I will be using the latest stable Zabbix 3.0.x here. I also run Gentoo on all of my machines and installation will not be covered here because Gentoo has a great wiki covering Gentoo on Raspberry PiGentoo on Raspberry Pi. I also use OpenRC and refuse to use SystemD; However, this guide would be the same regardless of the init system used with the exception of the service and rc commands.

The first step is to keyword Zabbix on arm by creating a file (or editing an existing one) in /etc/portage/package.keywords/zabbix with the following line:

net-analyzer/zabbix **


Next we need to select our use flags by creating a file (or editing an existing one) in /etc/portage/package.use/zabbix with the following line:

net-analyzer/zabbix agent curl frontend ipv6 -java -ldap libxml2 -mysql -odbc openipmi -oracle postgres -proxy server snmp -sqlite ssh ssl -static
app-eselect/eselect-php apache2
media-libs/gd png
dev-lang/php xmlreader gd sysvipc bcmath postgres truetype apache2 xmlwriter sockets


Now we can install Zabbix and Apache along with their dependencies:

emerge -av zabbix apache


This will take a while and for me was aided by setting up distcc and crossdev on another machine.

Once the emerge is finished we need to enable the Zabbix web frontend with webapp-config:

webapp-config -I zabbix 3.0.8


Be sure to replace “3.0.8” with the specific version you emerged.

Next we need to enable PHP in Apache by editing /etc/conf.d/apache2 and adding “-D PHP” to the APACHE2_OPTS.

Now we need to start Apache:

service apache2 start


At this point you should be able to configure Zabbix like normal following the official guide. Once you have finished with your Zabbix configuration you need to enable and start the Zabbix agent and Zabbix server:

rc-update add zabbix-server

rc-update add zabbix-agentd

service zabbix-server start

service zabbix-agentd start


That’s about all there is to the install. As for resource usage, here are some stats from mine:

# free -h
total used free shared buff/cache available
Mem: 925M 54M 453M 10M 417M 846M
Swap: 1.0G 0B 1.0G

top – 09:30:13 up 58 min, 1 user, load average: 0.00, 0.04, 0.05
Tasks: 137 total, 1 running, 136 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.9 us, 1.2 sy, 0.0 ni, 97.7 id, 0.1 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem : 948016 total, 462944 free, 57204 used, 427868 buff/cache
KiB Swap: 1048572 total, 1048572 free, 0 used. 865836 avail Mem


That about covers the basics and should be enough to get you up and running!