Today one of our developers came to me to discuss a problem and I wanted to show him something on one of our Linux machines. To check a process, I ran pstree
and noticed that the formatting of the output was all wrong:
simon@atlas:~$ pstree
initââ¬âacpid
ââapache2âââ10*[apache2]
ââatd
[..]
âârsyslogdâââ3*[{rsyslogd}]
ââsshdââ¬âsshdâââbashâââping
â ââsshdâââbashâââpstree
â ââsshdâââsshdâââsh
ââudevdâââ2*[udevd]
This is obviously just a cosmetical problem and the output is quite hard to read. When encountering something like this, the first guess would be that the encoding is somehow wrong. When checking the environment variables with env
, we find that LANG is set to “en_US.UTF-8”.
Read the rest of this entry
For a proof-of-concept, I had to install a new Mantis Bug Tracker instance and after finishing the installation, the login screen greeted me with the following warning:
SYSTEM WARNING: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead
The solution is amazingly simple. The only thing that I needed to find out was that this is a PHP error and not a MantisBT error. So after that was settled, I went on and just followed the instructions given by the warning:
Read the rest of this entry
For an university assignment, I had to implement a recursive function to calculate the digit sum of a given number. I place my solution here for my own reference:
public static int digitSum(int n) {
if(n < 10)
return n;
else
return n % 10 + digitSum(n / 10);
}
This code can also be found in the GitHub repository that I am keeping for university: ChecksumTool.java
When comparing floating-point numbers (float, double) in Java, we quickly discover that we get roundoff errors. This has to do with the limited precision of Java floating point variables. The following code example shows the problem at hand:
double r = Math.sqrt(2);
double d = r * r - 2;
if (d == 0)
System.out.println("sqrt(2) squared minus 2 is 0");
else
System.out.println("sqrt(2) squared minus 2 is not 0 but " + d);
Theoretically, d
should be 0, but because we have limited precision (see the documentation on primitive data types) there will be a difference:
sqrt(2) squared minus 2 is not 0 but 4.440892098500626E-16
One possibility to circumvent this problem is to define a constant value (the following example uses EPSILON
). We then check if the difference is smaller than that constant value. Since we received a very small number (4.4E-16) above, we can use 1E-14 as the value of our constant:
Read the rest of this entry
In the last few weeks I reworked our internal Nagios configuration and added a few checks to some of our internal servers. Since we do not have a dedicated SAN for our environment, we are using iSCSI as a low-cost storage solution. However, the Microsoft iSCSI Initiator implementation sometimes has trouble connecting to the iSCSI target. As a result, we had to monitor the iSCSI Initiator.
So here is our implementation of check_iscsi for the Microsoft iSCSI Initiator. It uses the iscsicli utility provided together with the iSCSI Initiator and runs on the remote server. To use it, place the following batch file in the scripts/
folder of your NSClient++ installation.
Read the rest of this entry
One excellent tool for Systems Management on Windows is the Windows Management Instrumentation (WMI), which allows you to remotely execute commands and query parameters on a Windows Host. Of course, all modern Windows systems have the WMI Client installed, but what about the Linux clients?
To get the same functionality on a Linux system (I am using Debian in this example), we need to get the following two packages from this website:
Read the rest of this entry
To monitor our software, we use the free Nagios supervision system fitted with custom checks for our application. This way, we can make sure that not only the Operating System is properly monitored but also the core components of our application including the Application Server and the Oracle Databases.
Today I tried to update to the latest version of Nagios 3.3.1 on one of our supervision servers running Ubuntu Server. So I downloaded the package, ran “./configure” and ran “make fullinstall“. I then stumbled upon the following (quite meaningless) error:
/usr/bin/install: omitting directory `includes/rss/extlib'
/usr/bin/install: omitting directory `includes/rss/htdocs'
/usr/bin/install: omitting directory `includes/rss/scripts'
make[1]: *** [install] Error 1
make[1]: Leaving directory `/tmp/nagios-3.3.1/nagios/html'
make: *** [install] Error 2
root@watchtower:/tmp/nagios-3.3.1/nagios#
Phew. Alright, using my trusty friend Google I quickly discovered a thread on ubuntuforums.org with the solution.
Read the rest of this entry
Lately, I have seen a few personal sites that redirect /+ to the personal Google+ profile. I thought “What a good idea!”. Sadly, my quick search on Google itself only showed how to do it with Apache (see here for example). Since I am using lighttpd this obviously does not work for me.
So here is how to do it with lighttpd:
$HTTP["host"] =~ "(^|\.)krenger\.ch" {
# Redirect /+ to Google+
url.redirect = ( "^/\+" => "https://plus.google.com/115712438575389450995/about")
}
The Linux kernel provides the tmpfs, which basically creates a file system in memory. This temporary file system can be used to store temporary data, such as caches or log files. Read more about tmpfs in the kernel documentation: tmpfs.txt
After reading this excellent article about using tmpfs in Linux, I decided to put it to the test. Even though the Linux kernel already does a good job caching files, I wanted to see the performance of this solution by applying different loads on it. For this, I am using the IOzone tool I already used for my ZFS tests (1) (2) and my Amazon EC2 IO test.
Read the rest of this entry