wwwhizz’ blog Blog about some tech, some linux, my MIDIbox SID, etc.

27Jun/091

Fixed it!

My blog was down for a few weeks. I tried to upgrade my WordPress installation while not having a lot of time. Bad idea. It somehow didn't work, and after reinstalling WordPress and importing the database today it works again. Woohoo :D

Filed under: Uncategorized 1 Comment
7May/090

Worklog Midibox #1

So, after collecting a lot of bits and pieces, reading a lot of documentation I finally started building my midibox.

You might think: "what on earth is a MidiBox?". Well, that's pretty well explained at the Wiki of midibox.org

I'm making a MidiBox SID.

To be precise the MB-6582, which is a MidiBox built around (up to) 8 SID-chips. A SID-chip is the built-in sound module in the Commodore 64 (amongst others).

Probably I won't use the standard black casing, but build my own from UV-reactive "plexiglass" (Acrylic glass or poly(methyl methacrylate)).

What it should do eventually:

MIDIbox SID V2 Bassline Demo #3 c64 from Thorsten Klose on Vimeo.

I've done quite a lot of it already, so I'll be backlogging real soon :)

Filed under: Uncategorized No Comments
27Apr/091

Make monit send less email

Today I found some nice extensions in the monit configuration file.

If you only want an alert message sent for certain events and just for some services, then append the alert-statement with the following lines.

check process apache2 with pidfile /var/run/apache2.pid
alert myemail@adress.ext only on { timeout, nonexist }

Only and on are so called "noise keywords", ignored by Monit to make it more readable.

You can also setup to send alerts for all events except some by putting the word "not" ahead of the list. For example, if you want to receive alerts for all events except Monit instance events, you can write (note that the noise words 'but' and 'on' are optional):

check system myserver
alert foo@bar but not on { instance }

instead of:

alert myemail@adress.ext on { action
checksum
content
data
exec
gid
icmp
invalid
fsflags
nonexist
permission
pid
ppid
size
timeout
timestamp }

Some parts of this are taken from the Monit Documentation

Filed under: Linux, Tutorial 1 Comment
25Apr/092

Monitor your system, processes, daemons and remote hosts on Debian linux (lenny) with monit.

Since a while I am monitoring a few remote hosts, as well as my own server (serving you this page right now) with monit.

Their site says:

"Monit is a free open source utility for managing and monitoring, processes, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations."

Time to get started!

The installation is very easy with aptitude:

# aptitude install monit

If for some reason you have to compile it yourself:

$ tar zxvf monit-x.y.z.tar.gz (were x.y.z denotes version numbers)
$ cd monit-x.y.z
$ ./configure (use ./configure --help to view available options)
$ make && make install

Now it's time to configure. Monit is highly customizable :)

The monit configuration file is found at /etc/monit/monitrc

The configuration below can be found at

http://www.t44.nl/wordpress/data/monitrc

Here is an example you can edit:

##### Global options #####
## Logging options
# Poll every minute
set daemon  60                          # polling time in seconds
set logfile syslog facility log_daemon  # Set syslog logging.

## Mail options
# Here you can setup your own mailserver
set mailserver smtp.yourisp.ext,        # primary mailserver
               localhost                # fallback relay

If you would like to use GMail (which requires TLS/SSL) use something like this instead:

# set mailserver smtp.gmail.com port 587 username "myemail@gmail.com" password "password" using tlsv1 with timeout 30 seconds

The eventqueue holds events if for some reason mails cannot be sent.

set eventqueue
     basedir /var/monit # set the base directory where events will be stored
     slots 100          # optionaly limit the queue size

You can define your mail-notification format. Use man monit for all options.

set mail-format {
## Just an example, feel free to edit
    from: monit@yourhost.com
    subject: (monit) $SERVICE $EVENT at $DATE
    message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
    Yours sincerely,
    monit
    Your system admin
}

All alert mail will be sent to below mail address.

# Set a default mail from-address for all alert messages emitted by monit.
set alert you@something.ext # fill in your e-mailaddress here

Let's setup the webinterface

# Web-server options
  set httpd port 80          # set httpd port for the web-interface,
                                 # default is 80, 443 is normally used for https
  allow my.home.ip.address     # Only these addresses can connect to the webinterface
  allow localhost                # All hosts can connect when omitted
  allow username:password      # set your users/passwds here
  allow foo:bar                  # Multiple users are allowed

If you wish (like me) to use SSL connections:

# Web-server options
  set httpd port 443           # set httpd port for the web-interface,
                                 # default is 80, 443 is normally used for https
  ssl enable                   # if you wish to enable ssl (i.e. https) connections
  PEMFILE /var/certs/monit.pem   # (only for SSL)
  allow my.home.ip.address     # Only these addresses can connect to the webinterface
  allow localhost                # All hosts can connect when omitted
  allow username:password      # set your users/passwds here
  allow foo:bar                  # Multiple users are allowed

