Monitis announces even more simple way to access API through Perl interface — a high-level, general-purpose, interpreted, dynamic programming language.
The new Monitis CPAN module is now publicly available. CPAN, the Comprehensive Perl Archive Network, is an archive of over 90,000 modules of software written in Perl, as well as documentation for it. Monitis CPAN Perl library acts as an interface to Monitis leading systems monitoring platform and utilizes Monitis’s REST Application Programming Interface (API) . The code is publicly available at Monitis’ github open source repository.
CPAN automatically installs the module. And now you can install Monitis’s Perl library simply by typing:
sudo cpan Monitis
Before you start to use Perl interface, you should initialize it by authenticating your API key and Secret key. You must have a valid Monitis account and get the key using web interface under Tools -> API -> API key. Here is a Monitis session initialization code fragment:
use Monitis; my $api = Monitis->new( api_key => 'YOUR_API_KEY', sekret_key => 'YOUR_SECRET_KEY' );
That’s it! How simple is that?!
Now you can interact with Monitis API, add uptime and perfomance monitors and get any info you need right from your script. An extra plus is that you don’t need to think about authentication, generating checksums and parsing response because the Monitis package will do all this work for you.
Monitis API has a number of sections, as described in API documentation. To make usage simpler, there’s separate package and context for each section. For example, if you want to get a list of all your agents, you should run:
my $agents = $api->agents->get;
On the Monitis website, you can find a full list of context methods and corresponding packages available as package documentation under ‘context methods‘.
Benefits of Perl
Perl interface has many benefits to the sysadmin. Perl controls the parameters you pass to each call. And it warns you about wrong parameter names. So, this is an easy way to find typos.
Also Perl interface stops execution if one or more of mandatory parameters are not passed to their calls. For example, if you try to run sub_accounts->add() without any parameters, your script will stop execution and you will see a warning message:
Missing mandatory parameters: firstName, lastName, email, password, group
Some methods like cpu->add requires an Agent name or Agent ID. Those are unique identifiers of agent that you will want to use for this request. You can get this information during agent installation or using the agents->get method.
Now when you have Monitis Perl interface installed and set up you can automatize any task with Monitis, like creating custom monitors, producing operating statistics or displaying certain data right on your site.