The first line below would return a list of units that are currently targeting the player or his/her pet, the second would just return a count of the same. I don't see a plugin request though so please clarify if you're asking for something specific to be made.
-Alpha
Code:
List<WoWUnit> units = ObjectManager.GetObjectsOfType<WoWUnit>(false, false).Where(x => x.IsTargetingMeOrPet).ToList();
int unitCount = ObjectManager.GetObjectsOfType<WoWUnit>(false, false).Count(x => x.IsTargetingMeOrPet);