Table: servicenow_cmdb_ci - Query ServiceNow Configuration Items using SQL
ServiceNow Configuration Items (CI) are service assets tracked in the Configuration Management Database (CMDB). They include tangible assets like hardware and software, as well as intangible assets like policies, agreements, and services. CIs provide information about the assets' configurations and the relationships between them.
Table Usage Guide
The servicenow_cmdb_ci
table provides insights into the Configuration Items (CI) within ServiceNow's Configuration Management Database (CMDB). As a DevOps engineer, you can explore CI-specific details through this table, including CI classes, states, and associated metadata. Utilize it to uncover information about CIs, such as those related to specific services, the relationships between CIs, and the verification of CI states.
Examples
List CMDB Configuration Item name, asset tag, serial number
Explore the inventory of Configuration Items (CIs) to keep track of their names, asset tags, and serial numbers. This query is particularly useful for auditing and asset management purposes.
select ci.name, ci.asset_tag, ci.serial_numberfrom servicenow_cmdb_ci cilimit 100;
select ci.name, ci.asset_tag, ci.serial_numberfrom servicenow_cmdb_ci cilimit 100;
Retrieve a list of all CIs that are currently down or experiencing issues
Explore which Configuration Items (CIs) are currently not functioning optimally or facing issues. This can aid in quickly identifying problematic areas and taking necessary corrective actions.
select sys_id, name, sys_class_name, short_descriptionfrom servicenow_cmdb_ciwhere operational_status != '1';
select sys_id, name, sys_class_name, short_descriptionfrom servicenow_cmdb_ciwhere operational_status != '1';
Identify all CIs that have been recently modified or updated
Explore which Configuration Items (CIs) have undergone changes in the past week. This is useful in understanding recent system changes and potentially identifying any unexpected or unauthorized modifications.
select sys_id, name, sys_class_name, short_descriptionfrom servicenow_cmdb_ciwhere sys_updated_on > now() - interval '7 days';
select sys_id, name, sys_class_name, short_descriptionfrom servicenow_cmdb_ciwhere sys_updated_on > datetime('now', '-7 days');
Get a list of all CIs that have been retired or decommissioned
Explore which Configuration Items (CIs) have been decommissioned or retired. This can be useful in assessing the lifecycle of your resources and planning for replacement or upgrades.
select sys_id, name, sys_class_name, short_descriptionfrom servicenow_cmdb_ciwhere install_status = '7';
select sys_id, name, sys_class_name, short_descriptionfrom servicenow_cmdb_ciwhere install_status = '7';
Find all CIs that are currently undergoing maintenance or repair
Explore which Configuration Items (CIs) are currently under maintenance or repair. This is useful in managing system downtime and planning resource allocation.
select sys_id, name, sys_class_name, short_descriptionfrom servicenow_cmdb_ciwhere sys_id in ( select cmdb_ci from servicenow_task where state in (3, 4) and short_description like '%maintenance%' );
select sys_id, name, sys_class_name, short_descriptionfrom servicenow_cmdb_ciwhere sys_id in ( select cmdb_ci from servicenow_task where state in (3, 4) and short_description like '%maintenance%' );
Retrieve all CIs with a specific serial number
Explore which Configuration Items (CIs) share a common serial number. This can be useful in tracking and managing assets within your IT environment.
select sys_id, name, sys_class_name, short_descriptionfrom servicenow_cmdb_ciwhere serial_number = '123456789';
select sys_id, name, sys_class_name, short_descriptionfrom servicenow_cmdb_ciwhere serial_number = '123456789';
Schema for servicenow_cmdb_ci
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
asset | jsonb | The asset associated with the configuration item. | |
asset_tag | text | Unique identifier for the asset. | |
assigned | timestamp with time zone | Flag indicating if the configuration item is assigned. | |
assigned_to | jsonb | Person or group assigned to the configuration item. | |
assignment_group | jsonb | Group assigned to the configuration item. | |
attestation_score | bigint | Score representing the attestation status of the configuration item. | |
attestation_status | text | Status of attestation for the configuration item. | |
attested | boolean | Flag indicating if the configuration item is attested. | |
attested_by | jsonb | Person who attested the configuration item. | |
attested_date | timestamp with time zone | Date when the configuration item was attested. | |
attributes | text | Additional attributes associated with the configuration item. | |
business_unit | jsonb | Business unit associated with the configuration item. | |
can_print | boolean | Flag indicating if the configuration item can be printed. | |
category | text | Category of the configuration item. | |
change_control | jsonb | Change control information for the configuration item. | |
checked_in | timestamp with time zone | Flag indicating if the configuration item is checked in. | |
checked_out | timestamp with time zone | Flag indicating if the configuration item is checked out. | |
comments | text | Comments or notes related to the configuration item. | |
company | jsonb | Company associated with the configuration item. | |
correlation_id | text | ID used to correlate related configuration items. | |
cost | double precision | Cost of the configuration item. | |
cost_cc | text | Cost center associated with the configuration item. | |
cost_center | jsonb | Cost center associated with the configuration item. | |
delivery_date | timestamp with time zone | Date of delivery for the configuration item. | |
department | jsonb | Department associated with the configuration item. | |
discovery_source | text | Source of discovery for the configuration item. | |
dns_domain | text | DNS domain associated with the configuration item. | |
due | timestamp with time zone | Due date for the configuration item. | |
due_in | text | Time remaining for the configuration item. | |
duplicate_of | jsonb | Which CI is this a duplicate of. | |
environment | text | Environment associated with the configuration item. | |
fault_count | bigint | Number of faults associated with the configuration item. | |
first_discovered | timestamp with time zone | Date when the configuration item was first discovered. | |
fqdn | text | Fully Qualified Domain Name (FQDN) of the configuration item. | |
gl_account | text | General ledger account associated with the configuration item. | |
install_date | timestamp with time zone | Date when the configuration item was installed. | |
install_status | bigint | Installation status of the configuration item. | |
instance_url | text | The ServiceNow instance URL. | |
invoice_number | text | Invoice number associated with the configuration item. | |
ip_address | text | IP address of the configuration item. | |
justification | text | Justification for the configuration item. | |
last_discovered | timestamp with time zone | Most recent discovery. | |
lease_id | text | ID of the lease associated with the configuration item. | |
life_cycle_stage | jsonb | Life cycle stage of the configuration item. | |
life_cycle_stage_status | jsonb | The specific status of a CI within its life cycle phase. | |
location | jsonb | Location of the configuration item. | |
mac_address | text | MAC address of the configuration item. | |
maintenance_schedule | jsonb | Maintenance schedule associated with the configuration item. | |
managed_by | jsonb | Person responsible for managing the configuration item. | |
managed_by_group | jsonb | Group responsible for managing the configuration item. | |
manufacturer | jsonb | Manufacturer of the configuration item. | |
model_id | jsonb | ID of the model associated with the configuration item. | |
model_number | text | Model number of the configuration item. | |
monitor | boolean | Flag indicating if the configuration item is monitored. | |
name | text | Name of the configuration item. | |
operational_status | bigint | Operational status of the configuration item. | |
order_date | timestamp with time zone | Date when the configuration item was ordered. | |
owned_by | jsonb | Person or group that owns the configuration item. | |
po_number | text | Purchase order number associated with the configuration item. | |
purchase_date | text | Date when the configuration item was purchased. | |
schedule | jsonb | Schedule associated with the configuration item. | |
serial_number | text | Serial number of the configuration item. | |
short_description | text | Short description of the configuration item. | |
skip_sync | boolean | Flag indicating if synchronization should be skipped for the configuration item. | |
sp_connection_name | text | Steampipe connection name. | |
sp_ctx | jsonb | Steampipe context in JSON form. | |
start_date | timestamp with time zone | Start date associated with the configuration item. | |
subcategory | text | Subcategory of the configuration item. | |
support_group | jsonb | Support group responsible for the configuration item. | |
supported_by | jsonb | Person or group responsible for supporting the configuration item. | |
sys_class_name | text | Name of the configuration item's class. | |
sys_class_path | text | Path of the configuration item's class. | |
sys_created_by | text | User who created the configuration item. | |
sys_created_on | timestamp with time zone | Date and time when the configuration item was created. | |
sys_domain | jsonb | Domain associated with the configuration item. | |
sys_domain_path | text | Path of the configuration item's domain. | |
sys_id | text | Unique identifier (Sys ID) of the configuration item. | |
sys_mod_count | bigint | Number of times the configuration item has been modified. | |
sys_updated_by | text | User who last updated the configuration item. | |
sys_updated_on | timestamp with time zone | Date and time when the configuration item was last updated. | |
unverified | boolean | Flag indicating if the configuration item is unverified. | |
vendor | jsonb | Vendor associated with the configuration item. | |
warranty_expiration | text | Expiration date of the warranty for the configuration item. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- servicenow
You can pass the configuration to the command with the --config
argument:
steampipe_export_servicenow --config '<your_config>' servicenow_cmdb_ci