{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":28590,"path":"it-operations-management/agent-client-collector/acc-api-send-os-query-reqs.md","title":"Create a call API to send an osquery request","bundle":null,"doc_type":null,"release":"australia","body":"\n# Create a call API to send an osquery request\n\nCreate a background script to send an `osquery` request. The `osquery` request enables data collection from your host's operating system.\n\n## Before you begin\n\nRole required: administrator\n\n## Procedure\n\n1.  Create the following background script:\n\n    -   `\"MTLV9DE22016\"` is the name of the server running an agent\n    -   `\"c8bf9072539333003e76ddeeff7b12c5\"` is the sys\\_id of the previously created check definition\n    ```\n    \n    cis = new GlideRecord(\"cmdb_ci_server\"); \n        cis.addQuery(\"name\", \"MTLV9DE22016\"); \n        cis.query(); \n        check = { \n            \"checkDefId\": \"c8bf9072539333003e76ddeeff7b12c5\",\n            \"params\": { \n                \"query\": \"select pid,cmdLine from processes limit 4\" \n            } \n        }; \n        var agentNow = new sn_agent.AgentNowHandler(); \n        gs.info('request_id: ' + agentNow.runCheckForCis(cis,check,'1',60000));\n    ```\n\n2.  Run the script to print the request ID:\n\n    request\\_id: `eefbff7ab75733003e766068de11a981`\n\n3.  Check the system logs for messages coming from the instance script.\n\n    ```\n    result 0 requestId: 06c6c887b79733003e766068de11a912 agent_name: MTLV9DE22016 ci_id:\n    00726c36539333003e76ddeeff7b12db status: 0 output: [ \n    {\"cmdline\":\"\",\"pid\":\"0\"}, \n    {\"cmdline\":\"\",\"pid\":\"1\"}, \n    {\"cmdline\":\"\",\"pid\":\"45\"}, \n    {\"cmdline\":\"\",\"pid\":\"46\"} \n    ] \n    ```\n\n\n**Parent Topic:**[Enabling Agent Client Collector data collection](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/agent-client-collector/data-collection-enabling.md)\n\n"}}