• setup notifier actions in aodh alarm


    Aodh alarm NOTIFIER ==>

    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("
    ----- Request Start ----->
    ")
            print(request_path)
            print(self.headers)
            print("<----- Request End -----
    ")
            
            self.send_response(200)
            self.send_header("Set-Cookie", "foo=bar")
            
        def do_POST(self):
            
            request_path = self.path
            
            print("
    ----- Request Start ----->
    ")
            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 -----
    ")
            
            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
    "
                        "Run:
    
    "
                        "   reflect")
        (options, args) = parser.parse_args()
        
        main()
  • 相关阅读:
    Centos7 关闭防火墙
    Linux下磁盘挂载
    Sqlserver游标复习
    Redis-benchmark测试Redis性能
    将treeview控件内容导出图片
    使用redis进行消息推送
    web性能优化系列之网站瓶颈识别
    SqlServer时间格式化
    PHP二位数组/多维数组 根据某个键值排序
    VIM Taglist + ctags
  • 原文地址:https://www.cnblogs.com/lifeinsmile/p/5583272.html
Copyright © 2020-2023  润新知