This is the old XigmaNAS forum in read only mode,
it will taken offline by the end of march 2021!



I like to aks Users and Admins to rewrite/take over important post from here into the new fresh main forum!
Its not possible for us to export from here and import it to the main forum!

[HOWTO] Monitor NAS4Free with Munin Inside Jail

Jails with XigmaNAS
Forum rules
Set-Up GuideFAQsForum Rules
Post Reply
Snunn1
Starter
Starter
Posts: 35
Joined: 05 Sep 2013 21:55
Status: Offline

[HOWTO] Monitor NAS4Free with Munin Inside Jail

Post by Snunn1 »

[HOWTO] Monitor NAS4Free with Munin Inside Jail

Tested on:
NAS4Free 9.1.0.1 - Sandstorm (rev 847 & 943)
Platform x64-FULL on a VirtualBox VM on HP Microserver N40L (AMD64)
Tested and Working on Apache 2.2 without additional configuration

This guide will detail how to install Munin in a jail to monitor network devices. This will require no previous experience or knowledge of Munin or Apache and will consist of as minimal configuration as possible to get you started. There will always be other, better ways in doing most of this however the methods outlined here have worked for me and should minimise any confusion/frustration.

This guide assumes you have a system running a default installation of N4F with the IP address 192.168.1.250. This server has a new jail called 'munin' with an IP address of 192.168.1.251, has fully working Internet access, SSH and a file editor (Nano).

Before I begin, I give credit to the following which this guide is based on:

Monitor Systems Using Munin
Munin Monitoring

Munin works in a master/node configuration whereby Munin-Master is installed on the system which will do the monitoring and Munin-Node is installed on the system(s) which need to be monitored. In this example, the N4F host 192.168.1.250 will be the system we want to monitor - this is using the FULL version of N4F, not Embedded.

To start with, SSH to your server and enter one of the two commands below depending on whether your system is AMD or Intel based:

Code: Select all

setenv PACKAGESITE "ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9-current/Latest/"

setenv PACKAGESITE "ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-9-current/Latest/"
Next, the necessary packages or ports need to be installed, this guide will outline the procedure for both.

If you want to install the FreeBSD Ports Collection, install it with the following commands:

Code: Select all

portsnap fetch extract
If it's already installed, make sure it's up to date:

Code: Select all

portsnap fetch update
Next, install the Munin-Node port:

Code: Select all

cd /usr/ports/sysutils/munin-node/
make install clean
If you're using packages:

Code: Select all

pkg install sysutils/munin-node
Next, edit the Munin-Node configuration file to allow Munin-Master to access it:

Code: Select all

nano /usr/local/etc/munin/munin-node.conf
Scroll down to the line which says:

Code: Select all

allow ^127\.0\.0\.1$
allow ^::1$
And add:

Code: Select all

allow ^192\.168\.1\.251$
So it should now show as:

Code: Select all

allow ^127\.0\.0\.1$
allow ^::1$
allow ^192\.168\.1\.251$
Once complete, save and exit the file. The next step is for Munin-Node to configure itself:

Code: Select all

/usr/local/sbin/munin-node-configure --shell | sh -x
This command will list all of the plugins which Munin-Node will use - plugins are what make Munin as customisable as it is. To start the Munin-Node program, enter the following:

Code: Select all

/usr/local/etc/rc.d/munin-node onestart
To ensure it starts everytime the host is restarted, add 'munin_node_enable="YES"' on the N4F GUI (System -> Advanced -> rc.conf) as per this screenshot:
N4F - Munin-Node.jpg
Once the Munin-Node installation is complete, list the jails so we can set up Munin-Master:

Code: Select all

Welcome to NAS4Free!
nas4free: ~ # jls
   JID  IP Address      Hostname                      Path
     1  192.168.1.251   munin.local            /jail/munin
Then enter the jail:

Code: Select all

nas4free: ~ # jexec 1 csh
root@munin:/ #
Once in the jail, check the hosts file and make sure it matches how you've setup your host and jail:

