setup notifier actions in aodh alarm
2016-06-14 10:56
561 查看
Aodh alarm NOTIFIER ==>
NOTIFIER will resolve the URL and post the data to http server
setup a Http server ==>
such as: python -m SimpleHTTPServer 8000
link: https://docs.python.org/2/library/simplehttpserver.html
NOTE: this case only receive the posted data, but not handle it.
such as:
alarm_actions URL: http://<host>/<action>
NOTIFIER will resolve the URL and post the data to http server
setup a Http server ==>
such as: python -m SimpleHTTPServer 8000
link: https://docs.python.org/2/library/simplehttpserver.html
NOTE: this case only receive the posted data, but not handle it.
such as:
stack@stack:~$ cat reflect.py #!/usr/bin/env python # Reflects the requests from HTTP methods GET, POST, PUT, and DELETE # Written by Nathan Hamiel (2010) from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from optparse import OptionParser class RequestHandler(BaseHTTPRequestHandler): def do_GET(self): request_path = self.path print("\n----- Request Start ----->\n") print(request_path) print(self.headers) print("<----- Request End -----\n") self.send_response(200) self.send_header("Set-Cookie", "foo=bar") def do_POST(self): request_path = self.path print("\n----- Request Start ----->\n") print(request_path) request_headers = self.headers content_length = request_headers.getheaders('content-length') length = int(content_length[0]) if content_length else 0 print(request_headers) print(self.rfile.read(length)) print("<----- Request End -----\n") self.send_response(200) do_PUT = do_POST do_DELETE = do_GET def main(): port = 8000 print('Listening on localhost:%s' % port) server = HTTPServer(('0.0.0.0', port), RequestHandler) server.serve_forever() if __name__ == "__main__": parser = OptionParser() parser.usage = ("Creates an http-server that will echo out any GET or POST parameters\n" "Run:\n\n" " reflect") (options, args) = parser.parse_args() main()
相关文章推荐
- Swift语法糖的使用
- python实现中文转换url编码的方法
- Java checked异常和unchecked异常。
- 勇士队加油啊!!!!!!!
- Web储存
- 【leetcode】318. Maximum Product of Word Lengths My Submissions QuestionEditorial Solution
- 为了理解的位操作运算符
- Spring Date JPA 底层方法名对应关键字
- 微软商业智能
- 第二阶段冲刺第五天
- SQLSERVER进程CPU使用率100%
- 学习最优化
- 经典算法题06-最长子序列
- Scrollview嵌套listView数据显示不正常问题
- jQuery实例―选项卡的简单实现(js源码和jQuery)
- 【java线程】创建线程的两种方式
- Objective-C文件和目录操作,IOS文件操作,NSFileManager使用文件操作
- Android保持屏幕常亮的三种方法
- Yii2 使DataProvider分页时,page超过最大页数不进行处理
- int to hex