Monday, June 27, 2016

Getting UFO2 failover status from an OSIsoft PI Interface


I'm currently deploying an OSIsoft PI Interface node at my workplace.

Being a "Systems" Administrator, and not a "PI" Administrator per se, I was looking for a way to get high-availability status directly from that interface node. My objective was to provide IT Operations with an easy-to-use procedure that answers the following question: Which interface node is currently active and which one is currently in standby?... It is useful for them to know the answer to this when scheduling maintenance such as Windows patches.

Unfortunately, there is no easy way to find out which of the two interfaces is currently active. I've looked everywhere in OSIsoft's KB and I guess nobody asked. :-)

Some information on UFO 

Many, if not all, PI interfaces are based on UniInt (Universal Interface). UniInt supports two failover levels named UFO (UniInt FailOver):

  • UFO phase 1 (UFO1) which is based on PI points
  • UFO phase 2 (UFO2) which uses a shared file located on a separate file server

Not all interfaces support UniInt failover; check your Interface documentation. Mine only supports UFO2.

You can look at the following KBs for more information:

UFO2 is preferred to UFO1, and KB00446 even mentions that UFO1 is deprecated. That might be due to the fact that I see one major drawback with UFO1: if one node looses access to the PI Server, it cannot know the status of the other node. Using a shared file on a file server (a highly-available one, that is!) is deemed more reliable.

Finding what interface is active, the PI Admin Way

There seems to be one official way, the "PI Admin Way", which involves looking up points stored in the PI Server.

While my interface is UFO2, it seems to create PI points anyway. These points are created directly from ICU, and they all have "UFO2" in their names. It is therefore trivial to check their values from the PI SDK Utility tool. For example:

PRO TIP: It's also possible to find out these values at the command line using apisnap.

While this is sufficient from a PI admin perspective, from a systems administrator perspective, it's not great. For instance, it's not an easy task for IT Operations to fire up that tool and query PI points, it cannot be automated in a script (except if using apisnap) and lastly it will not work at all if the nodes cannot speak to the PI server. It is thus preferable to ask them to run a simple command.

Finding what interface is active, the born-again Sysadmin Way

It was a simple task to somewhat reverse-engineer the binary UFO2 .dat file created by the interface and write a simple program to extract basic data. I've named it readdat.

C:\tools>readdat \\myfileserver\myfile.dat

Active Node (0 = None, 1 = Node 1 is primary, 2 = Node 2 is primary)
Active ID: 1

Device Status (0 = Good, 99 = OFF, any value in between results in a failover)
Node 1: 0
Node 2: 0

Works good enough for me. Readdat.exe can then wrapped in a batch file or a powershell script to make it easier to use.

As a bonus, you can run it like this:
C:\tools>readdat \\myfileserver\myfile.dat -activeid

This will set ERRORLEVEL to the ID number.

The source code for readdat is here:

Here is also a Win32 executable:

Good luck!