7 Replies Latest reply on Sep 21, 2012 4:14 PM by Bill Robinson

    Automated .CSV Export for All Servers

      Greetings all,

       

      I've been searching around but couldn't seem to find exactly what I was looking for, so I thought I would ask you fine folks.  I would like to automate the daily generation of .CSV files for each system we are using BL for FIM (File Integrity Monitoring).  We have another process that uses the .csv files and manually generating them is cumberson.

       

      I imagine that it might be done with blcli which would be preferred if I could script something.  Any help and insight is really appreciate.


      While I am on the topic, we have a backup process that updates the timestamp on files which is wreaking havoc on the number of changes that BL is seeing.  Out of say 200 reported changes, only a handfull have MD5 changes, etc.  How do people typically deal with timestamp false positives?  Thanks!

       

      -Steve

        • 1. Re: Automated .CSV Export for All Servers
          Bill Robinson

          csv export of what?  a list of servers?  the deltas from the snapshot jobs ?

          • 2. Re: Automated .CSV Export for All Servers

            The delta's by machine.  Basically they are going in and manually getting these csv's and then parsing them with a third party program to get rid of a lot of the noise.  Manually doing that export is something I'd like to do away with. 

            • 3. Re: Automated .CSV Export for All Servers
              Bill Robinson

              you need to do something like:

              find the job(s)

              find the job run you want

              find the target list of servers

              for each server, run the Utility exportSnapshotRun command and create the file.

               

              how many jobs is this, and you always want the latest run exported ?

               

              have you considered using the email notifications instead ?  can the thing that's parsing this consume email ?

               

              i can give you some blcli that will get you started...

              • 4. Re: Automated .CSV Export for All Servers

                Any examples are GREATLY appreciated Bill. 

                • 5. Re: Automated .CSV Export for All Servers
                  Bill Robinson

                  wow, sorry for the delay.  fill in the right job name.  this assumes the last run of the job, you'd have to figure out how to pick a particular job run if you don't want the latest.

                   

                   

                  #!/bin/nsh

                  blcli_setoption serviceProfileName defaultProfile
                  blcli_setoption roleName BLAdmins
                  blcli_connect

                  jobGroup="/Workspace/Recommended Scheduled Jobs"
                  jobName="Inventory - Linux"
                  date=`date +'%Y%m%d-%H%M%S'`
                  blcli_execute SnapshotJob getDBKeyByGroupAndName "${jobGroup}" "${jobName}"
                  blcli_storeenv jobKey
                  blcli_execute JobRun findLastRunKeyByJobKey ${jobKey}
                  blcli_storeenv jobRunKey
                  blcli_execute JobRun jobRunKeyToJobRunId ${jobRunKey}
                  blcli_storeenv jobRunId
                  blcli_execute JobRun getTargetsForJobRunId ${jobRunId}
                  blcli_execute Utility mapPrint
                  blcli_storeenv targetMap
                  echo "${targetMap}" > $$.out


                  componentKeys=`grep "^COMPONENT" $$.out | cut -f2 -d= | sed "s/\[//g;s/\]//g" | sed "s/,//g"`
                  for componentKey in ${componentKeys}
                          do
                          componentKey=`echo ${componentKey} | sed "s/\(.*\):.*/\1/g"`
                          blcli_execute Component findByDBKey ${componentKey}
                          blcli_execute Component getDeviceId
                          blcli_storeenv serverId
                          blcli_execute Server findById ${serverId}
                          blcli_execute Server getName
                          blcli_storeenv serverName
                          cmpServers=(${serverName} ${cmpServers[@]})
                  done

                  serverKeys=`grep "^SERVER" $$.out | cut -f2 -d= | sed "s/\[//g;s/\]//g" | sed "s/,//g"`
                  for serverKey in ${serverKeys}
                          do
                          serverKey=`echo ${serverKey} | sed "s/\(.*\):.*/\1/g"`
                          blcli_execute Server findById ${serverKey}
                          blcli_execute Server getName
                          blcli_storeenv serverName
                          srvServers=(${serverName} ${srvServers[@]})
                  done

                  serverList=(${cmpServers[@]} ${srvServers[@]})
                  for server in ${serverList}
                  do
                  blcli_execute Utility exportSnapshotRun "${jobGroup}" "${jobName}" ${jobRunId} "" "" ${serverName} "/tmp/${server}-${jobName}-${date}.csv" CSV
                  done
                  rm -f $$.out

                  1 of 1 people found this helpful
                  • 6. Re: Automated .CSV Export for All Servers

                    Hi Bill,

                     

                    The above script gives me error when I run it for the snapshot of multiple server, It works fine only for the snapshot of single server.

                    error :

                    Command execution failed. com.bladelogic.cli.factory.CommandNotFoundException: Found command 'Componen

                    t.findByDBKey' but with mismatching arguments.

                    Command execution failed. java.lang.IllegalArgumentException: object is not an instance of declaring c

                    lass

                    Cannot store a failed command result

                    Command execution failed. com.bladelogic.cli.factory.CommandNotFoundException: Found command 'Server.f

                    indById' but with mismatching arguments.

                    Command execution failed. java.lang.IllegalArgumentException: object is not an instance of declaring c

                    lass

                    Cannot store a failed command result

                    Command execution failed. com.bladelogic.cli.factory.CommandNotFoundException: Found command 'Componen

                    t.findByDBKey' but with mismatching arguments.

                    Command execution failed. java.lang.IllegalArgumentException: object is not an instance of declaring c

                    lass

                    Cannot store a failed command result

                    Command execution failed. com.bladelogic.cli.factory.CommandNotFoundException: Found command 'Server.f

                    indById' but with mismatching arguments.

                    Command execution failed. java.lang.IllegalArgumentException: object is not an instance of declaring c

                    • 7. Re: Automated .CSV Export for All Servers
                      Bill Robinson

                      i just cut and pasted the text of my script into my 8.2 sp2 env and ran it, and it worked fine.

                       

                      can you run:

                       

                      nsh -x <script> > script.out 2>&1

                       

                      and attach the script.out ?