Friday, October 22, 2010

report and howto do in higher level language

1.
task: produce report of 100 apps running 1700 instances in production, showing app, box, and load avg, then have it run every so often for few days to see which boxes are overloaded and rearrange the apps on the boxes to make sure nothing is overloaded
2.
example:
3.
/home/projects/project1/locations/prod_boston/boxlist
4.

5.
now the boxlist is a perl file like this:
6.
blah
7.
blah blah
8.
boxes = {
9.
box1.mysite.bos
10.
box2.mysite.bos
11.
}
12.

13.
In bash I did a find that piped to a while loop reading each boxlist file, then a second while loop reading the boxlist file, grepping out unwanted lines, and ssh-ing to each box and grep-ping/cut-ting/sort-inguniq-ing the ssh "$box" "uptime" command, yet setting the project name from the first loop to end up with an echo of app, box, load on one line, all funneled into 1 "report" file.
14.
I then wrote a little awk+sort to sort the load avg by largest manually as sort of a query you could run on the reportfile.
15.
I then did crontab -e and made a cron to run it each 3 hours, and added something to name the reportfile with a date on the end using date+awk.
16.
WHEW
17.

18.
how would someone do such in a high level language?

No comments: