bookmark_borderRead Manga on Amazon Kindle and other eReaders

Do you like Manga? Do you also like to use eBook readers for reading text based books? Well, today you can combine these two things. With the help of the right tools you can bring your Manga on Amazon Kindle or any other eBook reader of your choice. This article gives you a step-by-step guide how to get your Manga books eReader ready.
This tutorial should also work for Comics. However, I’m a Manga reader and therefore don’t have a Comic ready to test. This means that this article focuses on Manga on Amazon Kindle / eBook readers only.

Why not just a tablet?

It’s correct that the most easiest and viable option would be to buy a 8-inches or 10-inches tablet. For e.g. the Amazon Kindle Fire HD 8 or Kindle Fire HD 10 would be a cheap and viable option. However, personally I don’t like to stare at an LCD or IPS display all the time while reading. It’s simply too straining for my eyes. E-Ink displays are the complete opposite. They are great for reading and give you a feeling that you’re actually reading a book. You can also read with these E-Ink screens outside. You will have zero reflection. Also, the battery is lasting much longer with one load cycle than a tablet.
In summary we can say, that tablets can be used for a lot of things like watching videos, listening to music, browsing the web and reading Comics and Manga. eReaders on the other hand are designed for one thing: Reading books. The biggest benefit for the eReaders are the display and the long lasting battery. However, you have to decide on your own if you want a multi purpose device or a device which does only one thing but gets this done right.

Can every eBook reader render Manga correctly?

There are some limitations when it comes to the eReader you should use. When I’m talking about Manga on Amazon Kindle or other eReader devices, I’m talking about the HD variants. While you can convert your Manga to a first gen Amazon Kindle for example, it will be difficult to almost impossible to read the Manga. The reason for that is, that the resolution of the screen from the earlier Kindle and eBook readers isn’t able to show that much pixels in order to render the pictures and fonts in a way a human eye can read it. I for myself am a Tolino Shine 2 HD user. This device has a 300 ppi screen and renders the Manga books perfectly. Devices with a similar or even better resolution like a Tolino Shine 2 HD for example are:

There are plenty other readers and this list is just a short overview of possible alternatives. Pick the one which suits best to you (if you haven’t one already). But keep in mind that the most important thing is an HD display (300 ppi / DPI) to get your Manga rendered correctly.

Kindle Comic Converter makes Manga and Comics eReader ready

Now that you’ve your eBook reader of choice ready, we can start converting the Manga. For this we use a tool which is called Kindle Comic Converter. This tools does not comes from Amazon nor does the developers have anything to do with them.
But why would you even want to convert the Manga before transferring them to your eReader? For the Amazon Kindle devices this answer is simple. The most Manga are published as a PDF or ePub file. These file types aren’t supported by the Amazon Kindle eBook readers. Therefore, you have to convert it into a so called MOBI file. But the most important reason is to resize the Manga to the screen size of your eBook reader. If you transfer your Manga to your eBook reader and simply start reading it, the Manga doesn’t automatically fits itself to the screen size of your eBook reader. Look at this picture for example where a unconverted ePub files is opened by a tolino shine 2 HD:

Manga on Kindle not optimized
Not optimized Manga on a tolino shine 2 HD (click to enlarge)

As you can see, the Manga is cut in halves due to the screen size. The rest of the Manga simply didn’t got rendered. And this is where Kindle Comic Converter comes into play. With the help of this tool you will be able to get a result like this:
Manga on Kindle optimized
Same page but optimized on a tolino shine 2 HD (click to enlarge)

Kindle Comic Converter is a free and open source software which converts CBZ, PDF, ZIP, RAR and a list of JPEG pictures into an ePub or MOBI format. It’s available for Windows, Linux and Mac OS X. The following chapters are covering how to install and use it.

Installation of Kindle Comic Converter

The installation of the Kindle Comic Converter software is rather simple. The following chapters are describing how to install under Linux, Windows and Mac OS X.

Linux

If you are a Debian, Linux Mint or Ubuntu user, you can download the Debian package for your distribution version from the official homepage and install it like that:

user@machine:~$ sudo dpkg -i kindlecomicconverter_5.4.5_distri_amd64.deb
user@machine:~$ sudo apt-get -f install

However, the following method works for all Linux distribution. It downloads and installs automatically all dependencies which are needed. The only requirement is that the Python package installer for Python 3 is available on your system. But in order to get all features of the Kindle Comic Converter software working, we also install the packages unrar and p7zip. These two packages allows Kindle Comic Converter to extract ZIP and RAR based files. For openSUSE simply enter this:

user@machine:~$ sudo zypper ref && sudo zypper in python3-pip unrar p7zip

For Debian, Linux Mint and Ubuntu you can install it with this command:

