This section describes how to delete information on assets, and
groups of assets, from MySQL Enterprise Monitor's inventory, using the
curl
utility on the command line.
Deleting assets from the inventory does not delete or uninstall assets from their installed locations. The delete process removes all record of an asset or group of assets from the internal record of MySQL Enterprise Service Manager, only. This enables you to remove entries for clusters, topologies, and instances which were monitored, but are no longer in use.
Ensure the asset or group is either not running, or not installed, before attempting to delete it from the inventory.
For more information on the inventory, see Appendix B, Managing the Inventory.
This section describes the following:
Retrieving Deletable Asset Information: how to check what is deletable.
Listing the Related Deletable Assets: how to check for related assets and their status.
Deleting Assets from the Inventory: how to delete assets.
Request Status Codes: return codes from the various request types.
The curl utility can be used to request information directly from MySQL Enterprise Service Manager's inventory of monitored assets. To retrieve information on whether the specific asset can be deleted, retrieved as a JSON array, execute a curl request with the following syntax:
curl -k -v --user username:password
"https://servername:port/v4/inventory/AssetType/AssetID/deletable
where:
username:password
is the username and password of a user with admin access to MySQL Enterprise Service Manager.servername:port
is the servername and port number for MySQL Enterprise Service Manager.AssetType
is the type of asset information you want to retrieve. The valid asset types are as follows:MySQL Instances:
com.mysql.etools.inventory.model.mysql.MysqlServer
MySQL Enterprise Monitor Agents:
com.mysql.etools.inventory.model.agent.Agent
NoteIt is not possible to delete an agent from the inventory if the agent's status is unknown, if the agent is running, or if the agent is monitoring one or more MySQL instances which are not scheduled for deletion in the same operation.
Hosts:
com.mysql.etools.inventory.model.os.Host
NoteIt is not possible to delete a host from the inventory if the host contains agents or MySQL instances which are not also scheduled for deletion in the same operation.
NDB Clusters:
com.mysql.etools.inventory.model.mysql.cluster.NdbCluster
NDB API Nodes:
com.mysql.etools.inventory.model.mysql.cluster.NdbApiNode
NoteDeleting an NDBAPINode also deletes the server.
NDB Data Nodes:
com.mysql.etools.inventory.model.mysql.cluster.NdbDataNode
NDB Management Nodes:
com.mysql.etools.inventory.model.mysql.cluster.NdbManagementNode
AssetID
is the unique, alphanumeric identifier of the asset type.NoteTo find the
AssetID
, check the inventory page for the specific asset type. See Appendix B, Managing the Inventory for more information.
The following example retrieves the information for a MYSQL
instance with the unique identifier
c14ee437-a615-11e4-8334-f8b156b72e61
:
In the following example, line breaks have been added for clarity.
curl -k -v --user admin:mysql
"https://localhost:18443/v4/inventory/com.mysql.etools.inventory.model.mysql.MysqlServer/
c14ee437-a615-11e4-8334-f8b156b72e61/deletable"
If the MySQL instance is deletable, the request returns the following data, confirming that the asset type can be deleted from the inventory:
"asset" : {
"id" : "c14ee437-a615-11e4-8334-f8b156b72e61",
"assetClass" : "com.mysql.etools.inventory.model.mysql.MysqlServer"
},
"isDeletable" : true,
"treeDeletable" : true,
"problems" : [ ],
"token" : "3b66cd39467791a739e5131a8d6a856b"
where:
asset
: lists the id and asset class of the requested asset.isDeletable
: True|False. Lists whether the asset's information can be deleted from the inventory.treeDeletable
: True|False. Lists whether related assets can be deleted.problems
: lists the reasons why the asset's information cannot be deleted from the inventory. Possible reasons are:ACL_FAIL
: the user has insufficient privileges to perform the operation.Deleting an asset requires the Administer permission for Server Group and MySQL NDB Cluster. To delete an asset from the inventory, the user must belong to a role with that permission.
For more information, see Section 23.3, “Monitored Assets Permissions”.
IS_LIVE
: the agent is running. The agent is running and broadcasting information to the Service Manager. It is not possible to delete a running asset from the inventory. To delete an asset from the inventory, you must first stop or uninstall it.UNKNOWN_LIVENESS
: The agent's state could not be determined. This problem can be caused by network issues, or some other issue, such as a power cut, preventing the Service Manager from contacting the agent.AGENT_HAS_UNRELATED_SERVER
: it is not possible to delete a server and related agent if the agent is monitoring a MySQL instance not included in the scope of the request. To include it, you must broaden the scope of the related request by including theagent
keyword.OS_HAS_UNRELATED_AGENT
: it is not possible to delete a host which contains an agent not scheduled for deletion. The host contains an agent which is not included in the request's scope. To include it, you must broaden the scope of the related request by including theagent
keyword.OS_HAS_UNRELATED_SERVER
: it is not possible to delete a host which contains a MySQL instance not scheduled for deletion. The host contains a MySQL instance which is not included in the request's scope. To include it, you must broaden the scope of the related request by including themysqlserver
keyword.
token
: a unique alphanumeric identifier for the state of the asset. This token can be used in aDELETE
request, to confirm the state of the asset has not changed between the time thedeletable
request was run, and the time theDELETE
request is run.
The request also returns a status code indicating the success or failure of the request. For more information, see Request Status Codes.
The related
request enables you to return data
on other assets which are related to the primary asset defined in
the type field. For example, using related, you can request
deletable information for a MySQL instance and for the agent
monitoring it, the host on which it resides, and so on.
related
also enables you to delete multiple
assets from the inventory with one request.
related
takes a comma-separated list of the
following values:
agent
: any agents related to the primary asset.mysqlserver
: any MySQL instances related to the primary asset.ndbcluster
: any NDBClusters related to the primary asset.os
: any hosts related to the primary asset.
The syntax of the request is as follows:
curl -k -v --user username:password
"https://servername:port/v4/inventory/AssetType/AssetID/deletable?
related=agent,mysqlserver,ndbcluster,os"
For example, the following requests deletable information on a
MySQL instance with the AssetID
c14ee437-a615-11e4-8334-f8b156b72e61
and on the
agent monitoring it:
curl -k -v --user admin:mysql
"https://localhost:18443/v4/inventory/com.mysql.etools.inventory.model.mysql.MysqlServer/
c14ee437-a615-11e4-8334-f8b156b72e61/deletable?related=agent"
The following JSON array is returned:
"asset" : {
"id" : "c14ee437-a615-11e4-8334-f8b156b72e61",
"assetClass" : "com.mysql.etools.inventory.model.mysql.MysqlServer"
},
"isDeletable" : true,
"treeDeletable" : false,
"problems" : [ ],
"children" : [ {
"asset" : {
"id" : "b68947f9-39f2-4003-981f-8c9cc7a7409f",
"assetClass" : "com.mysql.etools.inventory.model.agent.Agent"
},
"isDeletable" : false,
"treeDeletable" : false,
"problems" : [ {
"code" : "IS_LIVE",
"description" : "IS_LIVE"
} ]
} ],
"token" : "d0e3607f6029a91a35a9956950908761"
The data returned shows that while the MySQL instance is
deletable, it is not treeDeletable
, which means
it cannot be deleted in a related DELETE
,
because the monitoring agent is still running.
To delete individual assets from MySQL Enterprise Service Manager's inventory, use the following syntax:
Ensure the asset or group of assets is either not running, or not installed, before attempting to delete it from the inventory.
curl -k -v -X DELETE --header "X-Requested-With:XMLHttpRequest"
--header "If-Match:tokenID"
--user admin:mysql
"https://servername:port/v4/inventory/AssetType/AssetID"
To delete related assets from MySQL Enterprise Service Manager inventory, use the following syntax:
curl -k -v -X DELETE --header "X-Requested-With:XMLHttpRequest"
--header "If-Match:tokenID"
--user admin:mysql
"https://servername:port/v4/inventory/AssetType/AssetID?
related=agent,mysqlserver,ndbcluster,os"
--header "If-Match:tokenID"
is optional and
should only be used if you want to confirm the deletable
information is still accurate. If the tokenID is included, and
matches the value retrieved by the deletable request, the DELETE
operation is performed.
For example, the following shows a deletable request with the return data, listing a deletable agent, MySQL instance, the host it used to monitor, and another agent which was resident on the same server:
curl -k -v --user admin:mysql
"https://localhost:18443/v4/inventory/com.mysql.etools.inventory.model.agent.Agent/
d71ff41c-affd-4ebe-966e-395e6f06b5e3/deletable?related=mysqlserver,os,agent"
{
"asset" : {
"id" : "d71ff41c-affd-4ebe-966e-395e6f06b5e3",
"assetClass" : "com.mysql.etools.inventory.model.agent.Agent"
},
"isDeletable" : true,
"treeDeletable" : true,
"problems" : [ ],
"children" : [ {
"asset" : {
"id" : "sid:{S-1-5-21-700548433-2193620149-503502644}",
"assetClass" : "com.mysql.etools.inventory.model.os.Host"
},
"isDeletable" : true,
"treeDeletable" : true,
"problems" : [ ],
"children" : [ {
"asset" : {
"id" : "b68947f9-39f2-4003-981f-8c9cc7a7409f",
"assetClass" : "com.mysql.etools.inventory.model.agent.Agent"
},
"isDeletable" : true,
"treeDeletable" : true,
"problems" : [ ],
"children" : [ {
"asset" : {
"id" : "c14ee437-a615-11e4-8334-f8b156b72e61",
"assetClass" : "com.mysql.etools.inventory.model.mysql.MysqlServer"
},
"isDeletable" : true,
"treeDeletable" : true,
"problems" : [ ]
} ]
} ]
} ],
"token" : "7048b6e53c81f549b55c5f3e861c2eee"
The following example shows a related DELETE request, deleting all assets listed as deletable in the deletable example:
curl -k -v -X DELETE --header "X-Requested-With:XMLHttpRequest"
--user admin:mysql "https://localhost:18443/v4/inventory/com.mysql.etools.inventory.model.agent.Agent/
d71ff41c-affd-4ebe-966e-395e6f06b5e3?related=mysqlserver,os,agent"
It is not currently possible to delete an entire replication
topology, unlike NDB Cluster, which can be deleted using the
com.mysql.etools.inventory.model.mysql.cluster.NdbCluster
Asset type.
To delete the assets involved in a replication topology, you
must delete each individually, or use a
related
request type where possible.
The status code can be found in the following section of the return message, following the HTTP/1.1:
HTTP/1.1 200
Set-Cookie: JSESSIONID=8C0C2E1AFD45F170E7E41621F934723D; Path=/; Secure; HttpOnly
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Content-Type-Options: nosniff
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 24 Jul 2018 12:31:47 GMT
The following status codes are returned for
deletable
and DELETE
requests:
200
: the deletable request was successful. Content is returned in a JSON array.204
: the DELETE request was successful. No content is returned.400
: the request is not valid. Check the asset information, or the syntax of the request for errors, typos, and so on.403
: (DELETE
request, only) theX-Requested-With
header is not present.404
: incorrect AssetID provided.409
: it was not possible to perform the DELETE request. Further information is provided in a JSON array.412
: the requested token check failed.