Skip to content

Commit b66cfac

Browse files
author
ukmda
authored
Merge pull request #372 from ukmda/master
Updates and Enhancements April 2024
2 parents a0ebeae + bd5f980 commit b66cfac

24 files changed

Lines changed: 558 additions & 99 deletions

archive/.bash_aliases

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ alias du='du -h'
88
alias data='if [ "$SRC" == "" ] ; then echo select env first; else cd $SRC/data && pwd ; fi'
99
alias logs='if [ "$SRC" == "" ] ; then echo select env first; else cd $SRC/logs && pwd ; fi'
1010

11-
alias tml='if [ "$SRC" == "" ] ; then echo select env first; else tail -f $(ls -1 $SRC/logs/matches-*.log | tail -1) ; fi'
12-
alias tnj='if [ "$SRC" == "" ] ; then echo select env first; else tail -f $(ls -1 $SRC/logs/nigh*.log | tail -1) ; fi'
11+
alias tml='if [ "$SRC" == "" ] ; then echo select env first; else tail -f $(ls -1 $SRC/logs/matchJob.log | tail -1) ; fi'
12+
alias tnj='if [ "$SRC" == "" ] ; then echo select env first; else tail -f $(ls -1 $SRC/logs/nightlyJob.log | tail -1) ; fi'
1313

1414
alias stats='if [ "$DATADIR" == "" ] ; then echo select env first; else tail $DATADIR/dailyreports/stats.txt ; fi'
1515

16-
alias matchstatus='if [ "$SRC" == "" ] ; then echo select env first; else grep "Running" $(ls -1 $SRC/logs/matches-*.log| tail -1 ) && grep TRAJ $(ls -1 $SRC/logs/matches-*.log | tail -1)|grep SOLVING && echo -n "Completed " && grep Observations: $(ls -1 $SRC/logs/matches-*.log | tail -1) | wc -l && nj=$(ls -1 $SRC/logs/nightly* | tail -1) && grep "nightlyJob" $nj | tail -1 ; fi '
16+
alias matchstatus='if [ "$SRC" == "" ] ; then echo select env first; else grep "Running" $SRC/logs/matchJob.log && grep TRAJ $SRC/logs/matchJob.log | grep SOLVING && echo -n "Completed " && grep Observations: $SRC/logs/matchJob.log | wc -l && grep "nightlyJob" $SRC/logs/nightlyJob.log ; fi '
1717
alias spacecalc='ls -1 | egrep -v "ukmon-shared" | while read i ; do \du -s $i ; done | sort -n'
1818