user@machine:~$ sudo apt-get update && sudo apt-get install python3-pip unrar p7zip-full

Now that you’ve installed the Python package installer, you can finally install Kindle Comic Converter as well. This command is equals on every Linux distribution:

user@machine:~$ sudo pip3 install KindleComicConverter

After some minutes or seconds (depending on your internet speed), the installation is finished and you can enter the kcc on command line in order to start Kindle Comic Converter.

Windows

As a Windows user you may already be used to download and install software with a typical installer. The Kindle Comic Converter software also comes with such a installer. Simply download the installer from the official homepage and click yourself through the installation process.

Mac OS X

You can download the Mac OS X dmg file from the official homepage. After the download is finished, you can open the downloaded file and drag the content into your applications just like with the other software you’ve installed.

Only for Kindle users: Download and install kindlegen

kindlegen is an additional piece of software which allows the Kindle Comic Converter software to convert the output to a so called MOBI file. MOBI is the proprietary format that Amazon uses on their Kindle devices. This also means that this software is only needed if you’re using an Amazon Kindle eBook reader.
In order to install kindlegen on your PC or Mac, you have to download it from here for your operating system and move it to the following places:

  • For Windows: If you’re a Windows user, extract the downloaded ZIP file and move the kindlegen.exe into the directory where you installed Kindle Comic Converter. By default this directory is  C:\Program Files\Kindle Comic Converter. Restart Kindle Comic Converter if it’s actually running.
  • For Linux: As a Linux user, you have to extract the GZ archive and move the binary to the directory /usr/local/bin. This can done on command line easily:
    user@machine:~$ wget http://kindlegen.s3.amazonaws.com/kindlegen_linux_2.6_i386_v2_9.tar.gz
    user@machine:~$ tar xfvz kindlegen_linux_2.6_i386_v2_9.tar.gz
    user@machine:~$ sudo mv kindlegen /usr/local/bin
  • For Mac OS X: Amazon also provides kindlegen for OS X. However, I’m unable to do more testing here because I don’t have a Mac (anymore). The developer of Kindle Comic Converter recommends using the homebrew installer brew to install kindlegen on a Mac OS X device. Enter the following command in order to install kindlegen with brew:
    user@osx:~$ brew cask install kindlegen

Convert Manga to ePub format

Now that you have everything prepared you can finally start converting your Manga into a ePub format suiting to your eBook Reader. To do so, start Kindle Comic Converter. For OS X and Windows simply start the application as you’re used to. For Linux, simply enter the command kcc on the command line. You should see a window which looks like this:

KCC start window
KCC start window

To convert a PDF, CBZ, CBR, ZIP or RAR file, click on Add file and select the Manga you want to convert. As already mentioned a lot of Manga are published either as a PDF or CBZ file. However, if the Manga you want to convert is already a ePub file, simply change the ending .epub into .zip. You will then be able to add the renamed file to Kindle Comic Converter.
After adding a file, you have a various list of options to choose from. The first one is the option to the left hand of the Convert button. Here you can choose a device where you want to convert the Manga for. There are a various of presets available for many Kindle and Kobo devices. If your device isn’t listed you can always choose the option Other. If you choose the Other option you can set a custom width and height at the bottom. Enter the resolution of your eBook reader here.
Another option you have to set in order to read the Manga on your eBook reader is the Manga mode. This mode adds support for right-to-left reading which is absolutely necessary for any Manga of course.
The right drop down menu next to the Convert button is the output file format. If you have an Amazon Kindle device it’s recommend to choose the MOBI/AZW3 option here. If you’re a tolino, NOOK, Pocketbook, etc. user you should choose ePub instead.
All other settings can be ignored for now. They are providing additional features which aren’t needed in order to get a Manga readable on an eBook reader. You can finally click on Convert. You will then see a dialog where you have to select the destination path for the output file.
Note: The developers are providing a Wiki page where a lot of users already reported which settings would be optimal for specific eBook readers. You can checkout it out here. Your eBook reader is maybe already listed there as well.

Transfer your converted Manga to your eReader

For non Kindle users, this is business as usual. Most of the modern eReaders are shown as a USB storage device when you connect them to your PC or Mac. Simply move the created ePub to the eReader via your file browser and that’s it. The Manga should pop up within a second in the library of your eReader.
As an Amazon Kindle user however, you have two options:

  1. You can use the „personal“ mail address of your Amazon Kindle device. Just mail your MOBI file to the given address. It should pop up within a few minutes as long as your Kindle device is connected to the internet. You can see the mail address of your Kindle device under the settings menu. Most of the times it starts with your first name combined with a random number and ends with @kindle.com.
  2. Use a tool like Calibre to send your files to your Kindle. Calibre is a eBook suite which can be considered as a virtual shelf for eBooks. Calibre itself supports converting to different file formats which are eBook reader friendly like ePub. Calibre is also free and open source software.

