-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from cisagov/improvement/add-ssm-script
Add shell script to gather log data via SSM
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
# | ||
# Gather ClamAV scan log data from a list of AWS instances via SSM. | ||
# | ||
# Usage: ./clamav_log_report.sh <instance-id>... | ||
|
||
set -o nounset | ||
set -o errexit | ||
set -o pipefail | ||
|
||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then | ||
echo "Usage: $0 <instance-id>..." | ||
exit 1 | ||
fi | ||
|
||
today=$(date +%Y%m%d) | ||
logfile="./clamav-$today.log" | ||
# tee -a: Append to existing logfile | ||
# tee -i: Ignore SIGINT signals | ||
exec > >(tee -ai "$logfile") | ||
exec 2> >(tee -ai "$logfile" >&2) | ||
|
||
clamav_scan_log="/var/log/clamav/lastscan.log" | ||
|
||
instances=("$@") | ||
|
||
for instance_id in "${instances[@]}"; do | ||
# tail --lines=12: Output last 12 lines of ClamAV scan log, which includes | ||
# the summary of the most-recent scan results. | ||
aws ssm start-session --target="$instance_id" \ | ||
--document=AWS-StartInteractiveCommand \ | ||
--parameters command="hostname; tail --lines=12 $clamav_scan_log" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
"""This file defines the version of this module.""" | ||
__version__ = "0.2.0" | ||
__version__ = "0.2.1" |