API 2.0-M3
-
простейший запрос перестал обрабатываться
for alarm in session.getAlarms().values(): print '%s (%d): %s' % (session.getObjectName(alarm.getSourceObjectId()), alarm.getCurrentSeverity(), alarm.getMessage())или
for node in filter(lambda x: isinstance(x, objects.Node), s.getAllObjects()): print node.getObjectName()но это работает
import org.netxms.client import sys for action in s.getActions(): name = action.getName() data = action.getData() print name, '---', data -
>>> for alarm in session.getAlarms().values(): ... print '%s (%d): %s' % (session.getObjectName(alarm.getSourceObjectId()), alarm.getCurrentSeverity(), alarm.getMessage()) ... Traceback (most recent call last): File "<stdin>", line 2, in <module> TypeError: %d format: a number is required, not org.netxms.client.constants.Severity >>>Severity теперь Enum.
>>> alarm org.netxms.client.events.Alarm@4e904fd5 >>> session.getObjectName(alarm.getSourceObjectId()) u'AirAlk.local' >>> alarm.getCurrentSeverity() CRITICAL >>> type(alarm.getCurrentSeverity()) <type 'org.netxms.client.constants.Severity'> >>> alarm.getCurrentSeverity().getValue() 4Второй пример у меня отлично работает:
>>> for node in filter(lambda x: isinstance(x, objects.Node), s.getAllObjects()): ... print node.getObjectName() ... AirAlk.local -
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login