How to delete a harvester that is no longer running

Document ID : KB000113685
Last Modified Date : 12/09/2018
Show Technical Document Details
Issue:
We are receiving the below error when trying to delete a Harvester that no longer exists.

- Object reference not set to an instance of an object. at NetQoS.Common.EnumUtility.GetDescriptionByDescriptionContext(Enum value, String descriptionContext) at NetQoS.ReporterAnalyzer.Business.AgentPhysical.InitializeFromDataRow(DataRow row) at NetQoS.Business.DatabaseEntity.GetDatabaseEntityArrayFromDataTable[T](DataTable table) at NetQoS.ReporterAnalyzer.Business.AgentPhysical.GetByInterfaceIds(UInt32[] ids) at NetQoS.ReporterAnalyzer.Business.AgentPhysical.DeleteByInterfaceIds(UInt32[] ids) at NetQoS.ReporterAnalyzer.Business.Interface.DeleteByIds(UInt32[] interfaceIds) at NetQoS.ReporterAnalyzer.Business.Interface.DeleteByRouterIds(UInt32[] routerIds) at NetQoS.ReporterAnalyzer.Business.Router.DeleteByIds(UInt32[] routerIds) at NetQoS.ReporterAnalyzer.Business.Harvester.Delete(UInt32[] ids) at NetQoS.ReporterAnalyzer.WebService.HarvesterWS.DeleteHarvesterData(UInt32 harvesterID) Error when trying to delete interfaces: - Connection must be valid and open. at MySql.Data.MySqlClient.MySqlCommand.CheckState() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() at NetQoS.Data.MySqlDataComponentBase.ExecuteNonQuery(MySqlConnection connection, String sql, DataParameter[] dataParameters) at NetQoS.Data.MySqlDataComponentBase.ExecuteNonQuery(String sql) at NetQoS.ReporterAnalyzer.Data.Archive.ArchiveDc.DeleteByRouterAndPersistentId(String sourceTable, UInt32 router, UInt32 persistentId) at NetQoS.ReporterAnalyzer.Business.Agent.DeleteById(UInt32[] ids) at NetQoS.ReporterAnalyzer.Business.Router.DeleteLicensedOnlyByIds(UInt32[] routerIds) at NetQoS.ReporterAnalyzer.WebService.RouterInterfaceWS.DeleteRouterInterfaces(String routerIds, String interfaceIds)

Error when trying to delete interfaces from a harvester that no longer exists:

- Connection must be valid and open.

at MySql.Data.MySqlClient.MySqlCommand.CheckState()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at NetQoS.Data.MySqlDataComponentBase.ExecuteNonQuery(MySqlConnection connection, String sql, DataParameter[] dataParameters)
at NetQoS.Data.MySqlDataComponentBase.ExecuteNonQuery(String sql)
at NetQoS.ReporterAnalyzer.Data.Archive.ArchiveDc.DeleteByRouterAndPersistentId(String sourceTable, UInt32 router, UInt32 persistentId)
at NetQoS.ReporterAnalyzer.Business.Agent.DeleteById(UInt32[] ids)
at NetQoS.ReporterAnalyzer.Business.Router.DeleteLicensedOnlyByIds(UInt32[] routerIds)
at NetQoS.ReporterAnalyzer.WebService.RouterInterfaceWS.DeleteRouterInterfaces(String routerIds, String interfaceIds)
Cause:
The Console cannot communicate with the old Harvester to delete.
Resolution:
We need to remove the harvester manually from the MySQL database.
  1. RDP to the NFA Console.
  2. Open a CMD prompt and type:
    1. mysqldump reporter > c:\reporter.sql
    2. mysql reporter
    3. select harvesterid from harvesters where address='x.x.x.x'; (where x.x.x.x is the harvester IP you want to delete).
    4. delete from harvesters where harvesterid=x; (where x is the returned value from the first query)
    5. delete from routers where harvesterid=x;
    6. create table temprouters select id from routers;
    7. delete from interfaces where routerid not in (select id from temprouters);
    8. drop table temprouters;
    9. delete from agent_definitions where interfaceid not in (select id from interfaces);
    10. delete from agent_definitions_deleted where harvesteraddress='x.x.x.x';