Where to buy eBook Manga?

While going into a store to buy the Manga you want to read is easy and self explaining, the question „Where can I buy Manga eBooks?“ is something that has to be answered. One valid option for almost every country is Amazon. Amazon offers a wide range of Manga eBooks. Even older volumes are published here again digital. Buying on Amazon works great as long as you’re an Amazon Kindle user. If you’re like me and you use another eReader you would have to download the Manga onto your computer, convert the .mobi file extension into an ePub and convert it from there on. I’ve seen some people posting that Amazon also offers PDF based Manga. However, I can’t confirm nor deny that right now.
But besides Amazon there are also other vendors available. For US customers, Barnes & Nobles are offering eBook based Manga and Comics. In Germany there are vendors like buecher.de and thalia.de which are both selling eBook Manga and Comics. But that’s just a very short list. There are even more alternatives available. Even the Humble Bundle comes up with a Manga and Comic eBook bundle from time to time. The last bundle included over 30 Manga volumes for just 18$.

Conclusion

As someone who collects video games, I understand that someone who is really passionate when it comes to collecting Manga or Comics buying digital isn’t an alternative. For me as someone who just likes to read Manga, the digital way of reading them is a more handy, cheaper, ecological and space saving solution. For everyone who doesn’t care if the Manga is digital or physical, I really recommend you to check out an eBook reader for reading Manga. Sadly I’m unable to tell if a 6″ to 7″ eReader is also acceptable for comics. I will most likely test this in the future but I guess that the experience isn’t the same because of the missing colors with the e-Ink displays (there are no eReaders with e-Ink displays available as of today).
What do you think about digital Manga or Comics? Do you see this as a viable option? Or do you stick to the physical version? Let me know in the comments section below.

Further links

bookmark_borderDump / save a PostgreSQL output

PostgreSQL is one of the most used open source database solutions besides MariaDB / MySQL. Even though they have some similarities, PostgreSQL is based on a object-relational database management system while MariaDB and MySQL are relational database management systems.
This article is about how to save a PostgreSQL output. While you can use the command mysqldump to dump your MariaDB or MySQL database, saving an output with PostgreSQL is a little bit different and doesn’t require an extra tool.

Switch to the database

First and foremost we have to change / go to the database. In Linux you also have to be the PostgreSQL system user in order to work with the database. To change the user just use sudo:

user@machine:~$ sudo -u postgres /bin/bash

You are now the user postgres. You can see this at the beginning of your command line. Instead of your username you can now see postgres@ at the beginning of the line. As next we use the psql command to switch into the actual database we want to dump:

postgres@machine:~$ psql database
psql (9.3.14)
Type "help" for help.
database=#

You are now connected to the database. Don’t forget to replace database with the desired database you want to connect to.

Save a PostgreSQL output

To finally save an output you can use normal SQL statements which are returning your desired value and wrap this command within a COPY statement. The following example saves the output of an PostgreSQL statement in the file output.txt which will be located in /tmp:

database=# COPY (select firstname, lastname from user_table) TO '/tmp/output.txt';

Save a PostgreSQL output as CSV

You can also define in which format the output should be saved. You can save the output as a CSV file so that you will be able to easily work with the output within LibreOffice or MS Office for example. The following example saves the same output as in the example above, but uses CSV with semicolons as a format:

database=# COPY (select firstname, lastname from user_table) TO '/tmp/ouput.csv' (format csv, delimiter ';');

Exit database / psql command

To exit the database access and therefore the running psql command, simply enter \q to quit.

Final words

As you can see, saving / dumping PostgreSQL output directly into a text file even as a CSV file is a great feature. No extra tools needed. But PostgreSQL comes with much more than just dumping output to test and CSV files. Even the COPY command can be modified with a lot of other different settings. A good book about PostgreSQL is PostgreSQL: Up and running by Regina Obe and Leo Hsu. It covers a lot of other things besides dumping output from PostgreSQL as well.

bookmark_borderHow to setup a 7 Days to Die server under Linux

Setting up a 7 Days to Die server under Linux isn’t as difficulty as you may think. The Steam developer Valve is providing a tool which makes it easier, even for people who aren’t that familiar with the Linux command line. This article is covering how you setup your own 7 Days to Die server under a Ubuntu or Debian installation.

About 7 Days to Die

