Nagios plugin script written in Bash to check the master-slave replication in PostgreSQL (tested on PostgreSQL 9.2.4) (executed on the slave). The script will report how many bytes the slave server is behind, and how many seconds ago the last replay of data occurred. The script must be executed as ‘postgres’ user. #!/bin/bash # $Id:…
Recursive Inotify Daemon
There aren’t many Inotify daemons available that can work recursive and offer a descent flexibility regarding Inotify signals. For basic rsync operations, lsyncd isn’t that bad but it isn’t that flexible for system administration. The fact that it is written and configured in Lua, makes it actually really complex (considering that you don’t know to…
Backup to free Hetzner FTP
If you have a hosting account at Hetzner with free backup space, you can not access this backup volume using rsync. One way of creating a simple backup, is by using the tar command with the incremental option. You will also want to encrypt these backup files and one easy to do this, is by…
Check if a NFS share is mounted
Below is a small Perl example how to check for NFS mounted shares on a Linux host. The script does not need any specific modules, and makes use of the /etc/mtab file. #!/usr/bin/perl use strict; use warnings; my @mount_points = do {local @ARGV = ‘/etc/mtab’; }; foreach my $mnt (@mount_points){ next unless $mnt =~ /nfs/;…
Changing file permissions in Perl
There are definetly a few modules on CPAN which will allow to easily change file permissions in Perl, but you do not always have the chance or possibility to install CPAN modules. The following examples explain how to change the original file permissions to either remove or set new permissions. One way of doing this,…
Secure MySQL Backups with GnuPG
One way to secure your MySQL backups, is to encrypt the backup file using PGP/GnuPG. Of course you will need to own a PGP/GnuPG private key, which can be easily created using the PGP/GnuPG tools. On a Debian/Ubuntu Linux host, install the ‘gnupg’ package. # apt-get install gnupg After installation, generate a PGP/GnuPG key using…
Resize a LVM partition in a Debian VMWare VM
It can happen that a VMWare virtual machine (VM) runs out of space after a certain amount of time. If the installed Debian Linux (actually any kind of Linux) has been set up with LVM, resizing the partition is fairly easy. This article assumes that the VM has been installed with just one root partition,…
Watch a directory for uploaded files
In some situations, you need to watch a directory for uploaded files and move/process them immediately. Many scripts work in a polling kind of way, which will check every x amounts of seconds for new files. This is nowadays completely out of fashion and generaly not cool. A real watcher script uses the OS’s built-in…
dmesg with human readable timestamps
When you are not using Debian unstable or some kind of Linux distro that hasn’t got the latest version of the dmesg command, you will not be able to execute ‘dmesg -T‘ to see human readable timestamp in the output. A small Perl script does the trick: #!/usr/bin/perl -wn use strict; foreach my $line ()…
Finder and Samba share support
I’ve answered a question on StackOverflow (actually on SuperUser) regarding Finder and Samba shares on Ubuntu Linux. It’s only Ubuntu which has this problem, Finder works perfect with Samba when that Samba is installed on Debian, CentOS, … http://superuser.com/questions/283863/force-finder-to-log-in-as-guest-to-a-smb-share/300382#300382