Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
apcupsarn
s3logs
http_healthcheck_reboot_lambda.py
readme.md

readme.md

AWS scripts and tools

HTTP HealthCheck Reboot Tool

This is a very simple lambda script for rebooting EC2 instance when HTTP(s) site is unreachable or does not contain selected text.

When you create this Lambda script in AWS you should trigger it by CloudWatch Events trigger with Schedule expression set up for rate(1 hour) or whatever you like. For most scenarios it should run completely free of charge in free tier usage.

It is also needed to increase timeout for this script - recommended value is 10 minutes but might be lower.

Diagram

HTTP Health Check

AWS APC Ups state of lose power publisher

I was solving issue that I wanted to know when my UPS lose and restore power. First idea was to use some kind of e-mail but it is very difficult to configure to pass your message through SPAM folder etc. Using SNS (Simple Notification Service) within AWS is so much more easier. You just use Python three liner to publish message to ARN queue and then SNS publish it to your e-mail, SMS or whatever of your choice.

Diagram

UPS

S3Logs

This tools watches logs directory where are the S3 Logs files stored with Lambda script located in aws directory and when there is triggered S3 bucket event - ObjectCreated on directory where S3 logs are stored the lambda script creates the message in SQS (Simple Queue Service) and delete log file.

After that there is running SystemD daemon on Linux machine with MySQL installed called s3logs_daemon.py (stored in scripts directory) which check SQS queue for new logs and insert them into MySQL database.

Please be informed that there is no frontend - the main reason is that I find using PHPMyAdmin more universal and better because I can create directly SQL queries which I like.

Diagram

S3 Logs diagram

Installation

some image tutorial is stored in imgs directory

  1. Clone repository to your directory
  2. Set-up S3 logs in directory you like
  3. Create lambda function (source file is stored in aws directory) which is triggered by CloudWatch event ObjectCreated on S3 Logs directory.
  4. Set-up SQS queue
  5. Wait few hours (S3 logs are created only every few hours not on every access)
  6. Check SQS queue that it contains messages
  7. Install MySQL, PhpMyAdmin, Apache
  8. Create database with initial structure (sql file is in the scripts directory)
  9. Install scripts and SystemD service files
  10. Start and enable SystemD service

Of course do not forget to change variables in various script files. Also the path where scripts should be installed is visible in the source files.

You can’t perform that action at this time.