7 Days to Die is a zombie apocalypse survival crafting game which has been initially released in December 2013. The game is still in a „Early Access“ stage. 7 Days to Die is similar to Minecraft in the way it is played, but provides better graphics and a different scenario. There are also some quests included like treasure hunting. In the latest version (as of written in June 2018) the developer The Fun Pimps also integrated vehicles into the game. Like in Minecraft, the real fun with 7 Days to Die starts when you start playing with friends. Surviving, building and creating in a random generated world can bring you hours of fun and a long lasting motivation to go on in the things you wanna achieve.

Install requirements

On a freshly Debian or Ubuntu installation, we need to install some requirements in the first place. With the following command we will update the package repositories and install the necessary requirements:

user@machine:~$ sudo apt-get update && sudo apt-get install screen wget

Adding 32-Bit libraries

The Steam command line tool is only available as a 32-Bit program. As of today most of the systems are 64-Bit based. Ubuntu for e.g. isn’t even supporting 32-Bit anymore. If you’re running an 32-Bit system, you can skip this part. To find out if you have a 32-Bit system installed, just issue the following command on your system:

user@machine:~$ arch

If the output of this command is i386 or i586, you have a 32-Bit system. If it’s x86_64 you’re using a 64-Bit system. In this case you have to issue the following two commands as well:

user@machine:~$ sudo dpkg --add-architecture i386
user@machine:~$ sudo apt-get update && sudo apt-get install lib32gcc1

This installs the lib32gcc1 file which is a 32-Bit library. This library is needed by the Steam command line tool. If this library isn’t installed, the following commands will fail.

Download and extract Steam

As next, we acquire the Steam command line tool for Linux machines in order to download the server files via the Steam network. Before that we create a separate folder (which is called steamcmd) were we are going to download the Steam command line tool to:

user@machine:~$ mkdir steamcmd
user@machine:~$ cd steamcmd
user@machine:~/steamcmd$ wget http://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz

The wget command is now downloading the Steam Linux command line tool. After the download is finished, we can extract this tool (it is compressed right now) like this:

user@machine:~/steamcmd$ tar -xvzf steamcmd_linux.tar.gz

Updating the Steam tool

You can now start updating the Steam tool. Execute the following command to start the update:

user@machine:~/steamcmd$ ./steamcmd.sh

This process will take some time. In the meanwhile, you will see a lot of output on the console like this:

Redirecting stderr to '/home/user/.steam/logs/stderr.txt'
ILocalize::AddFile() failed to load file "public/steambootstrapper_english.txt".
[ 0%] Checking for available update...
[----] Downloading update (0 of 13.028 KB)...
[ 0%] Downloading update (38 of 13.028 KB)...
[ 0%] Downloading update (38 of 13.028 KB)...
[ 0%] Downloading update (38 of 13.028 KB)...
[ 0%] Downloading update (38 of 13.028 KB)...
[...]

When the process is finished you will see a output which looks like this:

Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam API...OK.
Steam>

The last line Steam> tells you that the Steam command line tool is actually opened and Steam waits for you to enter a command.

Login into Steam

When using the Steam command line tool, you have to login just like with the graphical desktop version. Enter the command login followed by your Steam username to login. Steam will then ask you for your password and Two Factor Authentication (if enabled). When you enter your password there will be no input shown. But this is normal, just like in almost every Linux / UNIX software:

Steam> login <USERNAME>
Logging in user '<USERNAME>' to Steam Public...
password:
Enter the current code from your Steam Guard Mobile Authenticator app
Two-factor code:XXXXX
Logged in OK
Waiting for user info...OK

Download and install the 7 Days to Die server files

Now that you’re logged in, you can finally start downloading and installing your 7 Days to Die server. With the first of the following two commands we enforce Steam to install the 7 Days to Die server files into the directory 7dtd_server. The second one is starting the actual installation process of the server files. The number 294420 is the ID for the 7 Days to Die server files:

Steam> force_install_dir 7dtd_server
Steam> app_update 294420

Alternatively, if you want to use the latest BETA of the dedicated server, us the following two commands instead:

Steam> force_install_dir 7dtd_server
Steam> app_update 294420 -beta latest_experimental

This will download the latest BETA experimental branch the developers are providing to the public audience.
You can see again an output which will show you the actual progress:

Update state (0x5) validating, progress: 2.19 (75656327 / 3459239207)
Update state (0x61) downloading, progress: 0.21 (7340032 / 3459239207)
Update state (0x61) downloading, progress: 1.02 (35228112 / 3459239207)
Update state (0x61) downloading, progress: 2.75 (95064875 / 3459239207)
[...]

The app_update commands can take even longer than the Steam update process. It basically depends on your internet connection speed. After this command was successful, you will get yet again another message about it:

Success! App '294420' fully installed.

You can now quit the Steam command line tools by simply entering quit. Congratulations, you successfully downloaded and installed a 7 Days to Die server under Linux.

Configuring your server

