04 March 2013

Using Rsync to Pull and Monitor remote logs

I have been building a whole Load Test and Monitoring framework within Jenkins.  With that in mind, one of the servers I hit during load, is a Call Control server.  I wanted to collect the logs that were built during the load tests and I came up with this process. I'm sure there are other ideas out there, but this worked nicely for me:

I wrote a script that reads like this:

#!/usr/bin/expect

sapwn rsync -v -e ssh user@myremotebox:/tmp/ccv5/log/callcontrol.log /Users/Jenkins/.jenkins/userContent

expect "*?assword:*"

send -- "mypassword"
send -- "\r"
expect eof

What this script does is it uses rsync to synchronize a file between machines.  In this example above, it would sync the callcontrol.log on a remote box called myremotebox as user user, and update the same log in my local directory of /Users/Jenkins/.jenkins/userContent. 

Because I need to sudo to get access, I want to automatically pass the password prompting.  To get around that I'm using expect. Expect will expect a prompt and respond with some sort of defined response.  Like a password.  It could also be a password key.... but in this simple example i'm just passing a password.

Now, with Jenkins, I do the following:
I set up a build project to run the Load Test, with a downstream project that just executes the shell script above. 

I also used a sidebar add on for Jenkins and hard coded a link to /Users/Jenkins/.jenkins/userContent/callcontrol.log

Therefor, after each run of load, the link to callcontrol.log is updated with fresh content.

No comments:

Post a Comment