Refactor agent ping resources logic