Search code examples
openshiftopenshift-client-tools

How to download logs from child gears


I have OpenShift Enterprise 2.0 running in a multi-node setup. I am running a simple JBoss scaled app (3 gears, so HAProxy and 2 JBoss gears). I have used a pre_start_jbossews script in .openshift/action_hooks to configure verbose GC logging (with just gc.log as the file name). However, I can't figure out how to get the gc.log files from the gears running JBoss.

[Interestingly enough, there is an empty gc.log file in the head/parent gear (running HAProxy). Looks like there is a java process started there, that might be a bug.]

I tried to run

rhc scp <appname> download . jbossews/gc.log --gears

hoping that it would be implemented like the ssh --gears option, but it just tells me 'invalid option'. So my question is, how can I actually download logs from child gears?


Solution

  • I don't think that you can use RHC directly to get what you want.

    However you can use the following to find all of your GEARS:

    rhc app show APP_NAME --gears | awk '{print $5}' | tail -n +3
    

    From this list you can list all the logs for each gear that are part of that application.

    for url in $(rhc app show APP_NAME --gears | awk '{print $5}' | tail -n +3); do for dir in $(ssh $url "ls -R | grep -i log.*:"); do echo -n $url:${dir%?}; echo; done; done 
    

    With that you can us simple scp commands to get the files you need from all of the gears:

    for file_dir in $(for url in $(rhc app show APP_NAME --gears | awk '{print $5}' | tail -n +3); do for dir in $(ssh $url "ls -R | grep -i log.*:"); do echo -n $url:${dir%?}; echo; done; done); do scp "$file_dir/*" .; done