Code: Select all

root@munin:/ # cat /etc/hosts
::1 localhost localhost.local
127.0.0.1 localhost localhost.local
192.168.1.250 nas4free nasfree.local
192.168.1.251 munin munin.local
If it doesn't look like the above, enter the following

Code: Select all

echo '192.168.1.250 nasfree nas4free.local' >> /etc/hosts
echo '192.168.1.251 munin munin.local' >> /etc/hosts
Next, we need to install the necessary packages or ports within the jail in the same way as we did for the N4F host.

Enter one of the two commands below depending on whether your system is AMD or Intel based:

Code: Select all

setenv PACKAGESITE "ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9-current/Latest/"

setenv PACKAGESITE "ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-9-current/Latest/"
If you want to use the FreeBSD Ports Collection, install it with the following commands:

Code: Select all

portsnap fetch extract
If it's already installed, make sure it's up to date:

Code: Select all

portsnap fetch update
Next, install the Apache 2.2 port (this may take a while and install a lot of dependancies):

Code: Select all

cd /usr/ports/www/apache22
make install clean
If you're using packages:

Code: Select all

pkg install www/apache22
To ensure Apache starts automatically, enter the following:

Code: Select all

echo 'apache22_enable="YES"' >> /etc/rc.conf
Once that's complete, install Munin-master (same note applies as the Apache install above):

Code: Select all

cd /usr/ports/systils/munin-master/
make install clean
And with packages:

Code: Select all

pkg install sysutils/munin-master
Once these are installed by either method, we need to edit the Munin-Master configuration file to tell it about the system(s) it will need to monitor:

Code: Select all

nano /usr/local/etc/munin/munin.conf
Scroll down to the line which says:

Code: Select all

# a simple host tree
[munin.local]
    address 127.0.0.1
    use_node_name yes
And add the following below it:

Code: Select all

[nasfree.local]
    address 192.168.1.250
    use_node_name yes
So it should look like this by the time you've finished:

Code: Select all

# a simple host tree
[munin.local]
    address 127.0.0.1
    use_node_name yes

[nasfree.local]
    address 192.168.1.250
    use_node_name yes
Once you've saved and exited the file, we need to tell Apache about Munin, so enter the two commands below:

Code: Select all

touch /usr/local/etc/apache22/Includes/munin.conf
nano /usr/local/etc/apache22/Includes/munin.conf
And paste the following into it before saving and exiting:

Code: Select all

Alias /munin "/usr/local/www/munin"

<Directory /usr/local/www/munin>
Options none
AllowOverride Limit
Order Deny,Allow
Deny from all
Allow from all
</Directory>
You'll also need to delete the following file before starting Apache:

Code: Select all

rm -rf /usr/local/www/munin/.htaccess
Once you get to this point, all you need to do is to sanity check the Apache config to check for typos:

Code: Select all

/usr/local/etc/rc.d/apache22 configtest
If it responds with 'Syntax OK', you'll be able to start it:

Code: Select all

/usr/local/etc/rc.d/apache22 start
To test Munin, enter http://192.168.1.251/munin into your browser and the Overview page should show up.
Munin - Overview.jpg
Click on the N4F host and a list of graphs will be displayed on a daily/weekly/monthly/yearly basis:
Munin - Graphs.jpg
And that's it - Munin will now be graphing everything for your N4F host!

Munin is very customisable so it may take a while to configure it as you want it, however there's plenty of additional plugins etc. on Google should you wish to.

I hope some of you find this guide useful, any corrections or recommendations are welcome.
You do not have the required permissions to view the files attached to this post.
NAS4Free 10.2.0.2.2545 P14 Embedded on 1GB USB Key
HP N40L Microserver - 8GB ECC RAM, 3x Seagate 500GB RAIDZ1, 1x Seagate 500GB UFS & 1x 200GB SATA
Extensions: RRDGraphs

Post Reply

Return to “Jails”