---
sourceDocument: Yokohama IT Operations Management
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/yokohama/it-operations-management

 Release :

    - yokohama

ft:locale :

    - en-US

ft:publication_title :

    - Yokohama IT Operations Management

ft:clusterId :

    - itom

bundleId :

    - itom

workflow :

    - Technology


---

# Create a call API to send an osquery request

# Create a call API to send an osquery request {#ariaid-title1}

* Release version: Yokohama
* 
* Updated January 30, 2025
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

Create a background script to send an `osquery` request. The `osquery` request enables data collection from your host's operating system.

## Before you begin

Role required: administrator

## Procedure

1. Create the following background script:  
   * <kbd class="ph userinput">"MTLV9DE22016"</kbd> is the name of the server running an agent
   * <kbd class="ph userinput">"c8bf9072539333003e76ddeeff7b12c5"</kbd> is the sys_id of the previously created check definition

   {#acc-api-send-os-query-reqs__ul_nld_s41_jkb}


       cis = new GlideRecord("cmdb_ci_server"); 
           cis.addQuery("name", "MTLV9DE22016"); 
           cis.query(); 
           check = { 
               "checkDefId": "c8bf9072539333003e76ddeeff7b12c5",
               "params": { 
                   "query": "select pid,cmdLine from processes limit 4" 
               } 
           }; 
           var agentNow = new sn_agent.AgentNowHandler(); 
           gs.info('request_id: ' + agentNow.runCheckForCis(cis,check,'1',60000));

2. Run the script to print the request ID:  
   request_id: `eefbff7ab75733003e766068de11a981`
3. Check the system logs for messages coming from the instance script.  

       result 0 requestId: 06c6c887b79733003e766068de11a912 agent_name: MTLV9DE22016 ci_id:
       00726c36539333003e76ddeeff7b12db status: 0 output: [ 
       {"cmdline":"","pid":"0"}, 
       {"cmdline":"","pid":"1"}, 
       {"cmdline":"","pid":"45"}, 
       {"cmdline":"","pid":"46"} 
       ] 


