Look here, you can use the REST API of the Device.
WAGO Device REST-API WDx/WDA - Hardware and Linux - WAGO Open Source Community
it provides nearly everything which is available inside the Web Based Management.
try it out.
Provide Diagnostic from the Program will only work the Codesys Runtime is in RUN.
so i recommend to use the REST API to get all relevant Diagnostic Information of the Linux OS, including PLC Data.
But the REST API will only work for Devices PFC100 Generation 2, CC100, PFC200 Generation 2, Edge Controller and TP600 with a FW >= Index 28.