11
11
using System . Threading . Tasks ;
12
12
using System . Web . Http ;
13
13
using System . Web . Http . Controllers ;
14
+ using Microsoft . Azure . WebJobs . Script . Config ;
14
15
using Microsoft . Azure . WebJobs . Script . Description ;
15
16
using Microsoft . Azure . WebJobs . Script . WebHost . Filters ;
16
17
using Microsoft . Azure . WebJobs . Script . WebHost . Models ;
@@ -87,18 +88,20 @@ public FunctionStatus GetFunctionStatus(string name)
87
88
[ HttpGet ]
88
89
[ Route ( "admin/host/status" ) ]
89
90
[ AllowAnonymous ]
90
- public HostStatus GetHostStatus ( )
91
+ public IHttpActionResult GetHostStatus ( )
91
92
{
92
- var status = new HostStatus ( ) ;
93
-
94
93
// based on the authorization level we determine
95
- // the additional level of detail to return
94
+ // the level of detail to return
96
95
var authorizationLevel = Request . GetAuthorizationLevel ( ) ;
97
- if ( authorizationLevel == AuthorizationLevel . Admin )
96
+ if ( authorizationLevel == AuthorizationLevel . Admin ||
97
+ Request . IsAntaresInternalRequest ( ) )
98
98
{
99
- status . State = _scriptHostManager . State . ToString ( ) ;
100
- status . Version = ScriptHost . Version ;
101
- status . Id = _scriptHostManager . Instance ? . ScriptConfig . HostConfig . HostId ;
99
+ var status = new HostStatus
100
+ {
101
+ State = _scriptHostManager . State . ToString ( ) ,
102
+ Version = ScriptHost . Version ,
103
+ Id = _scriptHostManager . Instance ? . ScriptConfig . HostConfig . HostId
104
+ } ;
102
105
103
106
var lastError = _scriptHostManager . LastError ;
104
107
if ( lastError != null )
@@ -107,13 +110,22 @@ public HostStatus GetHostStatus()
107
110
status . Errors . Add ( Utility . FlattenException ( lastError ) ) ;
108
111
}
109
112
110
- return status ;
113
+ var parameters = Request . GetQueryParameterDictionary ( ) ;
114
+ string value = null ;
115
+ if ( parameters . TryGetValue ( ScriptConstants . CheckLoadQueryParameterName , out value ) && value == "1" )
116
+ {
117
+ status . Load = new LoadStatus
118
+ {
119
+ IsHigh = _scriptHostManager . PerformanceManager . IsUnderHighLoad ( )
120
+ } ;
121
+ }
122
+
123
+ return Ok ( status ) ;
111
124
}
112
125
else
113
126
{
114
- // for Anonymous requests, we don't return any
115
- // detailed info
116
- return status ;
127
+ // for Anonymous requests, we don't return any info
128
+ return Ok ( ) ;
117
129
}
118
130
}
119
131
0 commit comments