7 Replies Latest reply on Nov 11, 2014 8:55 AM by James Donohue

    using Calculations in Compliance Rules

    James Donohue


      Hello,

       

      Is there a way to create a Compliance Rule that compares Available space on a drive to the total capacity of the Drive and if its less than 10% of the total capacity, then the test should fails. The actual question is, can I take a PART and create a calculation out of it? 

       

      i.e. Here's what I tried to do and obviously it fails:

      "Hardware Information.Physical Storage Device:/Hardware/StorageDevices/PhysicalStorageDevices/\\.\PHYSICALDRIVE0"."Available Space (in KB)  (Windows)" >= "Hardware Information.Physical Storage Device:/Hardware/StorageDevices/PhysicalStorageDevices/\\.\PHYSICALDRIVE0"."Capacity (in KB)" *.1

       

      I'm trying to avoid adding another Extended Object in my environment.

        • 1. Re: using Calculations in Compliance Rules
          Yanick Girouard

          There's no arithmetic operators available for compliance rule evaluations as far know, but this would make a great suggestion to post in the ideas section. Basically, to be able to apply transformations on the values, maybe using XPATH or another form of standard transformation language?

          • 2. Re: using Calculations in Compliance Rules
            Monoj Padhy

            In current scenario blade does not have some feature for arithmetic operation in compliance rule. You may have to use EXO approach only.

            • 3. Re: using Calculations in Compliance Rules
              Joe Piotrowski

              It's a shame, if you live browse a server and select File System, there is a Capacity property that displays the used drive value in %. But (to my knowledge) you can't bring in the File System as a part in a Component Template. So I don't know how or where else to capture this in BSA natively. The other Capacity properties and values in the Hardware Information section look like total size of drive values.

              • 4. Re: using Calculations in Compliance Rules
                Monoj Padhy

                Really I dont find away to do this. If we select system info (windows) then we have something like this. then one need to use these and do some arithemtic operation until BSA has somehting inbuilt to capture thsose in % format.(May be in upcoming versions) I think we can have an idea created for this. Does that make sense ?

                • 5. Re: using Calculations in Compliance Rules
                  Joe Piotrowski

                  Correct. To my knowledge System Info sections are not available as Parts in CTs, so you can't use them as Rules. More than likely an EXO script would have to be created to output the % disk space remaining on a drive.

                  • 6. Re: using Calculations in Compliance Rules
                    Mike Reider

                    you can do something like this, create an Ext Obj w the following script, place it into your storage/ext object folder

                     

                    (you will need to change the script around to fit your target OS, this example is for Win targets, C: space)

                     

                    #!/bin/nsh

                    # 2014 Column Technologies

                    # script:  freespace_C.nsh

                    #

                    # Description: check free space on C drive as % of Total

                    #######################################################################

                    # Init variables

                    TARGET=$1

                     

                    FREE=`nexec -nohup $TARGET cmd /c 'fsutil volume diskfree C:' | grep "Total # of avail free bytes" | sed 's/[^0-9]*//g'`

                    echo "C: Freespace," $FREE

                     

                    TOTAL=`nexec -nohup $TARGET cmd /c 'fsutil volume diskfree C:' | grep "Total # of bytes" | sed 's/[^0-9]*//g'`

                    echo "C: Total Space," $TOTAL

                     

                    P=$(echo "$FREE / $TOTAL" | bc -l)

                     

                    # multiply by 100 to get % from decimal

                    P2=$(echo "$P * 100" | bc -l)

                     

                    # only 2 decimal places

                    PERCENT=`printf "%0.2f\n" $P2`

                    echo "% Free Space of Total," $PERCENT

                     

                    exit 0

                    #######################################################################

                     

                    add a new Ext Obj

                     

                    ext1.gif

                     

                    your result will look somethin like this

                     

                    ext2.gif

                     

                    now add your compliance rule to check Value 1 of % Free Space of Total and do your pass/fail according to that.

                    • 7. Re: using Calculations in Compliance Rules
                      James Donohue

                      Thanks Mike. Thats what I am doing and wanted to try get away from using too many EO's. I already have a PowerShell script that returns results very similar to what you have and it works but as mentioned, I think it would be more efficient using the inherent BSA data and leverage it natively. But, its apparent that it cannot be done so I'm keeping the EO's. Thanks.