Thursday, 23 July 2015

SourceForge is back - Yay!

The Nagresconf Web site, http://nagrestconf.smorg.co.uk/, is back on-line. What a huge job that must have been for sourceforge to have taken a week to get back on-line.

Interestingly, Google Analytics on the Web site show that it had 61 sessions on Monday and 81 on Tuesday, when the site was down. Why? - I have no idea!

Obdi Centos 6 Install Guide

An Obdi installation guide for Centos 6 is now on GitHub here.

So now guides for Ubuntu Trusty and RedHat/Centos 6 are done, along with installation scripts for both.

Tuesday, 21 July 2015

Obdi Milestone 0.1.4 Released Today



Obdi Milestone 0.1.4 is available today.

Changes:
  • RPM: Adds cert and works out GOROOT. Closes #21
  • Added documentation. Fixes #23.
  • Don't create sidebar item when HasView==0
  • Documentation moved out of Wiki
  • DEB: Fixes #19. Add cert creation to OS packages
  • Ubuntu Installation fixes
  • upstart scripts
  • Build now works stand-alone and in ubuntu ppa
  • Debian/Ubuntu build files
  • Take plugins out. Closes #3
  • Added rpm dependency on git, gcc and golang
  • Added repository manager to admin interface
  • Log plugin's stdout to obdi's stdout. Closes #17
Centos 6 RPMs are available at GitHub:
https://github.com/mclarkson/obdi/releases

Ubuntu packages uploaded to Launchpad:
https://launchpad.net/~mark-clarkson/+archive/ubuntu/obdi

What's next? Centos 6 Installation Guide.

Monday, 20 July 2015

Sourceforge Still Down

Sorry to all that the Nagrestconf Web site is still down.

It's hosted on Sourceforge and it's hopefully going to be back soon.

See their interesting post about the problem at http://sourceforge.net/blog/sourceforge-infrastructure-and-service-restoration/.

Saturday, 18 July 2015

Monitoring an external SMTP relay service with Synagios


I use an outbound email relay service, http://www.dnsexit.com/, and it stopped working last week without me knowing. Emails I had sent sat around for four days before I found out, which caused me a few problems.

The problem was with SSL - Dns Exit fixed it within 24 hours and I was able to switch to their backup server until it was fixed, but I should have known earlier. I'm pretty happy with DNS Exit though as they were pretty quick to fix it, had a backup server to connect to, and emailed me when the problem was fixed.

I'm going to add a new check to Synagios to check my email relay service so I know more quickly next time.

Finding a Plugin


I need a plugin to check STMP. First I'll log into my diskstation and see what plugins are available.

I'll Log into my diskstation using Putty or ssh then use the 'chroot' command to enter into the nagios chroot as shown: 
chroot /volume1/@appstore/Synagios/nagios-chroot/ /bin/bash
I'm in the nagios chroot now so I'll look at the plugins. They are in two locations, /usr/lib/nagios/plugins and /usr/local/nagios/plugins.

Looking in /usr/lib/nagios/plugins: 
ls /usr/lib/nagios/plugins
Shows a list of the default nagios plugins. The one I need is right there, 'check_smtp'.

Testing the Plugin

I'll test it from the command line first.

Check the plugin's options:
/usr/lib/nagios/plugins/check_smtp -h
The next command tests the host relay.dnsexit.com(-H), STARTTLS(-S), verbosely(-v):
/usr/lib/nagios/plugins/check_smtp  -S -H relay.dnsexit.com -v
Next I'll add authentication(-A) and my user name(-U) and password(-P):
/usr/lib/nagios/plugins/check_smtp  -S -H relay.dnsexit.com -v \
-A LOGIN -U theusername -P thepassword
Note that '\' is a continuation character. This allows the command to span multiple lines and I only do it here so the line fits in the blog.

I think this is enough to test for. It checks SSL, STARTTLS, and authentication.

A Note About Plugin Locations


In the synagios chroot, in the file '/etc/nagios3/resource.cfg', there are two nagios macros, $USER1$ and $USER5$, which hold the locations of the nagios plugins and are used in the 'Commands' tab in the Nagrestconf GUI.

The two Nagios macros are defined in resource.cfg as:
...
$USER1$=/usr/lib/nagios/plugins
...
$USER5$=/usr/local/nagios/plugins
...
$USER1$ is where the official nagios plugins are and $USER5$ is where extra plugins are kept.

I found 'check_smtp' in '/usr/lib/nagios/plugins', so this is '$USER1$'.

Open Nagrestconf and Nagios3


Using a Web Browser, preferably Firefox, Safari, or Chrome, I'll open the following links. Change 'diskstation' for the name or IP address of your diskstation.
http://diskstation:8888/nagrestconf/index.php
I'll refer to this as the Nagrestconf GUI from now on, and,
http://diskstation:8888/nagios3/
,which I will refer to as the Nagios GUI.

Adding the Check 


Looking in the Nagrestconf GUI, the 'check_smtp' plugin is already listed there as:
$USER1$/check_smtp -H $HOSTADDRESS$ $ARG1$
I can just add it then, great. To do this I will first add a new host, then add a service to that host.

