CMDB Query to locate application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 04:09 AM
Hi All,
I have a application which is hosted on virtual machines on linux servers
I need to build a query to query the running process on these linux servers to map the service
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 07:24 AM
Hi @rundagaikwa ,
As per my understading, You should understand below and follow the steps
Step 1: Understand the data model
When Discovery runs on Linux servers, it populates these important tables:
* cmdb_ci_computer (Linux servers / VMs)
* cmdb_ci_process (running processes)
* cmdb_ci_appl (application instances if processes are mapped)
* cmdb_ci_service (if you model business or technical services)
The process → application mapping is driven by process classifiers & process patterns.
Step 2: Make sure Discovery is configured to collect process info
* Check your Discovery schedule: ensure it includes the "Process Classifier" probe and process patterns.
* Validate that cmdb_ci_process table is getting populated for these Linux VMs.
* Check that your application is detected by a process classifier (this typically matches process name, arguments, ports, etc.).
If it’s not:
Create or update a process classifier:
* Go to Discovery Definition > CI Classifiers > Process Classifiers
* Define a rule to detect your application’s process by name or command line.
Step 3: Build the CMDB query
Use CMDB Query Builder or a direct GlideRecord / SQL-like query.
Goal: Find your application running as a process on Linux servers (which might be hosted on VMs).
Here’s an outline for a CMDB Query Builder approach:
Start with:
* Table: cmdb_ci_computer
* Condition: os = Linux (or class is cmdb_ci_linux_server)
Then join to:
* cmdb_ci_process
Relation: Runs on::Runs (process runs on server)
Add filter:
* Process name or command line LIKE '%your_application_name%'
Optionally join to:
* cmdb_ci_vm_instance (if your servers are VMs)
Example GlideRecord script
If you want to script:
var gr = new GlideRecord('cmdb_ci_process');
gr.addQuery('name', 'CONTAINS', 'your_application_name'); // or command line filter
gr.query();
while (gr.next()) {
gs.info('Found process: ' + gr.name + ' on server: ' + gr.getValue('host.name'));
}
Step 4: Map to Service
* Once you have identified the processes, you can:
* Create or update cmdb_ci_appl or cmdb_ci_service records.
* Define relationships:
* Runs on (process → server)
* Depends on (application → process)
* If this should be dynamic, configure a Service Mapping pattern to automatically build the application service by detecting these processes.
Best practice / automation:
* Use a Process Classifier so Discovery automatically maps running processes to application CIs.
* Use Service Mapping to build and maintain the service dynamically.
* Validate regularly via CMDB Health Dashboard.
Summary of steps:
1. Ensure Discovery collects processes (process classifier).
2. Identify your application’s process name or command pattern.
3. Use CMDB Query Builder: cmdb_ci_computer (Linux) → cmdb_ci_process.
4. Filter by process name.
5. Optionally map to cmdb_ci_appl or create service map.
Here’s a step-by-step guide to build the exact CMDB Query in CMDB Query Builder to locate your application’s process running on Linux servers.
We’ll build a query that:
* Starts from Linux servers (or VMs)
* Joins to running processes
* Filters by process name (e.g., your_application_name)
* (Optionally) shows VM info if servers are virtual
Step-by-step CMDB Query Builder definition
Step 1: Start from the base table
* Table: cmdb_ci_computer
* Condition:
* os → CONTAINS → Linux
or if you use cmdb_ci_linux_server class, start directly from that.
Step 2: Add relationship to processes
Click Add related table:
* Related table: cmdb_ci_process
* Relationship:
* Runs on::Runs
(process → server)
Step 3: Filter processes
On cmdb_ci_process:
* Filter:
* name → CONTAINS → your_application_name
or
* command_line → CONTAINS → your_application_name
(Use whatever identifies your application process best)
Step 4: (Optional) Add VM layer if applicable
If your servers are actually VMs and you want to see that:
* Add related table from cmdb_ci_computer:
* Related table: cmdb_ci_vm_instance
* Relationship: Hosted on::Hosts
Step 5: Select fields to display
Choose fields to include in your output, for example:
* From cmdb_ci_computer:
* name
* fqdn
* os
* serial_number
* From cmdb_ci_process:
* name
* command_line
* pid
* From cmdb_ci_vm_instance (optional):
* instance_id
Please appreciate the efforts of community contributors by marking appropriate response as Mark my Answer Helpful or Accept Solution this may help other community users to follow correct solution in future.
Thank You
AJ - TechTrek with AJ
LinkedIn:- https://www.linkedin.com/in/ajay-kumar-66a91385/
YouTube:- https://www.youtube.com/@learnitomwithaj
ServiceNow Community MVP 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2025 02:04 AM
Thank you for your reply
But if my application is running on nutanix VM and db process is on Oracle instance how can i create a query or encoded query to get only the servers which has those data as I have done service mapping using dynamic Ci group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2025 07:31 AM
Hi @rundagaikwa ,
As per my Understanding -
Scenario:
* Your application service:
* Runs on servers which are Nutanix VMs (cmdb_ci_vmware_instance or similar).
* Connects to an Oracle DB instance (process on separate DB servers).
* You’ve done Service Mapping and used Dynamic CI Groups.
* You now want to query only those servers (VMs) where:
* The app process is running AND
* They are part of the service mapped to the Oracle DB.
Solution approach:
You can do this using:
* CMDB Query Builder (recommended)
* OR an encoded query on the CI table (cmdb_ci_server / cmdb_ci_vmware_instance)
* OR querying the dynamic CI group membership and relationships
Option 1: Use CMDB Query Builder (visual, recommended)
1. Go to CMDB Query Builder
2. Start with table: cmdb_ci_vmware_instance or cmdb_ci_computer
3. Build relationship path:
* cmdb_ci_vmware_instance → Runs on → cmdb_ci_appl or cmdb_ci_service
* Then → Depends on::Used by → cmdb_ci_database_instance (Oracle)
4. Add filter:
* Application Service name = <your application>
* DB instance name = <your Oracle DB>
5. This will return only servers/VMs hosting the app that is mapped (via Service Map) to the Oracle DB.
Option 2: Encoded query directly (if you know table names and relationships)
Assuming:
* Servers: cmdb_ci_vmware_instance
* Application service: cmdb_ci_service_auto (dynamic service)
* Oracle DB: cmdb_ci_db_instance
Example logic in pseudo-query:
Find servers which are members of a dynamic CI group → related to service → related to DB
Example encoded query (replace with actual field names):
active=true^sys_idINjavascript:getMyServiceVMsAndDB()
Where getMyServiceVMsAndDB() would be a GlideAggregate / GlideRecord script that:
* Finds dynamic CI group members for the service.
* Checks which are also connected to Oracle DB.
Encoded query alone might be complex if relationships span multiple tables; script or query builder is easier.
Option 3: Use dynamic CI group membership
If you already have the dynamic CI group set up:
1. Go to table: cmdb_ci_vmware_instance (or cmdb_ci_computer)
2. Add filter:
sys_idIN<Dynamic CI Group>.members
3. You can further filter by:
* sys_class_name=cmdb_ci_vmware_instance
* Or by discovered process, e.g., process.nameLIKE<app process> (if process is discovered).
Tips to refine further:
1. Combine with:
* Filter on process: cmdb_ci_service_instance where process.name=your_app_process
* Filter on database type: cmdb_ci_db_instance with type=Oracle
2. Use query builder to:
* Start from service → find members → filter for VMs
* Then follow Depends on relationship to DB
Sample Query Builder design:
[cmdb_ci_vmware_instance]
|
Runs on
|
[cmdb_ci_appl] or [cmdb_ci_service_auto]
|
Depends on / Used by
|
[cmdb_ci_db_instance]
* Filter DB instance type=Oracle
* Filter App name = your app
Please appreciate the efforts of community contributors by marking appropriate response as Mark my Answer Helpful or Accept Solution this may help other community users to follow correct solution in future.
Thank You
AJ - TechTrek with AJ
LinkedIn:- https://www.linkedin.com/in/ajay-kumar-66a91385/
YouTube:- https://www.youtube.com/@learnitomwithaj
ServiceNow Community MVP 2025