QueueManagerStatusController

The second part of the URI must be qmstatus to call the QueueManagerStatusController.

inquire

Returns all status information attributes of the queuemanager with the given name. This action executes the MQCMD_INQUIRE_Q_MGR_STATUS pcf command. On success, the returned JSON object will have a data array, on failure an error object.

HTTP_NOT_IMPLEMENTED will be returned when this command is send to a queuemanager on a z/OS system. MQCMD_INQUIRE_Q_MGR_STATUS is not available for z/OS.

URL Parameters

/api/qmstatus/inquire/<QueueManager>

QueueManager

The name of the queuemanager. This parameter is required.

Query Parameters

QMStatusAttrs

With the QMStatusAttrs parameter you can specify which attributes must be returned from the PCF command. Multiple occurences of this parameter are possible. The value must be a (case-sensitive) valid attribute name.

Attrs is a synonym for QMStatusAttrs

Example

/api/qmstatus/inquire/PIGEON

<?php
	/*
	 * This sample will show the startdate/time of queuemanager PIGEON.
	 * MQWeb runs on localhost and is listening on port 8081. 
	 */
	$url = "http://localhost:8081/api/qmstatus/inquire/PIGEON";

	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

	if ( ($response = curl_exec($curl)) === false )	{
		$err = curl_error($curl);
		echo 'An HTTP error occurred while inquiring queuemanager status: '
			. $err
			. PHP_EOL;
	}
	else {
		$json = json_decode($response);
		if ( isset($json->error) ) {
			echo 'An MQ error occurred while inquiring queuemanager status.'
				. PHP_EOL;
			echo 'Reason Code: '
				. $json->error->reason->code
				. ' - '
				. $json->error->reason->desc
				. PHP_EOL;
		}
		else {
			if ( isset($json->data) && count($json->data) > 0 ) {
				echo $json->data[0]->QMgrName->value
					. ' started on '
					. $json->data[0]->StartDate->value
					. ' '
					. $json->data[0]->StartTime->value
					. PHP_EOL;
			}
			else {
				echo 'No status found' . PHP_EOL;
			}
		}
	}

JSON Object

When using an application/json POST request you can post a JSON object with names like the query parameters.

All URL parameters and query parameters are ignored except for the URL parameter for the name of the queuemanager.

{
  'QMStatusAttrs' : [
    'StartDate',
    'StartTime'
  ]
}

There are some differences between query parameters and a JSON object:

This is a Perl example that inquires a queuemanager to get the start date and time of the queuemanager.

#!/usr/bin/perl
use strict;
use warnings;
use feature qw(say);

use JSON;
use LWP::UserAgent;
use HTTP::Request::Common;

my $qmgr = shift;
die("Please pass me the name of a queuemanager as argument") unless defined($qmgr);

my $json = JSON->new;

my %input = ( 
);

my $content = $json->encode(\%input);    

my $ua = LWP::UserAgent->new;
my $req = POST 'http://localhost:8081/api/qmstatus/inquire/' . $qmgr;    
$req->header(
	'Content-Type' => 'application/json',
	'Content-length' => length($content)
);
$req->content($content);

my $res = $ua->request($req);
die $res->status_line unless $res->is_success;

my $mqweb = $json->decode($res->content());
if ( exists($mqweb->{error}) ) {
	say 'An MQ error occurred while inquiring queuemanager status.';
	say	'Reason Code: ',
		$mqweb->{error}->{reason}->{code},
		' - ',
		$mqweb->{error}->{reason}->{desc};
}
else {
	say $mqweb->{data}->[0]->{QMgrName}->{value},
		' : ', 
		$mqweb->{data}->[0]->{QMgrStatus}->{text};
}