Is there way to detect whether PIMDB health status is "InSync" ?
Would like to check this status before running certain calculations may write to the PIMDB.
The PIAFlink may lock the PIMDB when the health status is not "InSync".
As far as I can see there's neither a method in PI SDK nor in AF SDK that would allow you to query AF Link Subsystem health status but there's good news too.
There exists a Performance object "PI Session Statistics" that exposes counters for different subsystems. As far as I can see "Messages Sent/sec" and "Bytes Sent/sec" are good indicators that AF Link Subsystem is alive. With "PI Server" license type, as opposed to "Enterprise Server" or "Enterprise Professional Server", the MCN Interface package is included. One of the 4 interfaces is the PI Interface for Performance Monitor that can be used to collect Windows Performance Counter data into PI tags. In addition to "PI Session Statistics", I suggest collecting the "Elapsed Time" (performance object "Process") counter for the "piaflink" process. The Elapsed Time counter provides a kind of heartbeat continuously increasing: If the corresponding PI tag (serviced by the PI Interface for Performance Monitor) reads "I/O Timeout" the process pretty likely doesn't exist in memory and one of the first things to check would be the status of the AF Link Subsystem service. If the tag is stale, the process might be hanging which definitely indicates an unhealthy state.
If by any reason the performance counters are not accessible, there are also two different alternatives in order to solve your problem:
- Analyze the PI Message Log to find out the status of PI AF Link Subsystem by filtering the messages with Program=piaflink.
- Check if the service is running using native .NET libraries to help detect if the service is stopped.
I will try these suggestions in my PIACE.
I do hope PISDK and/or AFSDK can access those components exposed in PISMT's utilities.
Retrieving data ...