1. 在上一篇文章当中,我们迁了平台,还装了监控服务端。当初计划是将zabbix front和zabbix server进行分离,但是因为执行脚本的是zabbix server,所以我并没有做这样一个尝试,因为我很想知道,老外提供的方案是否真的可行? 
  2.  
  3. 遇到问题: 
  4. 1、手工执行时,不会报错,但在日志中执行发送skype消息时,则报错! 
  5. No protocol specified 
  6. No protocol specified 
  7. Traceback (most recent call last): 
  8.   File "/home/skype/sendim.py", line 4, in <module> 
  9.     skype = Skype4Py.Skype() 
  10.   File "/usr/local/lib/python2.7/dist-packages/Skype4Py/skype.py", line 192, in __init__ 
  11.     self._API = _ISkypeAPI(self._Handler, Options) 
  12.   File "/usr/local/lib/python2.7/dist-packages/Skype4Py/API/posix.py", line 34, in _ISkypeAPI 
  13.     return _ISkypeAPI(handler, opts) 
  14.   File "/usr/local/lib/python2.7/dist-packages/Skype4Py/API/posix_x11.py", line 196, in __init__ 
  15.     raise ISkypeAPIError('Could not open XDisplay') 
  16. Skype4Py.errors.ISkypeAPIError: Could not open XDisplay 
  17.  
  18. 为什么遇到这个问题? 
  19. 因为我看到以下描述,认为它操作太麻烦了,我就开个vnc呗! 
  20. Setting up the skype notification service 
  21. Please ensure, that you have vncviewer installed on your (local) ubuntu workstation. 
  22.  
  23. Log in to your server: ssh -L 5900:127.0.0.1:5900 ‘skype@your.zabbix.server’ 
  24.  
  25. start xfvb, fluxbox and skype: ./start-server.sh start 
  26. start the vnc server: ./start-vnc.sh start 
  27. on your local ubuntu workstation you start vnc-viewer: vncviewer 127.0.0.1 
  28. You should now be seeing the fluxbox desktop and skype 
  29. Enter the username and password and ensure, that the credentials get saved. 
  30. Go to settings and set the following options 
  31. no chat history 
  32. just people on my list can write me 
  33. just people on my list can call me 
  34. Send your first skype message on the server as skype user: ./sendim.sh ‘USERNAME’ ‘HELLO WORLD’ 
  35. Skype asks now, if skype4py should be allowed. Click on remember and allow! 
  36. stop the vnc-server: ./start-vnc.sh stop 
  37. Now the skype service is up and running. 
  38. 于是就发生了我刚说的报错。 在此需要说明: 
  39.  
  40. 1、因为skype在之后运行时,并没有调vnc(第一次需要,你需要设置一个账户登录 )而是xvfb,关于xvfb我没有深究。 
  41. 2、如果你在vnc中,打开了skype,你使用./sendim.sh "skypefriend" "message" 是可以执行成功的! 
  42. 3、如果你关了vnc,你会发现执行脚本的报错跟我一样。 
  43. 你会发现使用./start-server.sh start 启动后,会侦听一个端口6001,但你去没法连上去。 
  44.  
  45. 解决办法: 
  46. 1、关掉vnc,删除/tmp/.X*   
  47. 2、./start-server.sh start  //启动xvfb 

 整个大环境介绍:

之前的配置是RHEL5.5+zabbix1.8.10,目前因为需要将消息发送给skype的需求,现对环境做更改。

具体的是:

使用Ubuntu server 12.0.4来替换RHEL5.5。

按照老外大牛的博客进行操作:  http://www.qxs.ch/2011/01/07/skype-instant-messages-from-zabbix/

推荐阅读如下:

1、zabbix通过skype发送报警消息之安装skype http://myhat.blog.51cto.com/391263/925274

2、zabbix通过skype发送报警消息之切换平台 http://myhat.blog.51cto.com/391263/926247

3、zabbix通过skype发送报警消息之弯路 http://myhat.blog.51cto.com/391263/926296

4、zabbix通过skype发送报警消息之终结  http://myhat.blog.51cto.com/391263/923592