back.gif

next.gif


Using the MONyog API

 

You can access the API by passing parameters to MONyog through its base URL.

For example, if MONyog is running on a system with IP 192.168.1.1, then the parameters need to be passed to:

 

http://192.168.1.1:5555/

 

You can use either of the HTTP methods GET and POST.

 

The Parameters

The parameters that you will need to pass are:

 

 

Besides, if server names/IDs (_server) and (_tag) are not specified then the specified action would be performed globally.

 

 

For example, suppose you have a server named Production001 registered with MONyog. To stop data collection for this server using the HTTP GET method, the URL would look like:

Curl “http://192.168.1.1:5555/?_object=MONyogAPI&_action=DataCollection&_value=disable

&_password=mypassword&_server=Production001”  

 

In summary, the various URLs that you can use with curl:

curl "http://192.168.1.1:5555/?_object=MONyogAPI&_action=DataCollection&_value=enable&_user=admin&_password=Password

&_server=Production001"

 

 

curl "http://192.168.1.1:5555/?_object=MONyogAPI&_action=DataCollection&_value=disable&_user=admin&_password=Password

&_server=Slave+Of+Production"

 

curl "http://192.168.1.1:5555/?_object=MONyogAPI&_action=DataCollection&_value=enable&_user=admin&_password=Password

&_tag=Production"

 

curl "http://192.168.1.1:5555/?_object=MONyogAPI&_action=DataCollection&_value=disable&_user=admin&_password=Password

&_tag=Production"

 

 

curl "http://192.168.1.1:5555/?_object=MONyogAPI&_action=Alerts&_value=enable&_user=admin&_password=Password

&_server=Production001"

 

curl "http://192.168.1.1:5555/?_object=MONyogAPI&_action=Alerts&_value=disable&_user=admin&_password=Password

&_server=Production001"

 

 

curl "http://192.168.1.1:5555/?_object=MONyogAPI&_action=Alerts&_value=enable&_user=admin&_password=Password

&_tag=Production"

 

curl "http://192.168.1.1:5555/?_object=MONyogAPI&_action=Alerts&_value=disable&_user=admin&_password=Password

&_tag=Production"

 

curl "http://192.168.1.1:5555/?_object=MONyogAPI&_action=sniffer&_value=enable&_server=Production001"

 

curl "http://192.168.1.1:5555/?_object=MONyogAPI&_action=sniffer&_value=disable&_server=Production001"

 

 

Return Codes

Assuming that the connection to MONyog was successful, it will return a text message. The message will be in the JSON format:

{“STATUS”: “SUCCESS/FAILURE”, “RESPONSE” : “<Response text>”}

Your application can parse this message and determine whether the operation was successfully carried out or not.

 

NOTE: Since version 5.21 we have deprecated the API calls to "_object=ConnectionMgr". Instead use "_object=MONyogAPI".

 

Applications

The MONyog API is very flexible and can be accessed from other programming languages including scripting languages such as Perl, VBScript, etc.  Here is a very generic Perl script that accepts the required parameters from the command line and executes the specified action:

#! /usr/bin/perl

use LWP 5.64;

 

# USAGE: MONyog.pl <hostname>:<port> <password> <connection_name/ID> <action> <value>

# $ARGV[0] = hostname:port of server running MONyog

# $ARGV[1] = MONyog password

# $ARGV[2] = connection name

# $ARGV[3] = action

# $ARGV[4] = value

 

 

my $numArgs = $#ARGV + 1;

 

if($numArgs < 4) {

    die 'USAGE: MONyog.pl <hostname>:<port> <password> <connection_name/ID> <action>';

}

 

my $browser = LWP::UserAgent->new;

 

# The request URL

my $url = URI->new('http://' . $ARGV[0] . '/');

 

# The form data pairs:

$url->query_form(

    '_object' => 'MONyogAPI',

    '_action' => $ARGV[3],

    '_password' => $ARGV[1],

    '_server' => $ARGV[2],

    '_value' => $ARGV[4]

);

 

# The response object

$response = $browser->post($url);

if (!$response->is_success) {# Error connecting to MONyog

    die $response->status_line . "\n";

}

  else { # Successfully connected to MONyog; print MONyog's response

    print $response->content . "\n";

}

 

back.gif

next.gif