Fix bug NMS-5990, wrong node availability calculation. Rebuiling the
query selecting and calculating the availability by a node.