This requires a certificate, and some more than basic knowledge. Much of it is very well explained in the Monit Wiki

Let's continue setting up services. First of all we check wheter our own system is running nicely. This is pretty straightforward.

##### Services #####
## System
  check system localhost
     if loadavg (5min) > 1 then alert
     if memory usage > 75% then alert
     if cpu usage (user) > 70% then alert
     if cpu usage (system) > 30% then alert
     if cpu usage (wait) > 20% then alert

Now we will monitor a few processes. The pid-files mostly are in /var/run/ (at least in Debian).

## Processes
# apache2
check process apache with pidfile /var/run/apache2.pid
   group www
   start program = "/etc/init.d/apache2 start"
   stop  program = "/etc/init.d/apache2 stop"
   if failed host 127.0.0.1 port 80 protocol http and request "/monit/token" with timeout 15 seconds then restart
   if cpu > 60% for 2 cycles then alert
   if cpu > 90% for 5 cycles then restart
   if totalmem > 200.0 MB for 5 cycles then restart
   if children > 250 then restart
   if failed host 127.0.0.1 port 50443 type tcpssl protocol http and request "/monit/token" with timeout 15 seconds then restart
   if 5 restarts within 5 cycles then timeout
   depends on apache_bin
   depends on apache_rc

 check file apache_bin with path /usr/sbin/apache2
   group www
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor

 check file apache_rc with path /etc/init.d/apache2
   group www
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor

Over to MySQL

# mysql
check process mysql with pidfile /var/run/mysqld/mysqld.pid
   group database
   start program = "/etc/init.d/mysql start"
   stop program = "/etc/init.d/mysql stop"
   if failed host localhost port 3306 protocol mysql then restart
   if 5 restarts within 5 cycles then timeout
   depends on mysql_bin
   depends on mysql_rc

 check file mysql_bin with path /usr/bin/mysql
   group database
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor

 check file mysql_rc with path /etc/init.d/mysql
   group database
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor

And syslogd:

# syslogd
check process syslogd with pidfile /var/run/syslogd.pid
   start program = "/etc/init.d/sysklogd start"
   stop program = "/etc/init.d/sysklogd stop"
   if 5 restarts within 5 cycles then timeout

 check file syslogd_file with path /var/log/syslog
   if timestamp > 65 minutes then alert

sshd and Samba:

# sshd
 check process sshd with pidfile /var/run/sshd.pid
   start program  "/etc/init.d/ssh start"
   stop program  "/etc/init.d/ssh stop"
   if failed host localhost port 50022 protocol ssh then restart
   if 5 restarts within 5 cycles then timeout

# Samba
 check process smbd with pidfile /var/run/samba/smbd.pid
   group samba
   start program = "/etc/init.d/samba start"
   stop  program = "/etc/init.d/samba stop"
   if failed host localhost port 139 type TCP  then restart
   if 5 restarts within 5 cycles then timeout
   depends on smbd_bin

 check file smbd_bin with path /etc/init.d/samba
   group samba
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor

Finally we also check wheter some other hosts are still up and running.

## Check other hosts
  check host google.com with address google.com
    if failed icmp type echo count 3 with timeout 3 seconds then alert
    if failed port 80 protocol http then alert
  check host t44.nl with address t44.nl
    if failed icmp type echo count 3 with timeout 3 seconds then alert
    if failed port 80 protocol http then alert

It is also possible to include some other configuration files with the include keyword:

##############################################################################
## Includes
###############################################################################
##
## It is possible to include additional configuration parts from other files or
## directories.
#  For instance:
include /etc/monit.d/*
#
#

After modifying the configuration file you should check for the syntax to make sure they are correct. To do this run:

# monit -t

Now you can run monit standalone:

# monit

Now you should be able to check monit in your webbrowser, and probably you'll get a few alert mails :) If for some reason you cannot access the webbrowser, you can throw out all lines that say

allow *hostname*

This will make monit accept all IP-adresses and hosts. Also check that your host correctly has port 80/443 (or whatever you have setup) forwarded, and that your firewall and ip-tables are set up correctly.

In order to use the Debian init.d startup script you must enable the service by changing the file /etc/default/monit.

# You must set this variable to for monit to start
startup=1

# To change the intervals which monit should run uncomment
# and change this variable.
CHECK_INTERVALS=30

Now you can start monit by running /etc/init.d/monit start. Also it will automatically start on reboot.

Filed under: Uncategorized 2 Comments
24Apr/092

Blogs come and blogs go

Actually, I wasn't planning on having a blog. Then a friend of mine showed me how well WordPress works, and I quite liked it. Thought I might give it a go. I'll post my worklog on my midibox here, some small Debian HOW-TO's as well as some tech-related stories.

Comments are highly appreciated :)

Filed under: Uncategorized 2 Comments