SnackLinux update

SnackLinux now has a whopping 31 packages, which include a (somewhat) working gcc toolchain and other fun GNU utilities (vitetris included!). I was able to add Docker support as well, which is just tarballed userland. Getting a working gcc toolchain was a bit of a pain in the butt. Pain in the butt because musl doesn't play nice with every piece of software out there, since most (that I have encountered anyway) think we're using glibc. And since SnackLinux is focused on every packaging being staticly compiled, not every package plays nice with that either. For example, there is a Python 2.7.9 package in the repository that is missing quite a few modules, see below:

_codecs_cn         _codecs_hk         _codecs_iso2022 
 _codecs_jp         _codecs_kr         _codecs_tw      
 _ctypes            _ctypes_test       _curses         
 _curses_panel      _hashlib           _hotshot        
 _json              _lsprof            _multibytecodec 
 _multiprocessing   audioop            bz2                
 dl                 future_builtins 
 imageop            linuxaudiodev      ossaudiodev     
 readline           syslog      

Fortunately, it works. Sort of. I wouldn't recommend using it at all. This is why gcc 4.9.2 needs to be patched for musl to get around this. That being said, most of the current packages are natively compiled on SnackLinux itself, so at least it's somewhat self sufficient ;)

 

I just got Nim working, as well as Lua. Perl is possible through staticperl. It's suprising the amount of software that depends on Perl, pkg-config and syslinux come to mind. With a working Python implementation being the last holdout, SnackLinux may finally gain some traction....in whichever niche it fits in... I suppose.

Pasteros.io is live!

My text storage platform project, pasteros.io is finally live! It's also on Github: https://github.com/snacsnoc/pasteros

Easton
Tags

Setup Nagios 3 with lighttpd on your VPS

There are countless tools and software stacks out there to monitor your servers out, though some are not the easiest to setup. I went with Nagios since it's straightforward to configure and easy to setup. For reference, I used Nagios 4.0.8 on Debian 7 using Debian 7 slaves. The Nagios master node already had lighttpd and PHP set up so I'll gloss over that.

Master node

Start by downloading Nagios and Nagios plugins:

 

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz
wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz

 

Extract, compile and install Nagios:

tar xzf nagios-4.0.8.tar.gz
cd nagios-4.0.8
./configure
sudo make all
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode

Extract, compile and install Nagios plugins


tar xzf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3

./configure
sudo make
sudo make install

Everything should install nicely, with the config residing in /usr/local/nagios/etc/. Next we'll have to create a user with a password so we can login to Nagios:

 sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

 

If you have a working mail server setup, edit /usr/local/nagios/etc/objects/contacts.cfg and change email to receive email alerts.

Now onto lighttpd configuration. You'll have to add the "mod_alias", "mod_auth", "mod_setenv" and "mod_cgi" to your server.modules in lighttpd.conf. Next we'll add the proper aliases and allow us to authenticate.


alias.url  += ("/nagios/cgi-bin" => "/usr/local/nagios/sbin")
alias.url  += ("/nagios/stylesheets" => "/usr/local/nagios/share/stylesheets")
alias.url  += ("/nagios" => "/usr/local/nagios/share")

$HTTP["url"] =~ "^/nagios/cgi-bin" {
        cgi.assign = ( "" => "" )
}
$HTTP["url"] =~ "nagios" {
  auth.backend = "htpasswd"
  auth.backend.htpasswd.userfile = "/usr/local/nagios/etc/htpasswd.users"
  auth.require = ( "" => (
    "method" => "basic",
    "realm" => "nagios",
    "require" => "user=nagiosadmin"
    )
  )
}
setenv.add-environment = ( "REMOTE_USER" => "nagiosadmin" )

Restart lighttpd to check our changes:


sudo /etc/init.d/lighttpd restart

At this point, be sure to check if http://your-server-address/nagios works.

Slave nodes

The nice thing is that once we configure our slave nodes once, we don't have to touch them again (as far as configuration goes really). On each of the nodes:


sudo apt-get install nagios-nrpe-server nagios-plugins

This will install a whack of dependencies, for me it totalled to just over 100MB. Once that is installed, we'll have to add our master node IP to each slave. Edit /etc/nagios/nrpe.cfg, find the following line and add your master node IP address:


...
allowed_hosts=127.0.0.1 master.node.ip.address
...

Once completed, restart nrpe-server


sudo /etc/init.d/nagios-nrpe-server restart

Monitoring configuration

We'll have to tell Nagios where our slave nodes configurations are, so edit /usr/local/nagios/etc/nagios.cfg and uncomment the following line:


cfg_dir=/usr/local/nagios/etc/servers

Create the directory which will hold our slave nodes


sudo mkdir /usr/local/nagios/etc/servers

The config for the slave nodes is located at /usr/local/nagios/etc/servers/clients.cfg. Fortunately, there are other tutorials that are more in depth than mine regarding monitoring. Currently, I'm using a basic config to see if the slave node is alive, and check for HTTP/SSH. See below for an excerpt:


define host{
use                             linux-server
host_name                       your_fancy_hostname
alias                           your_fancy_hostname
address                         slave.node.ip.address
max_check_attempts              5
check_period                    24x7
notification_interval           30
notification_period             24x7
}


define service {
        use                             generic-service
        host_name                       your_fancy_hostname
        service_description             SSH
        check_command                   check_ssh
        notifications_enabled           0
        }
define service {
        use                             generic-service
        host_name                       bonbon
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }

And of course once we're done making changes, restart Nagios


sudo /etc/init.d/nagios restart
If all is well, you'll end up with something like this:

For me, all I'm looking for is basic application and uptime monitoring. Nagios is quite extensible, having a catalogue of plugins. There is of course more extensive documentation on monitoring configuration as well.

References: http://redmine.lighttpd.net/projects/1/wiki/NagiosRecipe http://library.nagios.com/library/products/nagiosxi/documentation/299-installing-the-nagios-ubuntu-and-debian-linux-agent

Nimrod language

 I have recently discovered the Nimrod programming language. I usually don't branch out on languages because, well, stuff you don't know can be scary. I'm surprised how easy it is to get going though, it reminds me quite a bit of Python. I put up a test project on Github that fetches the weather for a given location.

Tags

Building a distro that almost works

 For the most part, SnackLinux works. I've been having problems with Busybox, so I've made packages for coreutils, binutils, sed, grep and gawk. When compiling anything, I get:

segfault at 0 ip    (null) sp bfdb1cbc error 4 in busybox[8048000+e8000]

or something along the lines of that. I used the newest Buildroot, 2013.11, to create a new toolchain and cross compile uClibc 0.9.33 for SnackLinux. I have yet to recompile Busybox yet, but I'm working on getting gcc natively working on SnackLinux. Once that is completed, I should be able to compile SnackLinux from within SnackLinux.

Getting a terminal IBM Model M to work with PS/2

 I recently bought another IBM Model M (1395660) on eBay the other day, not thinking that it is actually a terminal keyboard. I thought it has a detachable SDL cable like my current Model M (1391401). I was wrong. Turns out it has a non-removable RJ-45 plug instead, thus being a terminal keyboard. Well, aftering some researching, some were able to get it to work by using an ATMega. I was able to find a pinout of the RJ45 plug on the keyboard, and simply just wire it up to a PS/2 cable. Though apparently, the colour of wire for PS/2 is not standardized, which led to testing each pin to see what it does. I cannibalized an old Microsoft keyboard for the cable and was able to hook the wires up straight to each other.

PS/2 cable wires on a breadboard, original connector above.

 

For this specific PS/2 cable, the pinout is as follows:
IBM -> PS/2 Cable
black -> red         +5V 
red -> white         data 
yellow -> brown  clock
white -> black     ground 
 
The last wire (next to the white wire) on the breadboard is ground, which I have on the metal body of the keyboard. Thankfully everything mostly works. The "Print" key on the left hand side of the board is somehow F5 and the blank key above it is CTRL+F. Next step is a neat soldering job and it's good to go!

SnackLinux, an intro to building your own distro

 I've spent the last week or two working on SnackLinux, a small Linux distro. I managed to get uClibc in there, as well as tcc, which makes it somewhat useful. The source of it all is there, so you can compile the distro yourself (sans the packages). There are also ISOs which you can download here and fire them up in a virtual machine.