No module Published on Offcanvas position

Unable to get data from Citrix Director

When you try to get data you get the following error:
Cannot retrieve the data. Unexpected server error. View Director server event logs for further information (Refer Citrix KB article CTX130320).

If you dive deeper into the Event logs in Applications, you'll find this error as well:
An unexpected error occurred when accessing the data source 'Unknown error.' ('http://<servername>/Citrix/Monitor/OData/v3').

User: '<username>'
Console operation: 'Preview Custom report query response'

Additional information:
'Unexpected character encountered while parsing value: <. Path '', line 0, position 0.'

The error claims it found an expected character while parsing the path. This is true if your Citrix Monitoring database contains whitespaces. The Citrix Director uses the API to get data and that API can't handle whitespaces. 
To fix this, you need to remove the whitespace in your Citrix Monitoring DB. Luckly this can be done during office hours, but keep in mind you will have a small information gap because no data will be pushed to the database while you do this.

  1. Login to the Citrix Delivery Controller server and start powershell as administrator
  2. Enter the following command: Set-MonitorConfiguration -DataCollectionEnabled $false
    This disables the monitoring so no data will be sent to the database
  3. Login to the SQL server that houses the Citrix Database and start SQL Management Studio 
  4. Try to rename the database, in a lot of cases it doesn't work because it will error out about and exclusive lock. This means multiple sessions are connected to it and while that is happening it can't be renamed.
    If you get that error do the following:
    1. Create a new Query and copy the following lines into it:
      USE master;
      GO

      ALTER DATABASE <DATABASENAME> SET SINGLE_USER WITH ROLLBACK IMMEDIATE; 
      GO

      ALTER DATABASE <DATABASENAME> MODIFY NAME = <NEWDATABASENAME>;
      GO

      ALSTER DATABASE <NEWDATABASENAME> SET MULTI_USER;
      GO

      These lines will put the database in single user mode, creating that exclusive lock, then it will rename it and lastly revert it back to multi-user mode
  5. Back to the Citrix Delivery Controller server, enter the following in powershell: Set-MonitorDBConnection -DataStore Monitor -DBConnection $null 
    This clears the currently set connection, you can't set it to the new database without setting this to nothing first.
  6. Enter the following command next to create the new connection: Set-MonitorDBConnection -DataStore Monitor -DBConnection "Server=<servername\instance>;Initial Catalog=<monitoringdatabasename>;Integrated Security=True"
  7. Enter the following command to enable monitoring again: Set-MonitorConfiguration -DataCollectionEnabled $false
  8. Try logging in to the Citrix Director again and you will see that error will no longer appear and data will appear now.