1919
alias startcalc='~/prod/utils/stopstart-calcengine.sh start'
@@ -34,7 +34,7 @@ function prd {
3434

3535
function calcserver {
3636
sts=$(aws ec2 describe-instances --instance-ids $SERVERINSTANCEID --query Reservations[*].Instances[*].State --output text --profile ukmonshared)
37-
ipaddr=$(aws ec2 describe-instances --instance-ids $SERVERINSTANCEID --query Reservations[*].Instances[*].PublicIpAddress --output text --profile ukmonshared)
37+
ipaddr=$(aws ec2 describe-instances --instance-ids $SERVERINSTANCEID --query Reservations[*].Instances[*].PrivateIpAddress --output text --profile ukmonshared)
3838
isrunning=$(echo $sts | cut -d " " -f 1)
3939
if [ $isrunning -ne 16 ] ; then
4040
/home/ec2-user/prod/utils/stopstart-calcengine.sh start

archive/analysis/findAllMatches.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ log2cw $NJLOGGRP $NJLOGSTREAM "start runDistrib" findAllMatches
6565
$SRC/analysis/runDistrib.sh $MATCHSTART $MATCHEND
6666

6767
log2cw $NJLOGGRP $NJLOGSTREAM "start checkForFailures" findAllMatches
68-
logf=$(ls -1tr $SRC/logs/matches-*.log | tail -1)
69-
success=$(grep "Total run time:" $logf)
68+
success=$(grep "Total run time:" $SRC/logs/matchJob.log)
7069

7170
if [ "$success" == "" ]
7271
then
@@ -86,7 +85,7 @@ log2cw $NJLOGGRP $NJLOGSTREAM "start getMatchStats" findAllMatches
8685
dailyrep=$(ls -1tr $DATADIR/dailyreports/20* | tail -1)
8786
trajlist=$(cat $dailyrep | awk -F, '{print $2}')
8887

89-
matchlog=$( ls -1 ${SRC}/logs/matches-*.log | tail -1)
88+
matchlog=${SRC}/logs/matchJob.log
9089
vals=$(python -m metrics.getMatchStats $matchlog )
9190
evts=$(echo $vals | awk '{print $2}')
9291
trajs=$(echo $vals | awk '{print $6}')

archive/analysis/getLogData.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ fi
1616
# create performance metrics
1717
cd $SRC/logs
1818
python -m metrics.timingMetrics $rundate
19-
aws s3 cp $rundate-perfNightly.jpg $WEBSITEBUCKET/reports/batchcharts/ --quiet
19+
mv -f $rundate-perfNightly.jpg $DATADIR/
20+
aws s3 cp $DATADIR/$rundate-perfNightly.jpg $WEBSITEBUCKET/reports/batchcharts/ --quiet
2021

21-
lastmtch=$(ls -1tr $SRC/logs/matches-${rundate}-*.log | tail -1)
22+
#lastmtch=$(ls -1tr $SRC/logs/matches-${rundate}-*.log | tail -1)
23+
if [ $rundate != $(date +%Y%m%d) ] ; then
24+
lastmtch=matchJob.log-$rundate
25+
else
26+
lastmtch=matchJob.log
27+
fi
2228

2329
python -m reports.findFailedMatches $rundate
2430

archive/analysis/onlyConsolDistrib.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ logger -s -t onlyConsolDistrib "consolidating for $rundate"
4848

4949
python -c "from traj.distributeCandidates import monitorProgress as mp; mp('${rundate}'); "
5050

51-
privip=$(aws ec2 describe-instances --instance-ids $SERVERINSTANCEID --query Reservations[*].Instances[*].PublicIpAddress --output text --profile ukmonshared)
51+
privip=$(aws ec2 describe-instances --instance-ids $SERVERINSTANCEID --query Reservations[*].Instances[*].PrivateIpAddress --output text --profile ukmonshared)
5252
while [ "$privip" == "" ] ; do
5353
sleep 5
5454
echo "getting ipaddress"
55-
privip=$(aws ec2 describe-instances --instance-ids $SERVERINSTANCEID --query Reservations[*].Instances[*].PublicIpAddress --output text --profile ukmonshared)
55+
privip=$(aws ec2 describe-instances --instance-ids $SERVERINSTANCEID --query Reservations[*].Instances[*].PrivateIpAddress --output text --profile ukmonshared)
5656
done
5757

5858
if [ -s $DATADIR/distrib/processed_trajectories.json ] ; then

archive/analysis/runDistrib.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ python -m traj.createDistribMatchingSh $MATCHSTART $MATCHEND $execMatchingsh
6565
chmod +x $execMatchingsh
6666

6767
log2cw $NJLOGGRP $NJLOGSTREAM "get server details" runDistrib
68-
privip=$(aws ec2 describe-instances --instance-ids $SERVERINSTANCEID --query Reservations[*].Instances[*].PublicIpAddress --output text)
68+
privip=$(aws ec2 describe-instances --instance-ids $SERVERINSTANCEID --query Reservations[*].Instances[*].PrivateIpAddress --output text)
6969
while [ "$privip" == "" ] ; do
7070
sleep 5
7171
log2cw $NJLOGGRP $NJLOGSTREAM "getting IP address" runDistrib
72-
privip=$(aws ec2 describe-instances --instance-ids $SERVERINSTANCEID --query Reservations[*].Instances[*].PublicIpAddress --output text)
72+
privip=$(aws ec2 describe-instances --instance-ids $SERVERINSTANCEID --query Reservations[*].Instances[*].PrivateIpAddress --output text)
7373
done
7474

7575
log2cw $NJLOGGRP $NJLOGSTREAM "deploy the script to the server $privip and run it" runDistrib

archive/cronjobs/nightlyJob.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ aws s3 cp $DATADIR/activestatlocs.html $WEBSITEBUCKET/search/ --profile ukmonsha
4141

4242
# run this only once as it scoops up all unprocessed data
4343
log2cw $NJLOGGRP $NJLOGSTREAM "start findAllMatches" nightlyJob
44-
matchlog=matches-$(date +%Y%m%d-%H%M%S).log
44+
matchlog=matchJob.log
45+
if [ -f $SRC/logs/$matchlog ] ; then
46+
suff=$(stat matchJob.log -c %X)
47+
mv $SRC/logs/$matchlog $SRC/logs/$matchlog-$suff
48+
fi
4549
${SRC}/analysis/findAllMatches.sh > ${SRC}/logs/${matchlog} 2>&1
4650

4751
log2cw $NJLOGGRP $NJLOGSTREAM "start consolidateOutput" nightlyJob

archive/deploy-analysis.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,27 @@
1414
tags: [dev,prod]
1515
- name: Ensures {{destdir}}/logs exists
1616
file: path={{destdir}}/logs state=directory
17+
- name: clean local filesystem
18+
ansible.builtin.command: 'pyclean {{srcdir}}/archive/ukmon_pylib -v --debris all'
19+
delegate_to: localhost
20+
tags: [dev,prod]
1721
- name: Copy files
1822
copy: src={{ item.src }} dest={{ item.dest }} mode={{ item.mode }}
1923
tags: [dev,prod]
2024
with_items:
2125
- {src: '{{srcdir}}/archive/static_content/', dest: '{{destdir}}/static_content/', mode: '754', backup: no, directory_mode: yes }
22-
- {src: '{{srcdir}}/archive/ukmon_pylib/', dest: '{{destdir}}/ukmon_pylib/', mode: '644', backup: no, directory_mode: yes }
26+
27+
- {src: '{{srcdir}}/archive/ukmon_pylib/analysis/', dest: '{{destdir}}/ukmon_pylib/analysis/', mode: '644', backup: no, directory_mode: yes }
28+
- {src: '{{srcdir}}/archive/ukmon_pylib/converters/', dest: '{{destdir}}/ukmon_pylib/converters/', mode: '644', backup: no, directory_mode: yes }
29+
- {src: '{{srcdir}}/archive/ukmon_pylib/maintenance/', dest: '{{destdir}}/ukmon_pylib/maintenance/', mode: '644', backup: no, directory_mode: yes }
30+
- {src: '{{srcdir}}/archive/ukmon_pylib/metrics/', dest: '{{destdir}}/ukmon_pylib/metrics/', mode: '644', backup: no, directory_mode: yes }
31+
- {src: '{{srcdir}}/archive/ukmon_pylib/reports/', dest: '{{destdir}}/ukmon_pylib/reports/', mode: '644', backup: no, directory_mode: yes }
32+
- {src: '{{srcdir}}/archive/ukmon_pylib/share/', dest: '{{destdir}}/ukmon_pylib/share/', mode: '644', backup: no, directory_mode: yes }
33+
- {src: '{{srcdir}}/archive/ukmon_pylib/tests/', dest: '{{destdir}}/ukmon_pylib/tests/', mode: '644', backup: no, directory_mode: yes }
34+
- {src: '{{srcdir}}/archive/ukmon_pylib/traj/', dest: '{{destdir}}/ukmon_pylib/traj/', mode: '644', backup: no, directory_mode: yes }
35+
- {src: '{{srcdir}}/archive/ukmon_pylib/README.md', dest: '{{destdir}}/ukmon_pylib/', mode: '644', backup: no, directory_mode: no }
36+
- {src: '{{srcdir}}/archive/ukmon_pylib/requirements.txt', dest: '{{destdir}}/ukmon_pylib/', mode: '644', backup: no, directory_mode: no }
37+
2338
- {src: '{{srcdir}}/archive/analysis/', dest: '{{destdir}}/analysis/', mode: '754', backup: no, directory_mode: yes }
2439
- {src: '{{srcdir}}/archive/cronjobs/', dest: '{{destdir}}/cronjobs/', mode: '754', backup: no, directory_mode: yes }
2540
- {src: '{{srcdir}}/archive/utils/', dest: '{{destdir}}/utils/', mode: '754', backup: no, directory_mode: yes }

archive/terraform/mjmm/vpc.tf

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ resource "aws_route_table" "default" {
6565
}
6666
route {
6767
cidr_block = "172.32.0.0/16"
68-
vpc_peering_connection_id = "pcx-04bcbf8428c045637"
68+
vpc_peering_connection_id = "pcx-0beef413172ec795e"
6969
}
7070

7171
tags = {
@@ -82,14 +82,6 @@ resource "aws_internet_gateway" "main_igw" {
8282
}
8383
}
8484

85-
resource "aws_vpc_peering_connection_accepter" "eetommpeering" {
86-
vpc_peering_connection_id = "pcx-04bcbf8428c045637"
87-
tags = {
88-
"Name" = "ee-to-mm-peering"
89-
"billingtag" = "ukmon"
90-
}
91-
}
92-
9385
resource "aws_vpc_peering_connection_accepter" "mdatommpeering" {
9486
vpc_peering_connection_id = "pcx-0beef413172ec795e"
9587
tags = {

archive/terraform/ukmda/secgrp.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ resource "aws_security_group" "ec2_secgrp" {
4646
description = "Security Group for EC2 instances"
4747
vpc_id = aws_vpc.ec2_vpc.id
4848
ingress = [
49-
{
49+
/* {
5050
cidr_blocks = [data.aws_vpc.mjmm_ec2_vpc.cidr_block]
5151
description = "SSH for Admin"
5252
from_port = 22
@@ -56,7 +56,7 @@ resource "aws_security_group" "ec2_secgrp" {
5656
prefix_list_ids = []
5757
security_groups = []
5858
self = false
59-
},
59+
},*/
6060
{
6161
cidr_blocks = [aws_vpc.ec2_vpc.cidr_block]
6262
description = "SSH for Admin"

archive/ukmon_pylib/maintenance/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
Routines used to maintain and keep data organized
44

5-
* dataMaintenance.py - cleardown and space freeing routines
6-
* sortToDateDirs.py - one off tool to convert the WMPL trajectory database to a new layout
7-
* getNextBatchStart.py - update the crontab to start the batch at the right time
5+
* dataMaintenance.py - cleardown and space freeing routines
6+
* sortToDateDirs.py - one off tool to convert the WMPL trajectory database to a new layout
7+
* getNextBatchStart.py - update the crontab to start the batch at the right time
88
* rerunFailedLambdas.py - rerun any failed lambdas
9-
* plotStationsOnMap.py - plot the locations of all stations on a map
10-
* manageTraj - functions to manage the trajectory database
9+
* plotStationsOnMap.py - plot the locations of all stations on a map
10+
* manageTraj.py - functions to manage the trajectory database
11+
* getUserAndKeyInfo.py - functions to audit and manage users and keys
12+
13+
getUserAndKeyInfo is used by a scheduled process to roll keys every 90 days, and to
14+
report on accounts that have been inactive for 90 days.

0 commit comments

Comments
 (0)