Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Commencez à utiliser les CloudWatch alarmes à l'aide d'un AWS SDK
L’exemple de code suivant illustre comment :
- SAP ABAP
-
- SDKpour SAP ABAP
-
DATA lt_alarmnames TYPE /aws1/cl_cwtalarmnames_w=>tt_alarmnames.
DATA lo_alarmname TYPE REF TO /aws1/cl_cwtalarmnames_w.
"Create an alarm"
TRY.
lo_cwt->putmetricalarm(
iv_alarmname = iv_alarm_name
iv_comparisonoperator = iv_comparison_operator
iv_evaluationperiods = iv_evaluation_periods
iv_metricname = iv_metric_name
iv_namespace = iv_namespace
iv_statistic = iv_statistic
iv_threshold = iv_threshold
iv_actionsenabled = iv_actions_enabled
iv_alarmdescription = iv_alarm_description
iv_unit = iv_unit
iv_period = iv_period
it_dimensions = it_dimensions
).
MESSAGE 'Alarm created' TYPE 'I'.
CATCH /aws1/cx_cwtlimitexceededfault.
MESSAGE 'The request processing has exceeded the limit' TYPE 'E'.
ENDTRY.
"Create an ABAP internal table for the created alarm."
CREATE OBJECT lo_alarmname EXPORTING iv_value = iv_alarm_name.
INSERT lo_alarmname INTO TABLE lt_alarmnames.
"Disable alarm actions."
TRY.
lo_cwt->disablealarmactions(
it_alarmnames = lt_alarmnames
).
MESSAGE 'Alarm actions disabled' TYPE 'I'.
CATCH /aws1/cx_rt_service_generic INTO DATA(lo_disablealarm_exception).
DATA(lv_disablealarm_error) = |"{ lo_disablealarm_exception->av_err_code }" - { lo_disablealarm_exception->av_err_msg }|.
MESSAGE lv_disablealarm_error TYPE 'E'.
ENDTRY.
"Describe alarm using the same ABAP internal table."
TRY.
oo_result = lo_cwt->describealarms( " oo_result is returned for testing purpose "
it_alarmnames = lt_alarmnames
).
MESSAGE 'Alarms retrieved' TYPE 'I'.
CATCH /aws1/cx_rt_service_generic INTO DATA(lo_describealarms_exception).
DATA(lv_describealarms_error) = |"{ lo_describealarms_exception->av_err_code }" - { lo_describealarms_exception->av_err_msg }|.
MESSAGE lv_describealarms_error TYPE 'E'.
ENDTRY.
"Delete alarm."
TRY.
lo_cwt->deletealarms(
it_alarmnames = lt_alarmnames
).
MESSAGE 'Alarms deleted' TYPE 'I'.
CATCH /aws1/cx_cwtresourcenotfound .
MESSAGE 'Resource being access is not found.' TYPE 'E'.
ENDTRY.
Pour obtenir la liste complète des guides AWS SDK de développement et des exemples de code, consultezUtilisation CloudWatch avec un AWS SDK. Cette rubrique inclut également des informations sur la mise en route et des détails sur SDK les versions précédentes.