Easy Solution for this if you manage move Result Column to first column in csv by awk or anything.
on Nsh execute command
cat /c/temp/ash.csv | cut -d"," -f1,3 | grep Fail
Will give Result in format :
This is easy way to find Fail Targets.
Thank you for your respond and proposal solution!
This is regarding compliance job, so I can run it against one target and by using "Utility simpleExportComplianceRunLatest" this will create CSV file let's say: "TEMP.csv"
then I can do
nCOUNTER=`cat "TEMP.csv" | grep Fail | wc -l`
if [ $nCOUNTER -eq 0 ]
echo "SERVER is OFF compliance"
echo "SERVER is IN compliance"
What I don't like with this approach:
This will be batch job that will run daily and by using this tool: "Utility simpleExportComplianceRunLatest", I have to somewhere store the result in our case that is the CSV file. My question is what would be that place please, obviously it can not be the local directory from where I am running the script.
It seems this tool can only write the file locally. It can't handle a windows share as:
simpleExportComplianceRunLatest is not accepting share directory PATH currently.
But to access data from remotely I will give you a workaround.
Create Shortcut of local.csv to \\servername\C$\Dir\shortcut.lnk and in BLCLI give path of local.csv
blcli -v "defaultProfile" Utility simpleExportComplianceRunLatest "/sampleTemplateGroup" "sampleTemplate" "/sampleRuleGroup/sampleRule" "/sampleJobGroup" "sampleJob" "C:/temp/local.csv"
So with the shortcut you can access .csv file also if multiple files create shortcut to directory One time effort.
Also, For Linux you can use ln to create links.
Again thank you for your ideas and helpful replies.
The nsh script that we are building to get the result of the compliance job will ve part of a BL batch job that will be scheduled in BL. The whole thing will be living in BL. It seems that the above approach will not work with this context. Perhaps I may use the local BL store to write the result file, then pharse it and remove it the reault file from the store. Or even to move the result file from the BL store to the server I want if I have to retain it. I think that I am all set for now. Will experiment on soon and perhaps all will be successful.
Do you know what run of the batch job you will want the result for? you can use some commands to get the run of the batch job, and then find the child job run ids, and from that pull the compliance results.
Thank you for jumping in this thread!
I am really glad to hear that there is another possible way.
How things are combined on my end.
There will be a single BL batch job lets call it: "BL_batch_TEST", that BL batch should contains: "BL_compliance_JOB" and "BL_NSH_script_server_property_changer.nsh"
Bill, based on your e-mail, could you tell me what are my options to get the status of "BL_compliance_JOB".
I know that I may repeat myself, but let me clarify something about: "BL_compliance_JOB".
Let's say that "BL_compliance_JOB" has 10 rules and one of them is failing, then the status I am looking of the compliance job should be as whole and should be let's say: "FALSE" or "1" if the job has all the rules without FAIL, then I am expecting to get "TRUE" or "0".
We don't see how the above aproaches will help, if that compliance job has to be run against multiple targets at the same time. The aproaches above limit us, to run the compliance job at one target at a time.
Let's say we have a BL smart group with 100 servers. The compliance job will be run againts that smart group and the above aproaches are not acceptable in that scenario.
Because we don't want to run the compliance job twice at the same target we are updating specific BL property and based on that property the server will be off the smart group and becuase of that we have addtitional NSH script which is part of the BL batch job to take care of the BL property based on the compliance result.
let me understand the use case a little more - you want to set the property on the servers, and that will exclude them from successive runs of the compliance job (via the batch) ?
what happens if the server goes out of compliance for some reason? how will you catch that ? or does this compliance job only need to run once against the server? what is the issue w/ running the job against a compliant server?
i'll work out the blcli in a bit, i just got back from pto so i'm still catching up
Thank you for handling this!
1. There will be smart groups, which will be filled based on BL server properties. One of the BL server property will be let's say STATUS with possible VALUES 1,2,3 for example.
2. We will have "Smart Group - 1" that will contain servers with STATUS=1, "Smart Group - 2" with STATUS=2 and "Smart Group - 3" with STATUS=3
3. We going to run the BL BATCH JOB against "Smart Group - 1".
4. BL BATCH JOB will contains: BL COMPLIANCE JOB and NSH SCRIPT (the script will update STATUS=2 if BL COMPLIANCE JOB is OFF compliance and STATUS=3 if BL COMPLIANCE JOB is in compliance)
5. The smart group is expected to have 100 of servers.
The question is, how to know the status of the BL COMPLIANCE JOB regarding TARGET SERVER (what I mean here is not the status of the BL COMPLIANCE JOB whether it's completed with success or not) if one of the rules is failing then UPDATE the BL SERVER PROPERTY of the TARGET server with STATUS=3 and if all rules are passing UPDATE the BL SERVER PROPERTY of the TARGET server with STATUS=2.
On your question if the server is IN compliance the job will send notification to the apropriate parties and will place that problem server to different smart group: "Smart Group - 3", that way it will be excluded from the original smart group where the BL JOB will hit it otherwise more than once, there is no problem that server to be hit more than once, but it always will fails and obviously something needs to be fixed from our side. Also if the server is OFF compliance it goes to smart group "Smart Group - 2". Where will be running the same job but with schedule let's say every 3 months.
Against "Smart Group - 1" - above BL batch job schedule will be daily or perhaps multiple times a day. (if something is in compliance goes to "Smart Group - 3")
Against "Smart Group - 2" - above BL batch job schedule will be perhaps every 3 months. (if something is in compliance goes to "Smart Group - 3")
"Smart Group - 3" - against it will never run above BL batch job. It's going to be something as visualization fillter of what are the problem servers.
Please let me know if you need more details.
So in the NSH job, you need to figure out what batch job and batch job run it's a part of, from here we need to derive the compliance job run key. from there i think the best idea would be to use the exportComplianceRun command as ashitosh mentioned, grep that for failed servers and then set the properties based on that output.
when i get some time (you can see i have lots) i'll try to work out the 1st bit. i already have some ideas on that.
Actually I have a very similar need. Out of a compliance/remediation job set a server property. Unfortunately this is not something that is provided out of the box (correct me if I am wrong) so I'm very much interested in the scripts you're creating. I wonder if this type of functionality is a good candidate for an enhancement request.
carlos, for your case you should be able to run some blcli commands to get the information you need from the compliance job and then run the blcli command to set the server property.
can you elaborate on what criteria you want to pull from the compliance job to set the property?
also, what's the use case for this ? why do you want to do this ?
We have a quite complex environment. We have different network area's and depending in which area a server is located we need to set different DNS server, TSM backup server, etc. We use server properties to define all these parameters. Now this works fine for newly provisioned servers since we can correctly configure this from the start and normallly these values don't change during the lifecycle of a server. Beside newly provisioned servers we also have the existing estate which was present before we started with Bladelogic. At import time we were able to set some server properties but not all of them and we we're also not sure that they are all correct.
So we want to extract all these settings. Some are easy like DNS, others like a TSM backup instance are a little bit harder. Based on the network id we're able to determine if these settings are compliant or not.
After we have determined if a server is compliant or not we want to correct the server property accordingly. The main reason why we want to use a property is because it's easier to create smartgroups.
so, if after running your compliance job against the target it's compliant you want to set a property like "IS_COMPLIANT" to 'true' ?
is there only a single property you will use to track compliance for all these settings, and are you checking these settings in a single compliance job ?