Added plpgsql functions for monitoring