Refer to the Nagios Documentation to find out more about Nagios configuration. It will explain the format of the Command that is entered next and what the '!' sign is for (it's a delimiter between arguments).

Adding the host:
  • Click on the Hosts tab
  • Click on the Add New Host icon at the top right of the table
  • For the three fields Host Name, Alias, and IP Address enter: relay.dnsexit.com
    Of course, change relay.dnsexit.com to your email relay provider.
  • Click Create Host
Adding the service:
  • Click on the new 'relay.dnsexit.com' entry, expanding it
  • Click on the Add New Service icon at the top right of the inner table
  • For the Service Template choose: svctmpl-lin
  • For the Command field enter:
    check_smtp!-S -U theusername -P thepassword -A LOGINOf course, change 'theusername' and 'thepassword' to your username and password.
  • For the Description field enter: Outbound Mail Relay
  • Click the Additional tab
  • For the Check Interval field enter: 30.
    This checks the relay service every 30 minutes
Click Create Service.

Click Apply Changes at the top left of the screen, the Apply Configuration.

Switching to the Nagios GUI, the new host and check will appear in a couple of minutes and hopefully both turn green, as shown in the screen shot at the top of this page.

Now I'm going to do the same for the backup relay so if there's a problem I'll know it's good to switch to it.

Tuesday, 14 July 2015

Obdi Salt Stack Plugins Documentation - Done!

Finally! I've written an installation guide for the Obdi Salt Stack plugins. You can view it using this Link to GitHub.

Unfortunately it's only for Ubuntu Trusty so I'm going to have to do another guide for Centos next...

Saturday, 11 July 2015

Synology NAS monitoring with Synagios using SNMP

After installing Synagios, using the instructions on the Nagrestconf Web site, you will find that a whole bunch of things on the Diskstation are monitored and graphed, but these are not Synology specific.

In this blog post I will show how to add a new Nagios plugin to monitor things that are specific to Synology devices and we will get the plugin from exchange.nagios.org. A little Linux command line knowledge would be useful, but not much is required.

The nagios plugin we add can then be used to monitor other Synology devices and the method shown here can be used for adding any other Nagios plugins that use SNMP polling.

Getting Ready


This tutorial assumes that Synagios has been set up as described in the instructions on the Nagrestconf Web site, so it has the extra service templates etc.

We'll need two programs to configure Synagios: a Web Browser, to use the nagrestconf and nagios interfaces, and a terminal. Open these now, as shown next, so we can switch between them as necessary.

Start a Terminal Session to the Diskstation


Log into your diskstation using Putty or ssh then use the 'chroot' command to enter into the nagios chroot as shown next:
chroot /volume1/@appstore/Synagios/nagios-chroot/ /bin/bash
I'll call this the synagios chroot from this point on.

Note that anything you do here, after typing the 'chroot' command, will be inside the Synagios chroot, so you won't break your Synology NAS. Take a backup using the Nagrestconf GUI before starting and if things go terribly wrong just log out by typing 'exit', twice, then uninstall Synagios and then reinstall it.

Open Nagrestconf and Nagios3


Using a Web Browser, preferably Firefox, Safari, or Chrome, open the following links, changing 'diskstation' for the name or IP address of your diskstation.
http://diskstation:8888/nagrestconf/index.php
I'll refer to this as the Nagrestconf GUI from now on, and,
http://diskstation:8888/nagios3/
,which I will refer to as the Nagios GUI.

Plugin Locations


In the synagios chroot, in the file '/etc/nagios3/resource.cfg', there are two nagios macros, $USER1$ and $USER5$, which hold the locations of the nagios plugins and are used in the 'Commands' tab in the nagrestconf GUI.

Take a look in the Nagrestconf GUI now and click the 'Commands' tab to see them. Look for $USER1$ and $USER5$ in that page to see how they have been used.

The two Nagios macros are defined in resource.cfg as:
...
$USER1$=/usr/lib/nagios/plugins
...
$USER5$=/usr/local/nagios/plugins
...
$USER1$ is where the official nagios plugins are and $USER5$ is where extra plugins are kept.

When we get the new plugin we will put it in $USER5$.

Get the New Plugin


Lots of nagios plugins are available at exchange.nagios.org. I searched for 'synology' at the exchange.nagios.org Web site and I'm going to try the 'Synology status' plugin.

NOTE: Looking at the comments for the 'Synology status' plugin you'll see that some people have problems with it so it might not work for you. It works for me, but it fails when my system is doing a Timed Backup to another Synology device. This is at 2am, when alerting is off anyway, so this plugin is fine for me.

In this case I can download this plugin from the Web site straight from the synagios chroot using 'curl'.

Switch to the synagios chroot and type (or paste):
mkdir ~/tmp

cd ~/tmp

curl -o check_snmp_synology 'https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=4725&cf_id=24'
The first line makes a 'tmp' directory in the home directory; '~' means home, which will be '/root' in this case.
The second line switches us to that directory.
The third line gets the file from the Web site and names it 'check_snmp_synology' using the '-o' option.

You can view the first few lines of the file by typing 'head check_snmp_synology' to verify you got the right file, for example:
root@DiskStation:~/tmp# head check_snmp_synology
#!/bin/bash
# check_snmp_synology for nagios version 2.2
# 16.04.2015  Nicolas Ordonez, Switzerland
#---------------------------------------------------
# this plugin checks the health of your Synology NAS
# - System status (Power, Fans)
# - Disks status
# - RAID status
# - DSM update status
# - Te
mperature Warning and Critical
So, we have the new plugin. Let's test it.

Testing the plugin


We can test that the plugin works by running it in the synagios chroot before setting it up properly.

First we'll make it runnable with:
chmod +x check_snmp_synology
Then run it to see the options:
./check_snmp_synology
It should show a few options. Let's try it with options:
./check_snmp_synology -2 public -h 127.0.0.1
This did not work for me as SNMP was not enabled on my diskstation, so it failed with:
 CRITICAL - Problem with SNMP request, check user/password/host
I logged into my diskstation DSM using the Web Browser and opened the control panel, then searched for 'snmp' and opened 'Terminal and SNMP'. I then enabled 'SNMPv1, SNMPv2c service'.

Trying './check_snmp_synology -2 public -h 127.0.0.1' again worked the second time.

If you don't get the plugin working then don't continue with the rest of this tutorial!

So, now that the nagios plugin works from the command line, lets use it.

Adding the Plugin to Synagios


First we will move the Nagios plugin we downloaded to the $USER5$ directory:
mv ~/tmp/check_snmp_synology /usr/local/nagios/plugins/
Next we add a new command using the Nagrestconf GUI:
  1. Switch to the Nagrestconf GUI.
  2. Click the 'Commands' tab.
  3. Click the 'Add new command' icon at the top right of the table.
  4. For 'Command name' enter 'check_snmp_synology'.
  5. For 'Command' enter '$USER5$/check_snmp_synology $ARG1$'.
  6. Click 'Create Command'.


This command can now be used in other tabs. It can be added to service sets or directly to hosts. For speed we'll add it directly to the host:
  1. Click the 'Hosts' tab.
  2. Click on 'diskstation' to see the list of all checks for that host.
  3. Click the 'Add new service' icon at the top right of the inner table.
  4. Choose the Service Template 'svctmpl-lin'.
  5. For 'Command' enter 'check_snmp_synology!-2 public -h 127.0.0.1'.
  6. For 'Description' enter 'Synology'.
  7. Leave the other fields blank and click 'Create Service'.

Now apply this new configuration:
  1. At the top left of the screen, click the 'Apply Changes' button.
  2. Click 'Apply Configuration'.
The plugin is now added and the new 'Synology' check will appear in the Nagios GUI. Log into the Nagios GUI to check the status.


Troubleshooting


Errors in the Nagios GUI:

(Return code of 126 is out of bounds - plugin may not be executable)
  •  The plugin is not executable. The 'chmod +x' step was not done, as shown above.
(Return code of 127 is out of bounds - plugin may be missing)
  • The plugin was copied to the wrong place, or,
  • The Command in the Nagrestconf GUI was misspelt, or,
  • Then Command in the Nagrestconf GUI uses the wrong USER variable


Monitoring another Synology NAS


I have another synology NAS that I will try monitoring using the one I just set up. I will only use the check_snmp_synology plugin installed above.

First I need to enable SNMP on the other NAS using the Diskstation DSM as above.

In the Nagrestconf GUI I'll add a host, diskstation2:
  1. Click the 'Hosts' tab.
  2. Click the 'Add new host' icon at the top right of the main table.
  3. For 'Host name' and 'Alias' enter 'diskstation2'.
  4. For 'IP Address' enter the IP address.
  5. Click 'Create Host'.
Add the check_snmp_synology service as done before, but this time for diskstation2 and with a different IP address (using a nagios macro):
  1. Click the 'Hosts' tab.
  2. Click on 'diskstation2' to see the list of all checks for that host.
  3. Click the 'Add new service' icon at the top right of the inner table.
  4. Choose the Service Template 'svctmpl-lin'.
  5. For 'Command' enter 'check_snmp_synology!-2 public -h $HOSTADDRESS$'.
  6. For 'Description' enter 'Synology'.
  7. Leave the other fields blank and click 'Create Service'.
Now apply this new configuration:
  1. At the top left of the screen, click the 'Apply Changes' button.
  2. Click 'Apply Configuration'.
The new NAS, diskstation2, will appear in the Nagios GUI with a single check. Log into the Nagios GUI to check the status.

Tweaking


If you have a few Synology NAS devices to monitor then you might want to add the check_snmp_synology service check to a Service Set. Then, when adding a new host, you only need to specify the Service Set and the check will be added automatically. Adding new hosts could be done in the Nagrestconf GUI, one by one, by using Bulk Tools and supplying a comma delimited file, or by using REST commands in a script.

You may have noticed that I used the command 'check_snmp_synology!-2 public -h 127.0.0.1' the first time then 'check_snmp_synology!-2 public -h $HOSTADDRESS$' the second time. The latter command, with '$HOSTADDRESS$', could have been used for both commands instead.