You have a lot of options to configure your 7 Days to Die server to your wishes. The file to do so is the serverconfig.xml which is in the same directory as your 7 Days to Die server files. So change into the 7 Day to Die server directory:

user@machine:~/steamcmd$ cd 7dtd_server

Within this directory, there is already an example serverconfig.xml. While this file should work already, you should take at least some tweaks. To edit this file you can use the editor nano:

user@machine:~/steamcmd/7dtd_server$ nano serverconfig.xml

With CTRL+W you can search for a string. With CTRL+O you can save the file. And with CTRL+X you close the editor. The following parameters are a suggestion how you should modify your serverconfig.xml.
[table id=1 /]
You can always come back and change the parameters to your desire. However, you always have to restart the server after each change. For a full list of all possible values, check out this list.

Starting the server

Puh, lot of stuff right? But now the time has come to start your server. In order to have your server running constantly, you have to use screenscreen is a tool which runs programs even while you logged out. But first, ensure that you’re still in the 7dtd_server directory and enter the following commands:

user@machine:~/steamcmd/7dtd_server$ screen -S 7dtd
user@machine:~/steamcmd/7dtd_server$ ./7DaysToDieServer.x86_64 -logfile output.log -configfile=$HOME/steamcmd/7dtd/serverconfig.xml -dedicated

Your server will now start. This can take up to 5 minutes. You get no output when the server is ready. If you want to know more about what is hapenning, take a look at the output.log file within your 7dtd_server directory. To close the screen session (and therefore let the server run in the background), press CTRL+A followed by the D key for detaching. You can now close your remote session to your server without shutting down your 7 Days to Die server itself. If you want to attach to the screen session again, simply enter this command:

user@machine:~$ screen -r 7dtd

You can now start 7 Days to Die on your desktop / gaming machine, click on Connect To Server and enter either die IP address / name of your server (FQDN) and click on the connect symbol or search for your server name in the upper left (if you set your server to public at the step before):

7 Days to Die server connect
Connection field in 7 Days to Die

If you can’t connect at this point, you may have to check your firewall or the firewall on your server (if you use one). On default, the 7 Days to Die server listens on port 26900. This port has to be accessible from the internet.

Stopping the server

To stop your server, simply resume your screen session like this:

user@machine:~$ screen -r 7dtd

And press CTRL+C afterwards. It can take a few seconds up to a minute before the server shuts down.

How to become an admin?

In order to become an admin, you have to tell your server your Steam ID. Otherwise the server can’t decide which player really should get admin rights. To get your Steam ID, simply open Steam, click on your profile and copy the long number within the URL:

7 Days to Die server Steam ID
Steam ID

On your server, change into the following directory and create a file called serveradmin.xml. Open it afterwards with an text editor (we use nano again in this case):

user@machine:~$ cd $HOME/.local/share/7DaysToDie/Saves/
user@machine:~/.local/share/7DaysToDie/Saves$ touch serveradmin.xml
user@machine:~/.local/share/7DaysToDie/Saves$ nano serveradmin.xml

Enter at least the following lines:

<adminTools>
  <admins>
    <admin steamID="12345YourSteamID" permission_level="0" />
  </admins>
</adminTools>

Don’t forget to change the value 12345YourSteamID to your Steam ID! Press CTRL+O to save and CTRL+X to close the file. Afterwards, stop and start the 7 Days to Die server and that’s it. You could even create moderators and give each of them specific rights. However, this would definitely burst this article. If you want to know more about the possible rights management on a 7 Days to Die server, check out this link.

Last words …

As you can see, with a little bit of work you can setup your own 7 Days to Die server on a cheap Linux VPS for example. Of course you could also go with a hosted one and don’t bother about all the setup stuff, but this is way more costly. And if you’re interested in working with Linux machines, this is a good way to learn a little bit about how to maintain and setup server software under Linux in general. If you have any comments, wishes or notes, please let me know down below in the comments.

bookmark_borderMonit: An easy to use monitoring solution for Linux

Besides Nagios, Icinga and check_mk there are some other, more slimmer tools to monitor servers. Especially if you are a private person and you want to monitor your vServer, Raspberry Pi or whatever, you may want to use a smaller and easier monitoring solution than those big three.
This article is about monit. Monit is one of these simple monitoring tool. But just because the configuration is more simple, that doesn’t mean hat you are limited in the ways you monitor your servers with Monit.

How does monit works? And why not just use Nagios?

