Suppose I have an ec2 instance with service /etc/init/my_service.conf
with contents
script
exec my_exec
end script
How can I monitor that ec2 instance such that if my_service
stopped running I can act on it?
Suppose I have an ec2 instance with service /etc/init/my_service.conf
with contents
script
exec my_exec
end script
How can I monitor that ec2 instance such that if my_service
stopped running I can act on it?
You can publish a custom metric to CloudWatch in the form of a "heart beat".
put-metric-data
call to CloudWatch.See here for how to publish a custom metric: http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/publishingMetrics.html
I am not sure if CloudWatch is the right route for checking if the service is running - it would be easier with Nagios kind of solution.
Nevertheless, you may try the CloudWatch Custom metrics approach. You add Additional lines of code which publishes say an integer 1 to CloudWatch Custom Metrics every 5 mins. Your can then configure CloudWatch alarms to do a SNS Notification / Mail Notification for the conditions like Sample Count or sum deviating your anticipated value.
More Info
Publish Custom Metrics - http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/publishingMetrics.html