Skip to content

Commit

Permalink
added null check
Browse files Browse the repository at this point in the history
  • Loading branch information
schandrika committed Oct 1, 2024
1 parent 38761dc commit 4825c38
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/sysmon/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
import psutil
from gevent import sleep
from volttron import utils
from volttron.client.logs import setup_logging
from volttron.client.vip.agent import RPC, Agent
from volttron.utils.scheduling import periodic

utils.setup_logging()
setup_logging()
_log = logging.getLogger(__name__)
__version__ = '4.0'

Expand Down Expand Up @@ -209,15 +210,16 @@ def on_configure(self, config_name, action, contents):
sleep(1) # Wait for a second to pass to avoid divide by zero errors from tracking variables.
for method in self.IMPLEMENTED_METHODS:
item = monitors.pop(method, None)
if method == 'path_usage_rate' and item.get('path_name', None):
# Set initial value(s) of self.last_path_sizes for any configured path names.
self.path_usage_rate(item.get('path_name'))
if item and item.pop('poll', None) is True:
item_publish_type = item.get('publish_type', None)
item_publish_type = 'record' if method in self.RECORD_ONLY_PUBLISH_METHODS else item_publish_type
item_publish_type = item_publish_type if item_publish_type else self.default_publish_type
self._periodic_pub(getattr(self, method), item_publish_type, item['check_interval'], item['point_name'],
item['params'])
if item:
if method == 'path_usage_rate' and item.get('path_name', None):
# Set initial value(s) of self.last_path_sizes for any configured path names.
self.path_usage_rate(item.get('path_name'))
if item and item.pop('poll', None) is True:
item_publish_type = item.get('publish_type', None)
item_publish_type = 'record' if method in self.RECORD_ONLY_PUBLISH_METHODS else item_publish_type
item_publish_type = item_publish_type if item_publish_type else self.default_publish_type
self._periodic_pub(getattr(self, method), item_publish_type, item['check_interval'], item['point_name'],
item['params'])

for key in contents:
_log.warning('Ignoring unrecognized configuration parameter %s', key)
Expand Down

0 comments on commit 4825c38

Please sign in to comment.