monit works differently than Nagios or Icinga. While Nagios, Icinga and check_mk needs a monitoring server which connects in given time periods to the machines it checks, monit doesn’t need this kind of server in order to do these checks. So basically that means that wherever you install monit, it checks locally and reports the results via mail.
In the first moment this sounds like a disadvantage whether it be due to reliability or security, but think about it for a second: What does Nagios, Icinga or check_mk basically do? They ping the destination machine and if this ping is successful it opens up an NRPE or SSH connection and executes the given CPU, Ram, service checks and so on, locally. The console output is then used for analysis. If the check exceeds it’s given limit, Nagios / Iciniga / check_mk creates an E-Mail and send it to the user /group of users which is / are responsible for this service. So basically the server executes local commands like monit. The initiator however is not locally, it’s a different (remote) server.
You now may think „but how do I even test if the server is available?“. Well, you just setup another monit instance which is checking if the destination is pingable, just like with Nagios / Icinga / check_mk.
A real benefit for monit is it’s easy configuration and syntax. While you have to dig through a bunch of files in order to create a simple check in Nagios, monit allows you to simply put one (human readable) configuration file in the correct directory and the check is ready to use. In combination with a configuration management like Ansible (I’ve already created an article about Ansible a long time ago) you have an easy central to use monitoring tool with automatically distributed configuration files.

Installation of monit

Monit is available for most Linux distribution. With the following command you install monit on a Ubuntu / Debian machine:

user@machine:~$ sudo apt-get update && sudo apt-get install monit

Or if you’re an openSUSE user, you can install monit like this:

user@machine:~$ sudo zypper ref && sudo zypper in monit

That’s basically it. Compared to Nagios or Icinga, you don’t need an installed Apache web server. Monit comes with it’s own built-in web service. In order to check if monit is running, you can use systemctl to do so:

user@machine:~$ sudo systemctl status monit
● monit.service - LSB: service and resource monitoring daemon
 Loaded: loaded (/etc/init.d/monit; generated; vendor preset: enabled)
 Active: active (running) since Wed 2017-10-11 11:47:39 CEST; 3 months 13 days ago
 Docs: man:systemd-sysv-generator(8)
 Tasks: 2 (limit: 4915)
 CGroup: /system.slice/monit.service
 └─18228 /usr/bin/monit -c /etc/monit/monitrc
Dez 26 06:25:02 machine systemd[1]: Reloading LSB: service and resource monitoring daemon.
Dez 26 06:25:02 machine monit[15742]: Reloading daemon monitor configuration: monit.
Dez 26 06:25:02 machine systemd[1]: Reloaded LSB: service and resource monitoring daemon.
Jan 10 06:25:02 machine systemd[1]: Reloading LSB: service and resource monitoring daemon.
Jan 10 06:25:02 machine monit[15692]: Reloading daemon monitor configuration: monit.
Jan 10 06:25:02 machine systemd[1]: Reloaded LSB: service and resource monitoring daemon.

In order to start, stop or restart the service, use these following commands:

user@machine:~$ sudo systemctl start monit
user@machine:~$ sudo systemctl stop monit
user@machine:~$ sudo systemctl restart monit

Enable the monit built-in web server

If you’re an Debian / Ubuntu user, monit will store it’s main configuration under /etc/monit/monitrc. This files is really well documented. However, I want to give a short brief about how to enable the built-in web server which is one of the most important features.
You can find the following block (at the time of writing) at line 155:

# set httpd port 2812 and
# use address localhost # only accept connection from localhost
# allow localhost # allow localhost to connect to the server and
# allow admin:monit # require user 'admin' with password 'monit

If you uncomment this section the built-in monit web server will be started and will listen on port 2812. The second line sets the network address where the web server instance is listening on. If it only listens on localhost you will not be able to connect from any other host. For e.g. if your server has the IP address 192.168.0.2 you can replace localhost with this IP address. This will get the monit built-in web server to listen on this network interface.
The third line regulates which other hosts are allowed to establish a connection to the web server. You can define single IP addresses or even whole subnets (like 192.168.1.0/24). Just like before, simply replace localhost with the IP address or subnet which you want to allow to connect to the web server.
The fourth line defines a user with a password which will be able to login. monit does not allow an anonymous login which is good from a security point of view obviously. In this example the username would be admin with the password monit.
When you’re done setting these lines, restart the monit service:

user@machine:~$ sudo systemctl restart monit

You can now visit the monit web interface of your server. In this example the address would be something like http://192.168.0.2:2812 or just use the FQDN: http://my.monit.fqdn:2812.
Besides using the web interface, you can also check your services on the command line. To do so you also have to have the web interface enabled, because the command line simply gets an HTTP output and process it. To get a summary of all your monitored processes you can enter the following command:

user@machine:~$ sudo monit status

Enable mail notifications

Nagios or Icinga can send you a mail every time when a host or a service of this host went down. monit also offers this feature. To enable mail notifications, open once more the monit configuration file (/etc/monit/monitrc) and search for the following lines:

