Look in the Utilty namespace.
Found the command:
Curious how to determine the runID.. or how I could pass the runID as a parameter in a NSH script job.
Blcli_execute NSHScriptJob getDBKeyByGroupAndName
Blcli_execute JobRun findLastRunKeyByJobKey $jobKey
blclI_execute JobRun jobRunKeyToJobRunId $runKey
blcli_execute Utility exportNSHScriptRun $runId “/some/path/out.csv”
Did something a bit different
$job_key=`blcli SnapshotJob getDBKeyByGroupAndName "$group_name" "$job_name"`
$run_id=`blcli JobRun findLastRunKeyByJobKey $job_key`
Utility simpleExportSnapshotRun $group_name $job_name $run_id $out_file $col
--Didn't completely work, will update when I get it working.
Use the blcli performance commands, don’t to variable=`command`
Not sure what the blcli performance commands are...
I'm stuck with this error
Unknown command : name space = 'Utility', command = 'simpleExportSnapshotRun'.com.bladelogic.cli.factory.CommandNotFoundException: Found command 'Utility.simpleExportSnapshotRun' but with mismatching arguments.
This is the command I'm running
blcli Utility simpleExportSnapshotRun "$GROUP_NAME" "$JOB_NAME" $RUN_ID "$OUT_FILE"
Not sure where to go from here, I might sleep on it.
Look in the blcli docs in the 'nsh performance commands' section. when you run a lot of blcli calls, your script will run slowly because for each blcli call you are opening a jvm.
the simpleExportSnapshotRun wants an additional parameter - 'additionalColumns' - i would make this "" so:
blcli Utility simpleExportSnapshotRun "$GROUP_NAME" "$JOB_NAME" $RUN_ID "$OUT_FILE" ""
I initially had the additionalColumns var, it was producing the same error, tried it with the "" same error. I'm wondering if it's the runID.
The command blcli jobrun findlastrunkeybyjobkey $job_key true will return something like this
I am using sed to strip DBKey:SJobRunModelKeyImpl: from the var, leaving me with just the numbers per the example in the blcli help. I'm wondering if I should also trim from the "-" to the end of the string. I'm going to try harcoding a Run ID. [EDIT] I hardcoded the runID and the command succeeded, working on trimming the var.
Will look into the blcli performance stuff, though I really don't care how long it takes to run.
Now I'm getting a funky error and have no idea which way to turn.
Info Oct 14, 2011 12:11:34 PM Command execution failed. Found more than one snapshot for job key: DBKey:SJobModelKeyImpl:2002482-2-2143103 and job run id : 2010503/tmp/skcte/skcte_.csv exported!
So I've tried the blcli performance commands method you suggested, still running into an error, here is the code followed by the error being reported
GROUP_NAME="/BL_Infrastructure/Root SSH Audit"
JOB_NAME="Snapshot all the ssh keys"
blcli_execute SnapshotJob getDBKeyByGroupAndName "$GROUP_NAME" "$JOB_NAME"
blcli_execute JobRun findLastRunKeyByJobKey $jobKey
blcli_execute JobRun jobRunKeyToJobRunId $runKey
blcli_execute Utility exportSnapshot "GROUP_NAME" "$JOB_NAME" $runId "/tmp/skcte/skcte_12.csv" "CSV"
Error Oct 14, 2011 5:22:30 PM Command execution failed. com.bladelogic.mfw.util.BlException: Found more than one snapshot for job key: DBKey:SJobModelKeyImpl:2002482-2-2143103 and job run id : 2011157
You need to get the specific snapshot from the jobRun. Look in the snapshot namespace for the right method (maybe something like, getSnapshotByJobIdAndByServerName) just a guess
you could also try Utility exportSnapshotRun - you can specify the server name in that one.
I'm looking to grab the data from an entire snapshot job, so reporting should be based around the component I've snapshotted over all of the server targets. For instance I am checking for checksum changes on the authorized_keys2 file, I've setup components which apply to all Unix boxes. My snapshot target is a group: Unix Servers. With your proposed method will I have to step through each server in the group?
Use something like Server listServersInGroup to get the server names and then iterate through them.