
In the life of every system administrator, sooner or later there comes a time when the eye and hands are no longer enough to keep track of all the servers, then there are some problems there, and to solve them, I really want to know what was "before that". And it is here that they come to the rescue - led
Other and terrible monitoring systems. For a long time, I used
Nagios , and still, with all the convenience, I can’t call anything like monstrous. As a result, only 10% of the capabilities of this beautiful system were used. Everything changed when I stumbled upon
Munin - the perfect solution for monitoring small networks.
The system itself consists of two independent parts: a server (munin itself), installed on one machine, where all data will be collected, and a small munin-node daemon, which is installed on machines that we will monitor. This daemon itself is a small Perl script that listens to port 4949 using Net :: Server. When it starts, it scans the plugins installed in / etc / munin / plugins and remembers their names. Every 5 minutes, the munin server connects to all the nodes, receives information from all the plug-ins and saves itself in the rrdtool database. Thus, Munin doesn’t even need MySQL.
Plugins are the most delicious thing in Munin. The incredible simplicity of their implementation allows you to write plug-ins for everything you want in the system, spending a minimum of time reading the documentation. Apparently this explains the fact that the relatively young system has already acquired a large number of
ready-made plug-ins .
In fact, each plug-in is an executable file, which should output the current values ​​of the parameters.
The easiest thing to understand is the simplest example.
For the management of the network, I really like it when all the “livelihoods” of the network are presented in clear graphs that allow them to quickly assess what is happening. And the very first schedule that I was asked to make was the number of people now connected to the Internet.
FreeBSD (MPD) is used as a NAS. Clients are connected via PPTP, so the number of existing ng interfaces corresponds exactly to the number of subscribers online (since mpd5 learned how to “sweep extra interfaces”). In other words, we can get the required value with the command
ifconfig | grep ^ ng | wc -l
Everything. this is enough to implement the plugin. In this case, to implement the plugin, sh is enough for us (although no one forbids using bash / perl / ruby ​​/ what-you-want-and-know) to write plug-ins.
Here is the code for the plugin itself:
')
#! / bin / sh
#
# Plugin for monitoring the number of billing users
#
if ["$ 1" = "config"]; then
echo 'graph_title Billing users'
echo 'graph_vlabel users'
echo 'graph_noscale true'
echo 'graph_category billing'
echo 'users.label users'
echo 'graph_info This graph shows the amount of users connected to the Internet';
echo 'users.info Users amount'
exit 0
fi
echo -n „users.value“
echo `/ sbin / ifconfig | / usr / bin / grep '\ - > ' | wc -l`
Thus, we see that the only parameter processed by the script is the magic word config. It is this that is passed to the munin plugin at the first request. In response, the script should return the future schedule specifications for rrdtool. For full documentation, I refer you to the wonderful
plugin writing guide for Munin, but now I’ll review only the parameters I use.
graph_title Billing users
is just a graph title. I draw your attention to the fact that, at least on FreeBSD, rrdtool does not work correctly with the great and mighty, so you have to manage with English;
graph_vlabel users
- put the value of the
users
parameter on the vertical axis;
graph_noscale true
- disable rrdtool to scale the graph. This is useful for postponing real values ​​along the axis (2000 users instead of 2 * 10
3 );
graph_category Billing
- category graphics. Charts from one category will be formed on one page;
users.label users
- the name of the „users“ axis. It should be short enough to fit on the chart;
users.info Users amount
- description of the axis;
The existence of munin-node-win was a very pleasant discovery for me, which allows you to monitor Windows-servers, which, albeit in small quantities, are present with me.
And finally, a few words about what is actually on the way out. I think the
demo will say better than a thousand words - at the output we have generated html without a hint of scripts.
useful linksmuninexchange.projects.linpro.no is a collection of ready-made plugins for Munin.
Comparison of network monitoring systems is an extremely informative table in Wikipedia, which allows you to quickly assess whether this or that monitoring system is suitable for you.
linux-blogspot.com/2007/02/munin.html - about installing Munin in Russian.
munin.projects.linpro.no/wiki/HowToContactNagios - friends of Nagios and Munin