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