topic_watcher.agent module¶
-
class
topic_watcher.agent.
AlertAgent
(config_path, **kwargs)[source]¶ Bases:
volttron.platform.vip.agent.Agent
-
decrement_ttl
()[source]¶ Periodic call
Used to maintain the time since each topic’s last publish. Sends an alert if any topics are missing.
-
ignore_topic
(group, topic)[source]¶ RPC method
Remove a topic from agent’s watch list. Alerts will no longer be sent if a topic stops being published.
-
property
remote_agent
¶
-
watch_device
(group, topic, timeout, points)[source]¶ RPC method
Watch a device’s ALL topic and expect points. If the given group is new creates and starts an instance of group agent for the new group. The group onstart will start watching for the given device points
-
watch_topic
(group, topic, timeout)[source]¶ RPC method
Listen for a topic to be published within a given number of seconds or send alerts. If the given group is new creates and starts an instance of AlertGroup agent for the new group. The alert group agent, onstart, will start watching for the given topics
-
-
class
topic_watcher.agent.
AlertGroup
(group_name, config, connection, main_agent, publish_local=True, publish_remote=False)[source]¶ Bases:
object
-
static
get_topic_name
(parts)[source]¶ Return the input parameter if input parameter is a string. If input parameter is a tuple, expects an all topic as the first list element and point name as the second element of the tuple. strips “all” from the end of topic name and add the point name to it to get point topic string :param parts: topic name or (all topic, point name) :type parts: str or list :return: topic string :rtype: str
-
ignore_topic
(topic)[source]¶ Remove a topic from the group watchlist
- Parameters
topic (str) – Topic to remove from the watch list.
-
log_time_up
(up_time, log_topics)[source]¶ Log into topic_log table when the alert agent found publishes to a topic after the last time it timed out. :param up_time: Time when message was published to the topic. Note that this need not be the same as the timestamp in message header which gets recorded in the historian. For example, when older device scrapes are replayed. :param log_topics: The list of configured topics for which message was received. Entries in this list can either be topic string or a tuple containing an all topic and a point name. :type up_time: datetime :type log_topics: list
-
log_timeout
(log_topics)[source]¶ logs into database the last time a topic was seen before a time out or current time if topic was never seen from the time of alert agent start. :param log_topics: The list of configured topics for which message was received. Entries in this list can either be topic string or a tuple containing an all topic and a point name. :type log_topics: list
-
reset_time
(peer, sender, bus, topic, headers, message)[source]¶ Callback for topic subscriptions
Resets the timeout for topics and devices when publishes are received.
-
restart_timer
()[source]¶ Reset timer for all topics in this alert group. Should be called when a new topic is added to a currently active alert group
-
send_alert
(unseen_topics)[source]¶ Send an alert for the group, summarizing missing topics.
- Parameters
unseen_topics (list) – List of topics that were expected but not received
-
static