Tag Archives: arch linux

The pain of Nagios and Arch Linux

Or, there’s more to systemd than just service files.

I recently had cause to investigate writing a simple Nagios http monitor and although I’ve worked in and around Nagios I’ve not really had cause to try writing the monitor scripts.

There was an aspect of the task I wasn’t too sure about so I thought the best way to get to grips with fully understanding  the environment would be to try and get Nagios running on my desktop system.

Moral of the story: there’s a reason why Arch will never be used in an enterprise environment.

First, I should have been warned off by seeing that nagios for Arch only comes via the AUR.

But, there’s a reasonably detailed page describing it. The real problems came with nginx, php-fpm and fastcgi.

The php-fpm service isn’t enabled or started by default: systemctl soon fixes that.

For some bizarre reason, it turned out that although nginx had been configured to use /usr/share/nagios/share and the root directory for PHP scripts, it was trying to access PHP scripts in /etc/nginx/html/nagios. I had to cheat here and just created a symbolic link between the directories which got the basic page displaying.

But then to get the CGI scripts running I had to look more closely at the Arch nginx configuration for fcgiwrap and having seen that the fcgiwrap service wouldn’t run, I finally twigged that nginx was referring to a .sock file and that there was a systemd socket file.

So I now have Nagios running on Arch. Mostly.

Tomorrow I need to figure out the cause of these errors:

Error: Could not read object configuration data!

But at least we’re now dealing with Nagios problems rather than Arch.


Places of interest


Arch Linuxdeveloper signature errors

Every now and then when applying updates to my Antergos (Arch) Linux desktop I get an error like

$ sudo pacman -Syyu
error: libvirt: signature from "Christian Rebischke (Arch Linux Security Team-Member) <Chris.Rebischke@archlinux.org>" is unknown trust
:: File /var/cache/pacman/pkg/libvirt-4.6.0-3-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n]

Accepting the default option means the update fails. If using the GUI client there’s just a message saying the update failed with no further explanation

It is fixed by

$ sudo pacman -S archlinux-keyring

This kind of error is one reason why I’d never consider using Arch in a work environment.

Reference: https://www.reddit.com/r/archlinux/comments/900cxa/upgrading/


PhusionPassenger with Nginx for Rails – nearly worked

Now, I have a great deal of time for the PhusionPassenger module used to proxy Rails (and other framework) applications into a web server and I suspect the problem is that I’m doing something wrong; this is the first time I have tried it on Nginx.

I followed the guides at https://www.phusionpassenger.com/library/deploy/nginx/deploy/ruby/ and https://wiki.archlinux.org/index.php/Ruby_on_Rails but after configuring everything for my Rails app, I just get the ‘Welcome’ page. The Passenger processes are running although the logs seem to suggest otherwise.

There’s also a problem with scaling Nginx: with Apache we can define sensitive application parameters (such as database password and secret key) as environment variables for each vhost. Nginx doesn’t support this way of working which has to make code deployment harder for a single site let alone multiple vhosts.

I know the app is working because it starts from the console with ‘rails s’.

I’m probably on firmer ground with Apache providing Rails apps so I will give that a go instead; Passenger is a joy to install this way. While Nginx is hip and funky, I think I need the maturity and stability that you can only get with Apache httpd.

Arch Linu MySQL (Mariadb) startup

Posted as a quick note-to-self following a delay getting a database up and running for a rehash f an old Rails project.

After installing the mariadb package on Arch, the database needs to be initialised before starting,

# mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

After this, the database server can be started with,

# systemctl start mysqld.service

(Still can’t say that I’m happy with systemd; I just can’t see what problem it’s trying to solve).

https://wiki.archlinux.org/index.php/MySQL provided the much-appreaciated help and guidance in this case.

Bulding the SD card imge for Arch

For this part of the process, and as a follow-up to my previous post, I will be using the beautifully clear and concise post at http://serverfault.com/questions/281628/combine-partitions-to-one-disk-image.

I have two filesystem images that I want to combine into a single 16G image file. The above post mentions kpartx and I made the mistake of thinking that it was a KDE version of parted (!) except that it doesn’t work with the -av options.

A wee bit of digging hinted at kpartx being part of the multipath-tools package, but pacman couldn’t find it.

A quick word with one of my kids (who is more of an Arch whizz than I) suggested that the problem was that multipath-tools is part of the AUR (Arch Use Repository) and can be installed using the command,

$ yaourt -S multipath-tools

Note, as a unprivileged user. So we continue with the process.

# truncate --size 16G r-pi-16gb.img
# fdisk r-pi-16gb.img

With two partitions: 100M and 15.9 G.

# kpartx -av r-pi-16gb.img 
add map loop2p1 (254:0): 0 204800 linear /dev/loop2 2048
add map loop2p2 (254:1): 0 33347584 linear /dev/loop2 206848
# dd if=rpi-arch-root.img of=/dev/mapper/loop2p1 bs=1M
100+0 records in
100+0 records out
# dd if=rpi-arch-ext4.img of=/dev/mapper/loop2p2 bs=1M
dd: error writing ‘/dev/mapper/loop2p2’: No space left on device
16284+0 records in
16283+0 records out
17073963008 bytes (17 GB) copied, 509.39 s, 33.5 MB/s

Not what I was expecting. I have checked my sums and they all seem to match up: the ext4 image is 15.9 GiB (16284 M) and the combined size should match the 16G image file.

A closer check of fdisk does seem to highlight a discrepancy:

  • r-pi-16gb.img2 has 33347584 sectors for 15.9G
  • rpi-arch-ext4.img: 15.9 GiB, 17075011584 bytes with 33349632 sectors

So, perhaps the problem here is because there is an offset at the start, but extending the 16G disk image won’t work because that is then bigger than the size of the SD card. Back to the drawing board and out with the calculator.