Bug #34295 Document script to use with blackout period API
Submitted: 4 Feb 2008 20:35 Modified: 5 Feb 2008 21:34
Reporter: Mark Leith Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Enterprise Monitor: Documentation Severity:S3 (Non-critical)
Version:1.3 OS:Any
Assigned to: Peter Lavin CPU Architecture:Any

[4 Feb 2008 20:35] Mark Leith
Description:
It would be nice to document a script to be used with the blackout API of MEM.

How to repeat:
Try to work out how to incorporate a call to the API URL within a shell based backup script.. 

Suggested fix:
Document:

#!/usr/bin/perl

use LWP 5.64;

# USAGE: blackout.pl servicemanager:18080 admin password servername:3306 true
# $ARGV[0] = management server hostname:port
# $ARGV[1] = management server userid
# $ARGV[2] = management server password
# $ARGV[3] = mysqld managed instance server name
# $ARGV[4] = blackout state (true/false)

my $browser = LWP::UserAgent->new;
$browser->credentials(
$ARGV[0],
'',
$ARGV[1] => $ARGV[2]
);

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

$url->query_form( # And here the form data pairs:
'command' => 'blackout',
'server_name' => $ARGV[3],
'blackout_state' => $ARGV[4]);

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

if ($response->is_success) {
print $response->content ;
}
else {
die $response->status_line;
}
[5 Feb 2008 20:26] Sloan Childers
How about we change the example script to only check for the error condition instead of changing server behavior?

if (!$response->is_success) {
die $response->status_line;
}
[5 Feb 2008 21:00] Peter Lavin
Hi Sloan,

Okay, I've changed the script to check for an error condition only. 

One last question. The URL can be specified as http://tomcat_server/merlin/inventory" or as "http://tomcat_server/merlin/rest". One is an alias for the other I assume. Any preference as to which one appears in the documentation?
[5 Feb 2008 21:11] Sloan Childers
For 1.2 I moved all the public APIs to /rest.  /inventory will still map you to /rest to maintain backwards compatibility with customer scripts.
[5 Feb 2008 21:34] Peter Lavin
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.