Nagios plugin: monitor a systemd service

Here’s a tiny plugin to check if a systemd service is running:

#!/bin/bash
#
# машины
# 
# Check a if a systemd service is running
# 
# Usage: $0 
#
#Nagios exit codes
OK=0
WARNING=1
CRITICAL=2
UNKNOWN=3

SERVICE=$1

# Check service status

systemctl -q is-active $SERVICE
if [[ $? -ne 0 ]]; then
    echo "ERROR: service $SERVICE is not running"
    exit $CRITICAL
fi

echo "OK: service $SERVICE is running"
exit $OK

Changing sender’s email address in Nagios

By default settings, Nagios will send email notifications as nagios@localhost, identified by $ADMINEMAIL$ macro.

If you want to change this behavior, you need to set the email address you want to use in the nagios.cfg file:

# ADMINISTRATOR EMAIL/PAGER ADDRESSES
# The email and pager address of a global administrator (likely you).
# Nagios never uses these values itself, but you can access them by
# using the $ADMINEMAIL$ and $ADMINPAGER$ macros in your notification
# commands.
admin_email=nagios@localhost
admin_pager=pagenagios@localhost

Continue reading

VMware Remote Console 10.0.1 on Fedora 26

Welcome back to my (almost) daily appointment with “What’s wrong with Fedora today?”.

At work, our servers are VMs on a VMware vSphere; we access them using SSH of course, but sometimes we need to use the remote console from the vSphere Web Client (that is a vmrc link). I upgraded my kernel (and many libraries) last week but since I don’t use vSphere that often, I didn’t noticed anything until a couple of days ago, when a RAM stick failed and our machines crashed, rebooting in emergency mode.

Usually you login, select your VM, click on Launch Remote Console and you’re done. Unfortunately I got this:

reason       appLoader killed by signal 11
cmdline      /usr/lib/vmware/bin/vmrc
executable   /usr/lib/vmware/bin/appLoader
[...]
os_release   Fedora release 26 (Twenty Six)
kernel       4.12.11-300.fc26.x86_64

Continue reading

Fedora 26 and HTML5 video codecs

I upgraded to Fedora 26 weeks ago but I realize only today that I was having issues playing videos in Firefox, while I was trying to attend an online course.

At first I thought it was Flash Player’s fault: I always forget to have it and I always forget to update it. It was indeed out-of-date but the annoying “The media could not be played” error message was still there.

After a quick research and a little help from HTML5test, I noticed that few codecs were missing. I prefer not to install a bunch of codecs that I don’t even know what they’re for; if I am missing something I’m pretty sure it’ll come out! Continue reading

Using fingerprint authentication on Fedora 26

I’ve never ever had any problem using fingerprint authentication on openSUSE 42.1, it worked just out of the box, but when I switched back to Fedora (again), I had some issues configuring it.

On Fedora 26, by default, fingerprint authentication works only for logins but not for sudo. To enable this:

authconfig --enablefingerprint --update

If you’re using an older version of Fedora you can also use:

authconfig-tui

Continue reading

Flushing iptables

You can flush and reset iptables to default running these commands:

iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

The -F command flushes all the chains and -X deletes empty (non-default) chains.
You can also create a script:Continue reading

Using sudo without password

When you issue a sudo command you will be asked to type your password to execute it and this can be quite annoying, especially for people like me that open the terminal every 3 minutes and don’t want to login as root every time.

To solve this “problem” you need to edit sudo’s configuration file, located in /etc/sudoers, but it’s not recommended to do it directly. To modify this file, you have to use visudo that makes a temporary copy of the sudoers file and checks for errors before saving.Continue reading