The everlasting flame war.
So after reading this, it was time to show the world yet again that Linux is better than Windows. Duh.
In the mentioned article, we showed how to integrate into Monitis database query results from a MS SQL Server.
Many times while monitoring a system, you are not interested in “dry” counters such as I/O, memory, CPU, etc. Many times the more interesting counters would be a bit more applicative. These applicative counters usually reside within databases backends of such systems. And if it can be done on Windows, it can definitely be done on Linux, because we all know Linux is better!
But… why would I do it?
So you have a system which manages users in an organization. You license the system in such a way that a cheap license is up to 100 users, a comprehensive one is up to 1000 users and you obviously have an unlimited one.
So day to day, you’re monitoring the health of your systems at your clients’ sites. You’re all happy, just until the moment a raging client calls you in the middle of the night (because obviously he is in a different timezone) angry because he can’t add more users. Why? – because he exceeded his license and you never realized it until it was too late.
Imagine you got a notification a week before the fiasco happened, you call the client, telling him “Hey, you are about to exceed your license, please upgrade” – client upgrades happily and thanks you. You also know that counting the users a client has is as easy as “select count(*) from users;” on his database, which is monitored anyway.
So why didn’t you do it?
Easing the pain
I obviously can’t characterize the counters that are important to you. But what I can do is offer you a very easy interface for implementation.
I suggest having this example open while adding new counters.
Let’s get dirty with some Perl and Bash, ready? – let’s go:
# mkdir -p /usr/share/monitisexchange && cd /usr/share/monitisexchange # git clone git://github.com/monitisexchange/Monitis-Linux-Scripts.git # cd Monitis-Linux-Scripts/DBI # vim monitis_config
Use your API key and secret key while editing monitis_config.
Edit the configuration:
# cp monitis_dbi_config_sample.pl monitis_dbi_config.pl # vim monitis_dbi_config.pl
In this example there is one monitor to monitor the number of cakes in a MySQL database.
Then the second monitor deals with Italian food.
Yes I know, these examples are not practical for you, but it doesn’t matter.
What you should do is define the monitors and counters you want, then the rest of the parameters, such as the DB type, the query you wish to run, etc.
When you’re done, check your syntax with:
# perl -c monitis_dbi_config.pl
We’re almost done, let’s add all the monitors to Monitis:
# ./monitis_dbi.pl add_monitors
Then, we can update data and check that it actually succeeded:
# ./monitis_dbi.pl update_data
If you just want to check your configuration, a dry run is also possible (it will not update the counters in Monitis, but only run the query and display the results):
# ./monitis_dbi.pl “update_data(1)”
By hook or by crook
If there’s something I’ve learned in life, is that only rarely the good stuff happens magically by itself. But in this case it isn’t hard to make it happen. Decide what your resolution would be for updating your DB counters, and then add it accordingly as a cronjob. For a 5 minute resolution, use:
# echo “*/5 * * * * root cd /usr/share/monitisexchange/Monitis-Linux-Scripts/DBI && ./monitis_dbi.pl update_data >& /dev/null” > /etc/cron.d/monitis_dbi
Some authentic (yet boring) data sampled from my database:
Yes, during these hours of the day – I have the same number of cakes in my fridge – 12!
And this is just the tip of the iceberg.
DevOps and Sysadmins together, can use this interface for graphing many counters in their systems, providing interesting graphs such as business transactions per minute, sales per day, complaints per week and much more!
This is your chance to consolidate all of these graphs into one unified interface – Monitis – and impress your boss with beautiful graphs of key performance counters in his business.
Once you’ve got all the interesting counters, we both know how easy it is to configure alerts and notifications in Monitis for the things that really matter.
Alert your customer and boss about problems before they happen and ride the fame!