2017-09-13 105 views
0

我设置了一个跟踪Ubuntu Server 16.04上所有Ubuntu Server 16.04小工具上磁盘使用情况的信标。我们需要一个反应器,当磁盘空间达到某个特定点时,它会通过电子邮件发送给我们这个问题关注的是主人发送电子邮件的能力。Saltstack smtp.send_msg返回属性错误

sudo salt-call smtp.send_msg '[email protected]' 'Test message 3' subject='Test subject 3' profile='smtp-default' 

我得到以下结果:

[ERROR ] An un-handled exception was caught by salt's global exception handler: 
AttributeError: 'str' object has no attribute 'get' 
Traceback (most recent call last): 
    File "/usr/bin/salt-call", line 11, in <module> 
    salt_call() 
    File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 391, in salt_call 
    client.run() 
    File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 58, in run 
    caller.run() 
    File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 134, in run 
    ret = self.call() 
    File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 204, in call 
    ret['return'] = func(*args, **kwargs) 
    File "/usr/lib/python2.7/dist-packages/salt/modules/smtp.py", line 95, in send_msg 
    server = creds.get('smtp.server') 
AttributeError: 'str' object has no attribute 'get' 
Traceback (most recent call last): 
    File "/usr/bin/salt-call", line 11, in <module> 
    salt_call() 
    File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 391, in salt_call 
    client.run() 
    File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 58, in run 
    caller.run() 
    File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 134, in run 
    ret = self.call() 
    File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 204, in call 
    ret['return'] = func(*args, **kwargs) 
    File "/usr/lib/python2.7/dist-packages/salt/modules/smtp.py", line 95, in send_msg 
    server = creds.get('smtp.server') 
AttributeError: 'str' object has no attribute 'get' 

这是我返回错误的主盐--versions报告输出当我在盐主机上运行以下命令:

Salt Version: 
      Salt: 2017.7.1 

Dependency Versions: 
      cffi: 1.10.0 
     cherrypy: unknown 
     dateutil: 2.4.2 
     docker-py: Not Installed 
      gitdb: 0.6.4 
     gitpython: 1.0.1 
      ioflo: Not Installed 
     Jinja2: 2.8 
     libgit2: Not Installed 
     libnacl: Not Installed 
     M2Crypto: Not Installed 
      Mako: 1.0.3 
    msgpack-pure: Not Installed 
msgpack-python: 0.4.6 
    mysql-python: Not Installed 
     pycparser: 2.18 
     pycrypto: 2.6.1 
    pycryptodome: Not Installed 
     pygit2: Not Installed 
     Python: 2.7.12 (default, Nov 19 2016, 06:48:10) 
    python-gnupg: Not Installed 
     PyYAML: 3.11 
      PyZMQ: 15.2.0 
      RAET: Not Installed 
      smmap: 0.9.0 
     timelib: Not Installed 
     Tornado: 4.2.1 
      ZMQ: 4.1.4 

System Versions: 
      dist: Ubuntu 16.04 xenial 
     locale: UTF-8 
     machine: x86_64 
     release: 4.4.0-93-generic 
     system: Linux 
     version: Ubuntu 16.04 xenial 

我已经卸载并重新安装盐主盐,奴才,我已经更新了Python和盐主。我也创建了另一个salt-master,它遇到了同样的问题。这是什么修复或解决方案?

回答

0

我发现错误与已安装的Python库无关,或者如果我的系统更新与否。我发现我没有设置SMTP服务器,我需要创建一个SMTP邮件服务器或者有一个可访问的SMTP邮件服务器才能发送电子邮件作为反应器系统的通知。我发现,解决办法是建立一个SMTP邮件服务器,然后创建在/etc/salt/minion.d目录中的.conf文件所引用的SMTP邮件服务器,像这样:

smtp-default: 
    smtp.sender: [email protected] 
    smtp.server: 0.0.0.0 
    smtp.tls: false 

创建后.conf文件类似于上面的那个,以及参考状态文件的函数声明的salt-call命令的配置文件,我能够发送电子邮件到所需的地址。