Monitis Monitor Manager Raw Commands Explained

free-website-monitoringIncentive for raw commands

M3 (or its newer version which you should be using – M3v3) can do pretty much. However it can’t do anything.
M3 is good at timing execution of commands, apply simple parsing and upload the data to Monitis. Allowing you as the SysAdmin (and end-user of M3) to easily shape and design Custom Monitors for your system improving overall system uptime and stability.
Many times this is indeed what happens when trying to monitor different applications. The simple process of ‘Execution -> Parsing -> Reporting’ gets the job done. What happens when it doesn’t?
Well, I’ll tell you what happens – you are left a bit puzzled and think you’ll have to implement the Custom Monitors API which Monitis provide. True – until not long ago.
M3v3 bring you ‘Raw Commands’ capability in its last version.

Custom Monitors – What You Really Need

The Monitis REST API provides us with a rich set of commands to control Custom Monitors. From them, I believe the most important are these four:

  1. List monitors
  2. Delete monitor
  3. Add monitor
  4. Add monitor data

Looking at the REST API documentation, the implementation of these commands might look frightening, however, M3v3 does most of the work for you. Don’t believe me? – read on.

What are M3 raw commands?

M3v3 implements the mentioned above actions against Monitis so it is very easy for you, the end user, to easily upload monitoring data to Monitis, be it anything from network performance, server uptime, application availability or anything else which crosses your mind.
Sounds good, how do you invoke it?
Here we go, it is extremely simple. From here on I assume you have M3v3 properly installed on your system, and if you don’t – please refer to here.
Lets list our available monitors:

 $ monitis-m3 --raw "list_monitors" Using /home/dan/.m3/M3Templates.pm as M3Templates.pm Raw command is: 'list_monitors' Listing monitors...OK ID   |Name           |Tag                      |Type           | -----|---------------|-------------------------|---------------| 8557 |CPU            |CPU                      |UGA            | 10900|Telnet test    |Telnet_test              |Telnet test    |

Deleting a monitor is just as simple, lets delete the ‘Telnet test’ monitor – I don’t need it anymore, we’ll need its ID:

 $ monitis-m3 --raw "delete_monitor 10900" Using /home/dan/.m3/M3Templates.pm as M3Templates.pm Raw command is: 'delete_monitor 10900' Deleting monitor with ID '10900'...OK

List again, if you don’t believe me:

$ monitis-m3 --raw "list_monitors" Using /home/dan/.m3/M3Templates.pm as M3Templates.pm Raw command is: 'list_monitors' Listing monitors...OK ID   |Name           |Tag                      |Type           | -----|---------------|-------------------------|---------------| 8557 |CPU            |CPU                      |UGA            |

Makes things simple, isn’t it? Great, lets move on.

Adding monitors and uploading data

Lets add a monitor for memory with 2 counters, ‘free’ and ‘active’:

$ monitis-m3 --raw "add_monitor memory memory free:free:MBytes:2;total:total:MBytes:2" Using /home/dan/.m3/M3Templates.pm as M3Templates.pm Raw command is: 'add_monitor memory memory free:free:MBytes:2;total:total:MBytes:2' Adding monitor 'memory'...OK

For ‘add_monitor’ raw command, the parameters are as follow:

  1. Monitor name
  2. Monitor tag
  3. Formatted parameters for monitor – refer to the Monitis API

And updating data is as easy as it gets. Lets assume just for the example we want to update that we have 1500MB free out of 2048MB:

 $ monitis-m3 --raw "update_data memory memory free:1500;total:2048" Using /home/dan/.m3/M3Templates.pm as M3Templates.pm Raw command is: 'update_data memory memory free:1500;total:2048' Queuing item: '' => 'memory' => 'free:1500;total:2048' (TS: '1337363509') (TAG: 'memory') at /usr/share/perl5/MonitisMonitorManager.pm line 507 Reporting: 'free:1500;total:2048' Stopping execution of MonitisConnection... at /usr/share/perl5/MonitisMonitorManager.pm line 114 Updating data for monitor 'memory'...OK

For ‘update_data’ raw command, the parameters are as follow:

  1. Monitor name
  2. Monitor tag
  3. Formatted parameters for monitor – refer to the Monitis API

To be honest, that’s the most of it. This is how you can easily play with Custom Monitors on Monitis. I’m hoping for some feedback soon!

With M3 and Monitis anything can be monitored. Follow us on github and twitter.

You might also like