iis_bridge is a python package for manipulating IIS and monitoring iis pools' memory on windows.
IIS = Internet Information Services. It's a .net web app server.
iis_bridge has been tested with python 2.7 on:
1 | pip install iis_bridge |
1 2 3 4 5 6 7 8 | import iis_bridge as iis # to install iis: iis.install() print ( "iis version %s" % iis.get_version()) # to reset iis: iis.iisreset() |
1 2 3 4 5 | import iis_bridge as iis # to list the pool names: print (iis.get_pool_names()) # to list the site names: print (iis.get_site_names()) |
1 2 3 | def create(name, runtime_version = "4.0" , pipeline_mode = "Integrated" ): |
1 2 3 4 5 | import iis_bridge.pool as pool if not pool.exists( "some_pool" ): pool.create( "some_pool" ) if pool.is_running( "some_pool" ): print ( "The pool is running!" ) |
1 2 3 4 | import iis_bridge.pool as pool pool.stop( "some_pool" ) pool.stat( "some_pool" ) pool.restart( "some_pool" ) |
1 2 3 4 5 6 7 8 9 10 11 12 | import iis_bridge.pool as pool pool.config( "DefaultAppPool" , thirty_two_bit = False ) pool.config( "DefaultAppPool" , identity = "ApplicationPoolIdentity" ) pool.config( "DefaultAppPool" , identity = "LocalService" ) pool.config( "DefaultAppPool" , identity = "LocalSystem" ) pool.config( "DefaultAppPool" , identity = "NetworkService" ) pool.config( "DefaultAppPool" , identity = "SpecificUser" , username = "my_username" , password = "my_pass" ) # to set the idle timeout to 30 minutes: pool.config( "DefaultAppPool" , idle_timeout = "00:30:00" ) # note that small values ()like 10 seconds) are not allowed pool.config( "DefaultAppPool" , pipeline_mode = "Classic" ) |
1 2 3 | import iis_bridge.pool as pool if pool.exists( "some_pool" ): pool.delete( "some_pool" ) |
1 2 3 4 5 6 7 | # to add an iis site on port 5050: import iis_bridge.site as site # site name, port number, app directory, app pool name site.create( "mysite" , 5050 , r "C:\inetpub\wwwroot\myapp" , "mypool" ) # now to list the site names: print (iis.get_site_names()) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | def monitor_with_load(iterations, # this is the number of iterations of sending the requests = Total duration of sending requests urls, # list of urls to send the requests to. If 'all' is specified, it retrieves the app pools and sends requests to http://localhost:[port] rate, # how many parallel requests to send per iteration mem_type = 'WorkingSetPrivate' , # the type of memory to monitor mem_unit = 'KB' , # the units of memory to monitor timeout = 15 # http timeout in seconds ) def html_report(datasets, # the datasets to plot mem_type = 'WorkingSetPrivate' , # the type of memory to monitor mem_unit = 'KB' , # the memory unit: Bytes, KB, MB output_path = 'out.html' , # the path where to save the html report pools_to_monitor = None # list of pools to plot. If not specified, all pools will be plotted ): |
1 2 3 | import iis_bridge.mon as mon datasets = mon.monitor_with_load( 6 , 'all' , 12 , timeout = 30 ) # timeout is in seconds - default=15sec mon.html_report(datasets) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import iis_bridge.mon as mon import iis_bridge.site as site app1_port = site.get_port( "App1" ) app2_port = site.get_port( "App2" ) [ "http://localhost:190/CalcService.svc/multiply" , "POST" , "<list><int>1<int><int>2<int><int>3<int></int></int></int></int></int></int></list>" , "xml" ] ] pools = [ "App1" , "App2" ] mem_unit = 'MB' duration = 10 # seconds reqs_per_sec = 16 # how many request to send per second datasets = mon.monitor_with_load(duration, urls, reqs_per_sec, mem_unit = mem_unit) mon.html_report(datasets, pools_to_monitor = pools, mem_unit = mem_unit) print ( "Done" ) |
1 | site.get_port( "App1" ) |
1 2 3 4 | import iis_bridge.mem as mem for w in mem.get_workers(): print ( str (w)) output>> DefaultAppPool: pid = 12768 WorkingSetPrivate = 10052 |
1 2 3 4 5 6 | http_thread = load_gen.HttpFlood(iterations, # number of iterations urls, # the list of urls to send http requests to rate, # the number of reuqests to send per interval (default per second) interval = interval, # (optional default=1 second) the interval between iterations of parallel requests timeout = 15 # http timeout in seconds ) |
1 2 3 4 5 6 7 8 9 10 11 | import iis_bridge.load_gen as load_gen # send 6 requests per second for 10 seconds: http_thread = load_gen.HttpFlood( 10 , urls, 6 ) http_thread.start() # do your own monitoring if you prefer another tool http_thread.join() # wait for the http generator to stop print ( "Number of successful requests sent: %i" % http_thread.total_resp_received) print ( "Average response time: %f seconds" % http_thread.avg_res_time) |
1 | iis.register_asp() |
1 2 | import iis_bridge.isapi as isapi isapi.enable() |
1 2 | import iis_bridge as iis iis.install_wcf() |
1 2 3 | # to install WCF-Services45 and CF-HTTP-Activation45: import iis_bridge as iis iis.install_wcf([ "WCF-Services45" , "WCF-HTTP-Activation45" ]) |