FreeBSD Stuffhttp://lme.postach.io/feed.xml2015-10-22T13:42:56.857000ZWerkzeugChanging console resolution in FreeBSD 10 with vt(4)https://lme.postach.io/post/changing-console-resolution-in-freebsd-10-with-vt-42015-10-22T13:42:56.857000Z2015-10-22T09:55:42ZLars<p>Since FreeBSD 10 you can choose between the traditional <a href="http://man.freebsd.org/sc">sc(4)</a> console and the newer <a href="http://man.freebsd.org/vt">vt(4)</a> terminal console driver. While the latter is needed to have a working suspend / resume on Intel hardware newer than Ivy Bridge, it lacks the ability to use <a href="htttp://man.freebsd.org/vidcontrol">vidcontrol(8)</a> to dynamically change the screen resolution (on the console, not in X!).</p>
<p>If you need to set a higher resolution on a vt(4) console you can either start X and switch back to the console with <em>Ctrl+Alt+F1</em> or without starting X just by loading the <em>i915kms</em> kernel module:</p>
<pre><code># kldload i915kms
</code></pre>
<p>To load the module at boot time (a short time after the kernel is loaded), add this to <code>/boot/loader.conf</code>:</p>
<pre><code>i915kms_load="YES"
</code></pre>
<p>If for some reason you need to set a different resolution than the display's native resolution, you can set a <em>tunable</em> before loading the module:</p>
<pre><code># kenv kern.vt.fb.default_mode="800x600"
</code></pre>
<p>Or any other valid resolution for your display.</p>
<p>You probably want to set tunable at boot time, so add this to <code>/boot/loader.conf</code>:</p>
<pre><code>kern.vt.fb.default_mode="800x600"
</code></pre>
<p>Should you like to set a fixed mode on a specific output device, you can specify it:</p>
<pre><code> kern.vt.fb.LVDS-1="1024x768"
</code></pre>
<p>This sets the resolution for the internal notebook display. For a list of valid output device names use <a href="http://man.freebsd.org/dmesg">dmesg(8)</a>:</p>
<pre><code> # dmesg | grep drm
info: [drm] Connector LVDS-1: get mode from tunables:
info: [drm] - kern.vt.fb.modes.LVDS-1
info: [drm] - kern.vt.fb.default_mode
info: [drm] Connector VGA-1: get mode from tunables:
info: [drm] - kern.vt.fb.modes.VGA-1
info: [drm] - kern.vt.fb.default_mode
info: [drm] Connector HDMI-A-1: get mode from tunables:
info: [drm] - kern.vt.fb.modes.HDMI-A-1
info: [drm] - kern.vt.fb.default_mode
info: [drm] Connector DP-1: get mode from tunables:
info: [drm] - kern.vt.fb.modes.DP-1
info: [drm] - kern.vt.fb.default_mode
info: [drm] Connector HDMI-A-2: get mode from tunables:
info: [drm] - kern.vt.fb.modes.HDMI-A-2
info: [drm] - kern.vt.fb.default_mode
info: [drm] Connector HDMI-A-3: get mode from tunables:
info: [drm] - kern.vt.fb.modes.HDMI-A-3
info: [drm] - kern.vt.fb.default_mode
info: [drm] Connector DP-2: get mode from tunables:
info: [drm] - kern.vt.fb.modes.DP-2
info: [drm] - kern.vt.fb.default_mode
info: [drm] Connector DP-3: get mode from tunables:
info: [drm] - kern.vt.fb.modes.DP-3
info: [drm] - kern.vt.fb.default_mode
</code></pre>
<p>That's it, now you can actually work on the console. :-)</p>
<p>Thanks to dumbbell@ for his insights on the topic!</p>Installing Icinga Web 2 with Apache 2.4, Icinga 2 and MySQL on FreeBSDhttps://lme.postach.io/post/installing-icinga-web-2-with-apache-2-4-icinga-2-and-mysql-on-freebsd2015-10-22T13:36:26.271000Z2015-10-08T16:52:05ZLars<p>The last entry was about <br />
<a href="http://lme.postach.io/post/install-icinga-2-with-mysql-on-freebsd">Installing Icinga 2 with MySQL on FreeBSD</a>.</p>
<p>This one now shows how to install and configure the new <a href="https://github.com/Icinga/icingaweb2/">Icinga Web 2</a><br />
interface on FreeBSD and use it with <a href="https://www.icinga.org/icinga/icinga-2/">Icinga 2</a> and a MySQL database<br />
both as authentication and data source.</p>
<p>I assume that you followed the last blog entry and have now a FreeBSD machine running Icinga 2 which writes<br />
data into the MySQL database running on the same host.</p>
<h2>Install Icinga Web 2 and Apache 2.4 with mod_php</h2>
<p>Using binary packages, installing is just a matter of</p>
<pre><code># pkg install apache24 mod_php56 icingaweb2
</code></pre>
<p>The mod_php56 package is automatically enabled in <code>/usr/local/etc/apache24/httpd.conf</code> but it still needs<br />
some configuration:</p>
<pre><code># cat << EOF > /usr/local/etc/apache24/modules.d/001_mod_php.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
EOF
</code></pre>
<p>To enable mod_rewrite in Apache, uncomment the <code>#LoadModue rewrite [...]</code> line:</p>
<pre><code>LoadModule rewrite_module
</code></pre>
<p>Copy the example Apache configuration file for Icinga Web 2:</p>
<pre><code># cp /usr/local/share/examples/icingaweb2/apache/icingaweb2.conf /usr/local/etc/apache24/Includes/
</code></pre>
<p>Configure PHP and Include the ZendFramework libaries:</p>
<pre><code># cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
</code></pre>
<p>In <code>/usr/local/etc/php.ini</code> search for <code>include_path</code> and insert the following after:</p>
<pre><code>include_path = ".:/usr/local/share/ZendFramework/library"
</code></pre>
<p>Also in <code>/usr/local/etc/php.ini</code> set <code>date.timezone</code>:</p>
<pre><code>date.timezone = Europe/Berlin
</code></pre>
<p>Now enable starting Apache at boot time and start it:</p>
<pre><code># sysrc apache24_enable=yes
# service apache24 start
</code></pre>
<h2>Configure Icinga Web 2</h2>
<p>You can either configure Icinga Web 2 and MySQL from the command line or more comfortable trough its<br />
web interface. I will show you the latter:</p>
<p>Create a new setup token:</p>
<pre><code># cd /usr/local/www/icingaweb2/
# ./bin/icingacli setup token create --config=/usr/local/etc/icingaweb2
The newly generated setup token is: f4911ef531ef71a4
</code></pre>
<p>With the token you created, go to <code>http://$server_ip/icingaweb2/setup</code> and paste the token into the text field.</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/15a144d4-245f-4d2c-8369-7c2116b67c4c.jpg" /></p>
<p>Then select at least the <code>Monitoring</code> module:</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/0b886601-e971-4e0f-b467-4ec785ae0613.jpg" /><br />
You should not see any red components:</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/f0dc5ffb-b2c9-413e-91b4-6baba4a7ea13.jpg" /></p>
<p>Select <code>Database</code> as authentication method:</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/1407ecd1-25eb-4f1f-ab3c-2976ef6983a5.jpg" /><br />
In this screen, enter <code>icingaweb2</code> as the database name, <code>root</code> as username and the root password you set in the previous blog entry.</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/0cb2f06d-6cb5-4970-9cec-6d9b0400f748.jpg" /></p>
<p>Set <code>icingaweb2</code> as authentication backend:</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/d36fc285-b893-43d3-b548-3e277b2120b1.jpg" /></p>
<p>Setup a new user. I use <code>icingaadmin</code> for the example:</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/8a09ebca-9edd-4b27-9816-f552826c6225.jpg" /></p>
<p>Save your user preferences in the database and log to <code>syslog</code>:</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/057e9470-6527-4e5e-9a30-7f4374a51abf.jpg" /></p>
<p>Check if the configurations is right:</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/7e0849b4-cc16-435f-aaef-8db4b055c6cd.jpg" /></p>
<p>Now configure the monitoring module:</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/236b6047-7820-46ac-b1b8-cf4e44cfc93b.jpg" /></p>
<p>Select <code>IDO</code> as backend type</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/2ae1a5b5-af91-4362-bc2b-e8abc2b5dd00.jpg" /></p>
<p>As <code>IDO Resource</code> enter <code>localhost</code> as hostname <code>icinga</code> as database name, <code>icinga</code> as username and the according password in the MySQL database.</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/a9eb39f6-17b5-4087-b28d-404e24e4e6e5.jpg" /></p>
<p>To send commands to the Icinga 2 process like re-scheduling, etc. point the command file to <code>/var/run/icinga2/cmd/icinga2.cmd</code>.</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/f50388a3-1822-4c2e-849a-5021b97660b0.jpg" /></p>
<p>To protect passwords from the web interface, leave the defaults in this screen:</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/40b1882f-8a14-4a34-97f7-d921a45385b0.jpg" /></p>
<p>Have a last look at the settings:</p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/9f844669-cd7e-4dcc-ac8d-6a5bc1be0d34.jpg" /></p>
<p>And that's it, enjoy Icinga Web 2! </p>
<p><img src="https://cdn-images.postach.io/11e4cd45-669a-48d3-a170-84314f537eb6/8648c763-67f4-4893-96d5-debc4d969282/e1b7cdb8-76a0-4a06-8721-fbbc14899bda.jpg" /></p>Installing Icinga 2 with MySQL on FreeBSDhttps://lme.postach.io/post/installing-icinga-2-with-mysql-on-freebsd2015-10-08T20:57:00.141000Z2015-10-05T18:32:23ZLars<div><a shape="rect" href="http://www.freshports.org/databases/mysql56-server" target="_blank">Icinga 2</a> and <a shape="rect" href="http://www.freshports.org/databases/mysql56-server" target="_blank">MySQL</a> are both in FreeBSD's ports tree, so installing them via ports or packages is not too hard but you need to configure both afterwards.<br clear="none"/></div>
<div><br clear="none"/></div>
<div>This tutorial expects a clean FreeBSD installation, so please check if all steps are applicable to your installation. Where possible, I will install from packages but installation from ports should be similar.</div>
<div><br clear="none"/></div>
<div><span style="font-size: 18px;">Install Icinga 2 and MySQL packages and enable both at boot time</span></div>
<div><br clear="none"/></div>
<div>The following will install Icinga 2 and MySQL Server 5.6, and enable starting of them via <span style="font-family: 'times new roman', times, serif;">/etc/rc.conf</span><span><span style="font-family: gotham, helvetica, sans-serif;">. </span></span></div>
<div><span><span style="font-family: gotham, helvetica, sans-serif;"><span style="font-family: gotham, helvetica, sans-serif;"><br clear="none"/></span></span></span></div>
<div><span style="font-family: 'courier new', courier, monospace; color: #808080;"># pkg install icinga2 mysql56-server</span><br clear="none"/></div>
<div><span style="font-family: 'courier new', courier, monospace; color: #808080;"># sysrc icinga2_enable=yes</span></div>
<div><span style="font-family: 'courier new', courier, monospace; color: #808080;"># sysrc mysql_enable=yes</span></div>
<div><span style="font-family: 'courier new', courier, monospace;"><br clear="none"/></span></div>
<div><span style="font-family: gotham, helvetica, sans-serif;">Start the MySQL Server, but don't start Icinga 2, yet.</span><br clear="none"/></div>
<div><br clear="none"/></div>
<div><span style="font-family: 'courier new', courier, monospace; color: #808080;"># service mysql-server start</span></div>
<div><br clear="none"/><span style="font-size: 18px;">Secure the MySQL installation</span><br clear="none"/></div>
<div><span style="font-family: 'courier new', courier, monospace;"><br clear="none"/></span></div>
<div><span style="font-family: 'courier new', courier, monospace; color: #808080;"># mysql_secure_installation</span></div>
<div><span style="font-family: 'courier new', courier, monospace; color: #666699;">NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL [21/9199]<br clear="none"/> SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!<br clear="none"/><br clear="none"/>In order to log into MySQL to secure it, we'll need the current<br clear="none"/>password for the root user. If you've just installed MySQL, and<br clear="none"/>you haven't set the root password yet, the password will be blank,<br clear="none"/>so you should just press enter here.<br clear="none"/><br clear="none"/>Enter current password for root (enter for none): <br clear="none"/>OK, successfully used password, moving on...<br clear="none"/><br clear="none"/>Setting the root password ensures that nobody can log into the MySQL<br clear="none"/>root user without the proper authorisation.<br clear="none"/><br clear="none"/>Set root password? [Y/n] y<br clear="none"/>New password: <br clear="none"/>Re-enter new password: <br clear="none"/>Password updated successfully!<br clear="none"/>Reloading privilege tables..<br clear="none"/> ... Success!<br clear="none"/><br clear="none"/><br clear="none"/>By default, a MySQL installation has an anonymous user, allowing anyone<br clear="none"/>to log into MySQL without having to have a user account created for<br clear="none"/>them. This is intended only for testing, and to make the installation<br clear="none"/>go a bit smoother. You should remove them before moving into a<br clear="none"/>production environment.<br clear="none"/><br clear="none"/>Remove anonymous users? [Y/n] y<br clear="none"/> ... Success!<br clear="none"/><br clear="none"/>Normally, root should only be allowed to connect from 'localhost'. This<br clear="none"/>ensures that someone cannot guess at the root password from the network.<br clear="none"/><br clear="none"/>Disallow root login remotely? [Y/n] y<br clear="none"/> ... Success!<br clear="none"/><br clear="none"/>By default, MySQL comes with a database named 'test' that anyone can<br clear="none"/>access. This is also intended only for testing, and should be removed<br clear="none"/>before moving into a production environment.<br clear="none"/><br clear="none"/>Remove test database and access to it? [Y/n] y<br clear="none"/></span></div>
<div><span style="font-family: 'courier new', courier, monospace;"><span style="color: #666699;"> - Dropping test database...</span><br clear="none"/><span style="color: #666699;"> ... Success!</span><br clear="none"/><span style="color: #666699;"> - Removing privileges on test database...</span><br clear="none"/><span style="color: #666699;"> ... Success!</span><br clear="none"/><br clear="none"/><span style="color: #666699;">Reloading the privilege tables will ensure that all changes made so far</span><br clear="none"/><span style="color: #666699;">will take effect immediately.</span><br clear="none"/><br clear="none"/><span style="color: #666699;">Reload privilege tables now? [Y/n] y</span><br clear="none"/><span style="color: #666699;"> ... Success!</span><br clear="none"/><br clear="none"/><br clear="none"/><br clear="none"/><br clear="none"/><span style="color: #666699;">All done! If you've completed all of the above steps, your MySQL</span><br clear="none"/><span style="color: #666699;">installation should now be secure.</span><br clear="none"/><br clear="none"/><span style="color: #666699;">Thanks for using MySQL!</span><br clear="none"/><br clear="none"/><br clear="none"/><span style="color: #666699;">Cleaning up...</span><br clear="none"/></span></div>
<div><span style="font-family: 'courier new', courier, monospace;"><br clear="none"/></span></div>
<div><span style="font-family: gotham, helvetica, sans-serif;">Make sure to remember the root password for the MySQL database, you will need it later.<br clear="none"/></span></div>
<div><span style="font-family: gotham, helvetica, sans-serif;"><br clear="none"/></span></div>
<div><span style="font-family: gotham, helvetica, sans-serif; font-size: 18px;">Create database schema for Icinga 2</span></div>
<div><span style="font-family: gotham, helvetica, sans-serif; font-size: 14px;"><br clear="none"/></span></div>
<div>In order for Icinga 2 to write to the database you need to create a database schema.</div>
<div><br clear="none"/></div>
<div><span style="font-family: 'courier new', courier, monospace;"><span style="color: #808080;"># mysql -p -u root</span> <span style="font-family: gotham, helvetica, sans-serif;"># Enter the root password for the database</span><br clear="none"/></span></div>
<div><span style="font-family: 'courier new', courier, monospace;"><span style="color: #666699;">mysql> CREATE DATABASE icinga;</span><br clear="none"/><span style="color: #666699;"> mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga';</span><br clear="none"/><span style="color: #666699;"> mysql> connect icinga;</span><br clear="none"/><span style="color: #666699;"> mysql> source /usr/local/share/icinga2-ido-mysql/schema/mysql.sql;</span><br clear="none"/></span></div>
<div><span style="font-family: 'courier new', courier, monospace;"><br clear="none"/></span></div>
<div><span style="font-family: gotham, helvetica, sans-serif;">Of course I don't need to tell you to use a real password, do I? :-)<br clear="none"/></span></div>
<div><span style="font-family: gotham, helvetica, sans-serif;"><br clear="none"/></span></div>
<div><span style="font-family: gotham, helvetica, sans-serif; font-size: 18px;">Enabling Icinga 2 features and start Icinga 2<br clear="none"/></span></div>
<div><br clear="none"/></div>
<div>The last thing to do is enabling the "ido-mysql" feature in Icinga 2. While we're here, we can also enable other useful features.</div>
<div><span style="font-family: 'courier new', courier, monospace;"><br clear="none"/></span></div>
<div><span style="font-family: 'courier new', courier, monospace; color: #808080;"># icinga2 feature enable command ido-mysql livestatus perfdata statusdata</span><br clear="none"/></div>
<div><span style="font-family: 'courier new', courier, monospace; color: #808080;"># service icinga2 start</span></div>
<div><span style="font-family: 'courier new', courier, monospace;"><br clear="none"/></span></div>
<div><span style="font-family: gotham, helvetica, sans-serif;">That's it! If everything went well you should not see any errors in</span> <span style="font-family: 'courier new', courier, monospace;">/var/log/icinga2/icinga2.log</span></div>
<div><span style="font-family: 'courier new', courier, monospace;"><br clear="none"/></span></div>
<div><span style="font-family: gotham, helvetica, sans-serif;">In the <span><a shape="rect" href="http://lme.postach.io/post/installing-icinga-web-2-with-apache-2-4-icinga-2-and-mysql-on-freebsd">next part</a></span> will be about using <a shape="rect" href="http://www.freshports.org/net-mgmt/icingaweb2" target="_blank">Icinga Web 2</a> together with Icinga 2 on FreeBSD.</span></div>
<div><span style="font-family: gotham, helvetica, sans-serif;"><br clear="none"/></span></div>