pre cutover push
This commit is contained in:
@ -18,32 +18,18 @@ Parm3:
|
||||
-For Metric updates this represents the numeric data that you wish to send.
|
||||
***************************************************************/
|
||||
|
||||
Declare Subroutine Errmsg, Error_Services
|
||||
Declare function Get_Status
|
||||
Declare Subroutine Errmsg, Error_Services, Delay, Mona_Services
|
||||
Declare function Get_Status, SRP_Datetime, Environment_Services, Httpclient_Services
|
||||
#pragma precomp SRP_PreCompiler
|
||||
|
||||
$Insert LOGICAL
|
||||
$Insert SERVICE_SETUP
|
||||
$Insert REVDOTNETEQUATES
|
||||
|
||||
//Define the dotNet version
|
||||
DotNetHandle = StartDotNet("","4.0")
|
||||
|
||||
//Specify the DLL
|
||||
rv = Set_Property.NET(DotNetHandle, "AssemblyName", "D:\apps\OICurrent\IFXAPI\MonA\monaapi.dll")
|
||||
|
||||
//Define the classes
|
||||
MonAApi = Create_Class.NET(DotNetHandle, "monaapi.monacommands", 0)
|
||||
IF Get_Status(errCode) THEN
|
||||
//ErrMsg(errCode)
|
||||
|
||||
END
|
||||
GoToService else
|
||||
Error_Services('Add', Service : ' is not a valid service request within the ' : ServiceModule : ' services module.')
|
||||
end
|
||||
|
||||
Free_Class.Net(MonAApi)
|
||||
|
||||
return
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -57,21 +43,129 @@ Options STATES = 'OK', 'WARNING', 'CRITICAL'
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Service SendStatus(MonitorName=MONITORS, StatusName, CurrentState=STATES)
|
||||
|
||||
MonInStatusUpdate = Send_Message.NET(MonAApi, "StatusUpdate", MonitorName:@FM:StatusName:@FM:CurrentState, "System.String":@FM:"System.String":@FM:"System.String")
|
||||
|
||||
IF Get_Status(errCode) THEN
|
||||
Return
|
||||
END
|
||||
|
||||
|
||||
Mona_Services("SendBufferedStatus", MonitorName, StatusName, CurrentState)
|
||||
|
||||
end service
|
||||
|
||||
Service SendMetric(MonitorName=MONITORS, MetricName, Number)
|
||||
|
||||
MonInStatusUpdate = Send_Message.NET(MonAApi, "MetricUpdate", MonitorName:@FM:MetricName:@FM:Number, "System.String":@FM:"System.String":@FM:"System.Double")
|
||||
|
||||
IF Get_Status(errCode) THEN
|
||||
Return
|
||||
END
|
||||
Service SendMetric(MonitorName=MONITORS, MetricName, Number)
|
||||
|
||||
Mona_Services("SendBufferedAverageMetric", MonitorName, MetricName, Number)
|
||||
|
||||
end Service
|
||||
|
||||
|
||||
Service SendBufferedStatus(MonaResource, StatusName, StatusValue)
|
||||
|
||||
If MonaResource EQ '' then
|
||||
MonaResource = Environment_Services("GetMonaResource")
|
||||
end
|
||||
|
||||
DateTime = SRP_DateTime('Now')
|
||||
Year = SRP_Datetime("Year", DateTime)
|
||||
Month = SRP_Datetime("Month", DateTime)
|
||||
If Len(Month) EQ 1 then
|
||||
Month = '0':Month
|
||||
end
|
||||
Day = SRP_Datetime("Day", DateTime)
|
||||
If Len(Day) EQ 1 then
|
||||
Day = '0':Day
|
||||
end
|
||||
Hour = SRP_Datetime("Hour", DateTime)
|
||||
If Len(Hour) EQ 1 then
|
||||
Hour = '0':Hour
|
||||
end
|
||||
Minute = SRP_Datetime("Minute", DateTime)
|
||||
If Len(Minute) EQ 1 then
|
||||
Minute = '0':Minute
|
||||
end
|
||||
Second = SRP_Datetime("Second", DateTime)
|
||||
If Len(Second) EQ 1 then
|
||||
Second = '0':Second
|
||||
end
|
||||
|
||||
RequestBodyJson = '{ "resource": "':MonaResource:'"'
|
||||
RequestBodyJson = RequestBodyJson:', "dateTime": "':Year:'-':Month:'-':Day:'T':Hour:':':Minute:':':Second:'Z"'
|
||||
RequestBodyJson = RequestBodyJson:', "statusName": "':StatusName:'"'
|
||||
RequestBodyJson = RequestBodyJson:', "statusValue": "':StatusValue:'" }'
|
||||
|
||||
ApiUrl = Environment_Services("GetMonInBufferedWorkerApiUrl"):'/status'
|
||||
|
||||
retries = 3
|
||||
backoffSeconds = 1
|
||||
isSuccessful = False$
|
||||
|
||||
Loop
|
||||
while (isSuccessful EQ False$ and retries GT 0)
|
||||
waitSeconds = (2 - retries) * backoffSeconds
|
||||
Delay(waitSeconds)
|
||||
|
||||
retries = retries - 1
|
||||
|
||||
response = Httpclient_Services('SendHTTPRequest', 'POST', ApiUrl, 'Content-Type':@VM:'application/json':@FM:'Accept':@VM:'*/*', RequestBodyJson, '', '', False$, False$, '')
|
||||
If response EQ '"Request queued for processing"' then
|
||||
isSuccessful = True$
|
||||
end
|
||||
Repeat
|
||||
|
||||
end service
|
||||
|
||||
|
||||
Service SendBufferedAverageMetric(MonaResource, MetricName, MetricValue)
|
||||
|
||||
If MonaResource EQ '' then
|
||||
MonaResource = Environment_Services("GetMonaResource")
|
||||
end
|
||||
|
||||
DateTime = SRP_DateTime('Now')
|
||||
Year = SRP_Datetime("Year", DateTime)
|
||||
Month = SRP_Datetime("Month", DateTime)
|
||||
If Len(Month) EQ 1 then
|
||||
Month = '0':Month
|
||||
end
|
||||
Day = SRP_Datetime("Day", DateTime)
|
||||
If Len(Day) EQ 1 then
|
||||
Day = '0':Day
|
||||
end
|
||||
Hour = SRP_Datetime("Hour", DateTime)
|
||||
If Len(Hour) EQ 1 then
|
||||
Hour = '0':Hour
|
||||
end
|
||||
Minute = SRP_Datetime("Minute", DateTime)
|
||||
If Len(Minute) EQ 1 then
|
||||
Minute = '0':Minute
|
||||
end
|
||||
Second = SRP_Datetime("Second", DateTime)
|
||||
If Len(Second) EQ 1 then
|
||||
Second = '0':Second
|
||||
end
|
||||
|
||||
RequestBodyJson = '{ "resource": "':MonaResource:'"'
|
||||
RequestBodyJson = RequestBodyJson:', "dateTime": "':Year:'-':Month:'-':Day:'T':Hour:':':Minute:':':Second:'Z"'
|
||||
RequestBodyJson = RequestBodyJson:', "metricName": "':MetricName:'"'
|
||||
RequestBodyJson = RequestBodyJson:', "metricValue": "':MetricValue:'" }'
|
||||
|
||||
ApiUrl = Environment_Services("GetMonInBufferedWorkerApiUrl"):'/average'
|
||||
|
||||
retries = 3
|
||||
backoffSeconds = 1
|
||||
isSuccessful = False$
|
||||
|
||||
Loop
|
||||
while (isSuccessful EQ False$ and retries GT 0)
|
||||
waitSeconds = (2 - retries) * backoffSeconds
|
||||
Delay(waitSeconds)
|
||||
|
||||
retries = retries - 1
|
||||
|
||||
response = Httpclient_Services('SendHTTPRequest', 'POST', ApiUrl, 'Content-Type':@VM:'application/json':@FM:'Accept':@VM:'*/*', RequestBodyJson, '', '', False$, True$, '')
|
||||
If response EQ '"Request queued for processing"' then
|
||||
isSuccessful = True$
|
||||
end
|
||||
Repeat
|
||||
|
||||
end service
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user