This post is also available in:
The Oracle Enterprise Manager agent is up, the heartbeat with OMS is fine, but metrics simply aren’t arriving. When you try to force a manual collection, you get this:
EMD runCollection error:connection to the agent has been lostThis happens even when emctl status agent reports Agent is Running and Ready. The process is alive — but its internal state is corrupted or out of sync with the OMS.
Why This Happens
The agent tracks upload progress and in-flight collections using state files under $AGENT_INST/sysman/emd/state/. When the agent is interrupted abruptly — power loss, a forced kill, host reboot, or network instability — those files are left in an inconsistent state.
The agent process starts normally, heartbeat works, but the OMS communication layer fails when trying to resume the pending operations. The result: an agent that responds to heartbeats but can’t execute metric collections.
Diagnosis
Before applying the fix, confirm this is a corrupted state issue and not a connectivity or OMS availability problem.
1. Check the full agent status:
./emctl status agentKey fields to review:
Heartbeat Statusshould beOkLast successful uploadshould show a recent timestampCollection Statusshould showCollections enabled
If Heartbeat Status shows OMS is unreachable, the problem is not corrupted state — it’s a connectivity issue. See “When This Won’t Work” below.
2. Try forcing a collection on the problematic target:
./emctl control agent runCollection <TARGET_NAME>:<TARGET_TYPE> <COLLECTION_NAME>Example with an Oracle Home target:
./emctl control agent runCollection OraDB19Home1_2_oracleserver_6741:oracle_home oracle_home_configIf you get EMD runCollection error:connection to the agent has been lost, the state is corrupted. Proceed with the solution below.
Solution
The correct sequence is: clear corrupted state → force upload → verify.
⚠️ Warning:
emctl clearstatediscards pending state files. Any collection data not yet uploaded to the OMS repository will be lost. In production environments with active alerts, confirm OMS is reachable before running this.
Step 1 — Clear the agent state:
./emctl clearstate agentExpected output:
Oracle Enterprise Manager Cloud Control 13c Release 4
Copyright (c) 1996, 2020 Oracle Corporation. All rights reserved.
EMD clearstate completed successfullyStep 2 — Force an upload to OMS:
./emctl uploadExpected output:
Oracle Enterprise Manager Cloud Control 13c Release 4
Copyright (c) 1996, 2020 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
EMD upload completed successfullyStep 3 — Verify agent status:
./emctl status agentConfirm that Last successful upload has been updated and Heartbeat Status is Ok.
Step 4 — Test the collection again:
./emctl control agent runCollection OraDB19Home1_2_oracleserver_6741:oracle_home oracle_home_configExpected output:
EMD runCollection completed successfullyQuick Reference
./emctl status agent
./emctl clearstate agent
./emctl upload
./emctl status agent
./emctl control agent runCollection <TARGET>:<TYPE> <COLLECTION>When This Won’t Work
clearstate solves corrupted internal state. If the root cause is something else, the steps above won’t help:
| Additional symptom | Likely cause | Next step |
|---|---|---|
Heartbeat Status: OMS is unreachable | Network or invalid certificate | Check connectivity, re-secure agent |
| Upload returns authentication error | Stale agent certificate | Run emctl secure agent |
clearstate fails with OutOfMemoryError | state/ directory bloated with corrupt files | Manually move state/ contents before clearstate |
| Issue persists after clearstate + upload | Version-specific bug | Open SR with gcagent.log and emagent.nohup |
For the bloated state/ scenario, move the contents manually before running clearstate:
cd $AGENT_INST/sysman/emd
mkdir state-backup-$(date +%Y%m%d)
mv state/* state-backup-$(date +%Y%m%d)/
./emctl clearstate agent
./emctl start agent
./emctl uploadReferences
- Oracle Docs — Enterprise Manager Cloud Control Administrator’s Guide: emctl Commands
- MOS Note 1902124.1 — EM12c: emctl start agent Fails With Target Interaction Manager failed (verify applicability for your version)