## Set the list of mail servers for alert delivery. Multiple servers may be
## specified using a comma separator. If the first mail server fails, Monit
# will use the second mail server in the list and so on. By default Monit uses
# port 25 - it is possible to override this with the PORT option.
#
# set mailserver mail.bar.baz, # primary mailserver
# backup.bar.baz port 10025, # backup mailserver on port 10025
# localhost # fallback rela

As you can see, you can set multiple mail servers which monit should try to connect each time a notification is about to be send. The downside here is that monit does not support authentication against mail servers. This basically means that you can’t just enter public mail servers like GMail. If you want to use those service you have to have a local mail server setup. You can configure the mailserver as a satellite / client to keep it more simple. If you’re mail server is up and running, you can simply set the mail server in the monitrc file like this:

set mailserver localhost

If you have access to a mail server which doesn’t require authentication, you can replace localhost with this mail server of course.
Now that you’ve set the mail server, you also have to enter the recipient for the notification mails. Search for the following line in the monitrc file:

# set alert sysadm@foo.bar # receive all alerts

Uncomment this line and replace sysadm@foo.bar with the recipient of your choice. You can also define which kind of notification are going to be send to this mail address. However, this is more advanced configuration which would burst this articles length.
When everything set, restart monit and you will now get a mail each time a service status changes:

user@machine:~$ sudo systemctl restart monit

Some examples for monitoring services

For monitoring new programs or services, you have to create a new file under the subdirectory /etc/monit/monitrc.d/. Simply name this file like the service which is going to be monitored. The following examples are showing how to monitor services, programs and system resources with monit:

Monitoring a running program / service or service without a PID file
check process TeamSpeak
  matching "ts3"

In this example we simple check if a process called „ts3“ is running on the machine. You can use ps ax on the command line by yourself on the target machine to see if the process is running. That’s basically what monit is doing. The name of this check is TeamSpeak as seen in the first line. You can change this to whatever you want.

Monitoring a program / service with a PID file
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
  start program = "systemctl start mysql"
  stop program = "systemctl stop mysql"
  if failed host localhost port 3306 protocol mysql with timeout 15 seconds for 3 times within 4 cycles then restart
  if failed unixsocket /var/run/mysqld/mysqld.sock protocol mysql for 3 times within 4 cycles then restart
  if 5 restarts with 5 cycles then alert

In this specific example we monitor a MySQL instance installed on the system. If the service crashes, monit tries three times within four cycles to restart the service. For this restart monit uses the two defined commands which are defined in start program and stop program. In this case monit checks the unixsocket as well as a network connection to get in touch with MySQL before it trys to restart the service.
If after four cycles (which includes restarting the service after each cycle in this case) the service is still unreachable for monit, monit runs into the fifth cycle. This last cycle is defined with „alert“. The administrator, which has been declared in the monitrc file, will get a mail. If there is another competent person defined for this specific service, this person will be mailed as well. The name of the service in this example is mysqld.

Check for disk usage
check device root with path /
  if SPACE usage > 90% then alert

With this check, we check the root file system. If the used space in percentage is over 90, monit will send out an alert via mail. It would also be possible to check against the used inodes of a partition as well. If you have more than just one partition, you have to create a check for each partition of want to monitor.

Check for ram, swap and CPU usage
check system my.machine.fqdn
  if memory usage > 90% then alert
  if cpu usage > 90% for 4 cycles then alert
  if swap usage > 95% for 4 cycles then alert

In this example we check the memory, CPU and swap usage by the system. This example is similar to the disk usage. If the memory usage is higher than 90% of the overall memory of this system, monit will send out an alert. If the CPU usage is over 90% for four cycles, monit will send an alert as well. The four cycles ensure that monit is not starting to report every little peak a CPU has. Same goes to SWAP. If 95% of the overall SWAP is in use, monit will report this when this has happened four times / cycles in a row. In the first line you would have to change my.machine.fqdn to the real FQDN your system has.

Check an external host (ping)
check host other.host.fqdn with address other.host.fqdn
  if failed icmp type echo
    count 3 with timeout 5 seconds
    2 times within 3 cycles
then alert

With this check, monit tries to ping the specified other.host.fqdn. With every ping command monit starts, it does three pings with a timeout of five seconds for each. If the ping fails two times within a three times cycle, monit sends out an alert that the host is unreachable / offline. In order to get this command up and running, you have to change other.host.fqdn to the desired host which you want to check.
For every check you change, add or remove, you have to restart the monit service:

user@machine:~$ sudo systemctl restart monit

You can now see the status of the services with the help of the web interface or with the command line:

user@machine:~$ sudo monit status

