The following article provides several samples of SQL queries for the AvailabilityGuard Database Views. Database Views SQL queries can be used to integrate with external systems and send data for further processing, or simply as custom AvailabilityGuard reports.
Samples included in this article:
- Sample 1: Querying auxiliary views
- Sample 2: Network file systems (NIFS / CIFS) information
- Sample 3: Database file layout including business entity information
- Sample 4: Host access to storage systems including cluster info
- Sample 5: ESXi Host options - filtered to Net options
- Sample 6: Virtual Machine / Partition and its underlying physical host
- Sample 7: SAN I/O paths
- Sample 8: number of OPEN AvailabilityGuard tickets detected in April 2018 by risk (Gap) Signature and Labels
Sample 1: Querying auxiliary views
The Auxiliary views are queries on top of other database views, and represent common use cases. Refer to AvailabilityGuard Database Views (API) for the complete list of Auxiliary views.
SELECT * FROM V_FILE_SYSTEM_MULTIPATH -- present SAN path summary per host file system
SELECT * FROM V_FS_REPLICATION -- present storage replication summary per host file system
SELECT * FROM V_FS_STORAGE -- present summary of storage access by hosts
Sample 2: Network file systems (NIFS / CIFS) information
SELECT
HOST_NAME, DEVICE_ID, TYPE, FS_SIZE, MOUNT_POINT, REMOTE_SERVER, REMOTE_RESOURCE, MOUNTED, MOUNT_OPTIONS
FROM
SAPI_NETWORK_FILE_SYSTEM
ORDER BY
HOST_NAME, DEVICE_ID
Sample 3: Database file layout including business entity information
SELECT DISTINCT
BUSINESS_ENTITY_NAME, SAPI_DATABASE_FILE.HOST_NAME, SAPI_DATABASE_FILE.DATABASE_SERVICE_NAME, SAPI_DATABASE_FILE.DATABASE_NAME, SAPI_DATABASE_FILE.TYPE, SAPI_DATABASE_FILE.FILE_PATH, SAPI_DATABASE_FILE.FILE_SIZE
FROM
SAPI_DATABASE_FILE LEFT OUTER JOIN SAPI_HOST_TO_BUSINESS_ENTITY ON SAPI_DATABASE_FILE.HOST_ID=SAPI_HOST_TO_BUSINESS_ENTITY.HOST_ID
ORDER BY
BUSINESS_ENTITY_NAME, HOST_NAME, DATABASE_SERVICE_NAME, DATABASE_NAME
Sample 4: Host access to storage systems including cluster info
SELECT DISTINCT
SAPI_HOST.HOSTNAME, SAPI_HOST.OS_TYPE, SAPI_HOST.IS_VIRTUAL, SAPI_HOST.SITE_NAME, SAPI_HOST_TO_CLUSTER.CLUSTER_NAME,
SAPI_STORAGE_VOLUME.TYPE AS STORAGE_TYPE, SAPI_STORAGE_VOLUME.STORAGE_ARRAY,
SAPI_SCAN_STATUS_HOST.NAME AS HOST_SCAN_STATUS, SAPI_SCAN_STATUS_STORAGE.NAME AS STORAGE_SCAN_STATUS
FROM
SAPI_HOST LEFT OUTER JOIN SAPI_HOST_TO_CLUSTER ON SAPI_HOST.ID=SAPI_HOST_TO_CLUSTER.HOST_ID,
SAPI_PHYSICAL_VOLUME, SAPI_STORAGE_ARRAY, SAPI_STORAGE_VOLUME,
SAPI_SCAN_STATUS SAPI_SCAN_STATUS_HOST, SAPI_SCAN_STATUS SAPI_SCAN_STATUS_STORAGE
WHERE
SAPI_HOST.ID=SAPI_PHYSICAL_VOLUME.HOST_ID AND SAPI_STORAGE_VOLUME.ID=SAPI_PHYSICAL_VOLUME.STORAGE_VOLUME_ID AND SAPI_HOST.SCAN_STATUS_ID=SAPI_SCAN_STATUS_HOST.ID AND SAPI_STORAGE_ARRAY.SCAN_STATUS_ID=SAPI_SCAN_STATUS_STORAGE.ID AND SAPI_STORAGE_ARRAY.ID=SAPI_STORAGE_VOLUME.STORAGE_ARRAY_ID
ORDER BY
SAPI_HOST_TO_CLUSTER.CLUSTER_NAME, SAPI_HOST.SITE_NAME, SAPI_HOST.HOSTNAME
Sample 5: ESXi Host options - filtered to Net options
-- Structure queried:
-- ESXi Host
-- |__ Option Property
-- |__ Name Property
-- |__ Value Property
SELECT DISTINCT
SAPI_HOST.HOSTNAME, NAME_PROPERTY.VALUE as OPTION_NAME ,VALUE_PROPERTY.value as OPTION_VALUE
FROM
SAPI_HOST, SAPI_ITEM_PROPERTIES, SAPI_PROPERTY_PROPERTIES NAME_PROPERTY, SAPI_PROPERTY_PROPERTIES VALUE_PROPERTY
WHERE
SAPI_HOST.OS_TYPE like '%ESX%' and SAPI_ITEM_PROPERTIES.PARENT_ITEM_ID=SAPI_HOST.ID AND NAME_PROPERTY.PARENT_PROPERTY_ID=SAPI_ITEM_PROPERTIES.ID AND VALUE_PROPERTY.PARENT_PROPERTY_ID=SAPI_ITEM_PROPERTIES.ID AND SAPI_ITEM_PROPERTIES.name='option' AND NAME_PROPERTY.name='name' AND VALUE_PROPERTY.name='value' AND NAME_PROPERTY.VALUE LIKE 'Net.%'
ORDER BY
SAPI_HOST.HOSTNAME, NAME_PROPERTY.VALUE
Sample 6: Virtual Machine / Partition and its underlying physical host
SELECT DISTINCT
SH_VM.OS_TYPE as VM_OS_TYPE, SH_VM.NAME as VM, SH_VM.MEMORY_SIZE as VM_MEMORY_SIZE,
SH_PHYS.OS_TYPE as HOST_OS_TYPE, SH_PHYS.NAME as PHYSICAL_HOST, SH_PHYS.MEMORY_SIZE as HOST_MEMORY_SIZE
FROM
SAPI_HOST SH_VM, SAPI_HOST SH_PHYS, SAPI_VIRTUALIZATION SVI
WHERE
SVI.PHYSICAL_ITEM_ID = SH_PHYS.ID AND SVI.VIRTUAL_ITEM_ID = SH_VM.ID
ORDER BY
SH_PHYS.NAME, SH_VM.NAME
Sample 7: SAN I/O paths
SELECT DISTINCT
SAPI_PHYSICAL_VOLUME.HOST_NAME, SAPI_MULTIPATH.PSEUDO_NAME, SAPI_MULTIPATH.NAME, SAPI_MULTIPATH.MULTIPATH_SOFTWARE, SAPI_MULTIPATH.MULTIPATH_STATE, SAPI_MULTIPATH.MULTIPATH_POLICY, SAPI_MULTIPATH.IS_ALIVE
FROM
SAPI_PHYSICAL_VOLUME, SAPI_MULTIPATH
WHERE
SAPI_MULTIPATH.PSEUDO_VOLUME_ID=SAPI_PHYSICAL_VOLUME.ID
ORDER BY
SAPI_PHYSICAL_VOLUME.HOST_NAME, SAPI_MULTIPATH.PSEUDO_NAME
Sample 8: number of OPEN tickets detected in April 2018 by risk (Gap) Signature and Labels
SELECT
GAP_NAME, LABELS, count(*)
FROM
SAPI_TICKETS
WHERE
STATUS='OPEN' AND DETECTION_DATE BETWEEN '01-APR-18' AND '30-APR-18'
GROUP BY
GAP_NAME, LABELS
Comments
0 comments
Please sign in to leave a comment.