If you want to get the status of one single check, you can append the name of the check at the end of the status command. You have to use the name you defined within the configuration file for this check in your command. For e.g. to get the status of the first check TeamSpeak we’ve configured in these examples:

user@machine:~$ sudo monit status TeamSpeak

mmonit: If you need a central web instance

So while monit offers a web interface which you can use in order to get an overview about the actual checked services, I understand that literally nobody wants to connect to each single monit web instance if you have 30 hosts or more.
Now, what you could do is to write a wrapper script (with bash, Python, etc.) which helps you to get the actual status of all services on all hosts. However, a more comfortable and easier solution is to use mmonit. mmonit is written by the official monit developers and gathers all information from each single monit instance and is showing the collected data on one single page.
Sadly, mmonit isn’t free. You can grab a 30 day trial if you want to, but at the end you have to pay a small one time fee in order to use the software. The prices are starting as low as 65 € for 5 hosts and is dropping sharply as more hosts you’re using. With 50 hosts you also get support for just 349 €. Again, this is a one-time pay license. There are no more additional costs coming up. If you compare this to other solutions like check_mk, mmonit is really cheap.

The price table as of 24th January 2018

Sadly, I’m unable to tell you more about mmonit for now. I wasn’t in the need to have to use it for now. My own wrapper script is doing more than just fine. Right now I’m monitoring +30 hosts with monit. But maybe the future will push me to get a mmonit license 😉

Final words

Is monit a full replacement for Nagios or Icinga? I’m unable to say if monit really fits into server farms with more than 100 servers. But if you want to have a easy monitoring solution which works with scripts (and Nagios plugins if you configure your checks correctly), you will be most likely happy with monit.
I’ve seen some talks recently on StackOverflow about monit and while a lot of people are saying that they wouldn’t use monit in bigger clusters, they use it on certain spots. For e.g. somebody talked about a customer with round about 20 servers. He rolled out monit there because of the fast and easy configuration. In order to check all 20 hosts at once, he created a bash script which connects via SSH and Public Key authentication to each host and issues the command monit status. In order to keep track if the host is still accessible from outside he just pings from another host with a ping check configured on another monit instance.
As you can see, even if monit looks like it’s limited or „not as powerful as Nagios“, there are no borders. A lot of people use and love monit due to it’s easy configuration and flexibility. If you’re looking for a monitoring solution or for an Nagios / Icinga alternative, you should give monit a try.
Last hint: If you want to monitor a single server (for e.g. home server or a Raspberry Pi) monit is would you should look up before Nagios or Icinga IMHO. In a setup like this, monit is definitely about to shine.

Further links

bookmark_borderHow to convert/split p12 certificates into single files

So, you got a brand new personal certificate via a authorized issuer and all you got is a single file which has a ending of .p12? You want to use this certificate in various software solutions, but these solutions want single files for the user certificate and the private key? Then you have to split your .p12 file.

What is a .p12 file?

A .p12 file is a bundle which contains your private key as well as your private certificate. For a lot of certificate issuers, distributing these two things in a bundle is obviously easier.
Even if there is a lot of software which supports working with those bundles, there are others which don’t. The most prominent example I know is Network Manager under Linux. If you want to use a .p12 file with the Network Manger OpenVPN extension, you have to split up the .p12 file in it’s single parts. To split p12 certificates into single files will end up in having two files: Your user certificate and key.

Which software is needed?

Under Linux you need to have OpenSSL ready. OpenSSL is installed by default on every Linux based machine nowadays. But just to be sure, we will install OpenSSL again for this tutorial. For Debian, Linux Mint and Ubuntu simply enter the following command:

user@systen:~$ sudo apt-get update && sudo apt-get install openssl

Windows user have to downloaded the OpenSSL tools on their official homepage which can be found here: OpenSSL Windows Binaries

How to split a .p12 file?

Firstly, you have to navigate into the directory were your SSL file is actually stored. You can do this with the command cd. In this example we assume, that the p12 certificate file is stored in the directory ssl:
user@system:~$ cd ssl
Now that you are in the correct directory, you can extract the user key with the following command:

user@system:~/ssl$ openssl pkcs12 -nocerts -in your_file.p12 -out user_key.pem

The user certificate can be exported like this:

user@system:~/ssl$ openssl pkcs12 -nokeys -clcerts -in your_file.p12 -out user_cert.pem

During these two steps you might get asked for a password of the actual .p12 file and for a password for the new exported files. It’s up to you if you want to protect the new exported single files with a password. However, it is recommended of course. You can also do the two commands above within one statement like this (if you want):

user@system:~/ssl$ openssl pkcs12 -nocerts -in your_file.p12 -out user_key.pem && openssl pkcs12 -nokeys -clcerts -in your_file.p12 -out user_cert.pem

Further links