3 Replies Latest reply on Nov 30, 2010 3:50 PM by Jesper Rellme

    Compliance of /etc/fstab with NFS mounts

    Steven Alexson

      OM VERSION: 8.0 SP5

      It doesn't seem possible to write compliance rule that verifies mount points in /etc/fstab. When I view /etc/fstab in a live server browse, I see the

      following format:


      Name = storage device path (i.e. /dev/sda or hostname:/some/path)

      Value 1 = local mount point (i.e. /opt/bladelogic/storage)

      Value 2 = filesystem type (i.e. nfs)

      Value 3 = mount options

      Value 4 = dump frequency

      Value 5 = pass num


      This is what I would expect to see for the /etc/fstab file.


      When I tried to create a compliance rule, I am unable to check the storage device path. The fstab.gm grammar file saves each entry record identified by the local mount point, so even though it displays properly in a live browse, the value of the storage device path is lost. The local mount point assumes the value of "Name" and "Value 1", and the "Path" value in a compliance rule is the configuration object path (i.e. /etc/fstab//\/opt\/bladelogic\/storage). All of the other values correspond to their column in /etc/fstab. The only value missing is the storage device path.


      When I add one of the config file lines to a BLPackage, the storage device path is stored as "Value 0". This is not a value that can be referenced in a compliance rule.



      the fstab.gm grammar file provided by BMC looks like:


      --- BEGIN fstab.gm ---

      # JBoland, 4/21/03 - Written to parse the /etc/fstab file on HPUX and Linux
      # Sekhar, 12/9/05 - The format is as follows
      #     fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno
      # Using fs_file (mount point) as the key


      TAB \t




      COMMENT #.*
      VAL [^\t\n ]*
      WS [\n\t ]*




      comment COMMENT $save_as_comment $0


             $new_field $0 $new_field $2 $new_field $4 \
             $new_field $6 $new_field $8 $new_field $10 \
             $save_record $2




      add $write_record $TAB

      --- END fstab.gm ---



      The problem is the line "$save_record $2" in the record. This is what is causing the local mount point to be the reference name in the compliance template. I can obviously change the file to read "$save_record $0" and fix my problem, but what would that do to snapshots and BSARA ETLs? I can't imagine that the change WOULD NOT break those functions.


      This obviously isn't limited to NFS devices, as local devices (i.e. /dev/sda) would be defined in the first column of /etc/fstab.


      Has anyone else run into this problem? Has anyone figured out how to write a compliance rule for /etc/fstab to verify a local mount point and its storage device?

        • 1. Re: Compliance of /etc/fstab with NFS mounts

          Hi Steven,


          Just a suggestion as I haven't tried this.


          Couldn't you just copy the fstab.gm file to something like <COMPANY_NAME>_fstab.gm.

          Then change to "$save_record $0" and tell your compliance rule to use the new grammar file, thereby removing any potential impact to anything already using fstab.gm?





          1 of 1 people found this helpful
          • 2. Re: Compliance of /etc/fstab with NFS mounts
            Steven Alexson

            So, there is a problem with that approach (I had considered it). You cannot define a local configuration object with the same name as one that exists in the global configuration object dictionary. To get the compliance rule to use the changed grammar file, I would have to define /etc/fstab as a local config file for the component template. Attempting to do that generates a console error that the config object already exists (as it exists in the global dictionary).


            This is a pain that I have had to face in the past, and am getting ready to submit an enhancement request to change that.

            • 3. Re: Compliance of /etc/fstab with NFS mounts

              Hi Steven,

              Probably not exactly what you are asking for but during a POC I wrote a script to check that the fstab contained valid mount points. I ended up not using the fstab config file since I couldn't find good way of doing it. This is what I did instead and I'm not a script guru so there is probably other ways (better) you can do this but it worked for me. If I found an invalid mount point it would flag it in the compliance rule and print the invalid entry. You can probably modify the script to fit your specific use-case.


              This is what I did:

              1. Created a NSH script - This is what you need to modify to get the expected behavior because I know it's not bullet proof.


              while read inputline
                first="$(echo $inputline | cut -d' ' -f1)"
                # Only look for non-comment lines
                if [ $first != "#" ]; then
                  mount="$(echo $inputline | cut -d' ' -f2)"
                  filesystem="$(echo $inputline | cut -d' ' -f3)"
                  # Only check if file system is either auto, ext3, devpts, tmpfs, proc,sysfs or vmhgfs
                  if [ $filesystem = "ext3" ] || [ $filesystem = "auto" ] ||
                     [ $filesystem = "devpts" ] || [ $filesystem = "tmpfs" ] ||
                     [ $filesystem = "proc" ] || [ $filesystem = "sysfs" ] ||
                     [ $filesystem = "vmhgfs" ]; then
                    # Check if mount point directory exist
                    if [ -d "//$TARGET$mount" ]; then
                        echo "false"
                        echo "//$TARGET$mount"
                        exit 0
              done < //$TARGET/etc/fstab

              echo "true"
              exit 0


              2. Created an extended object which executed the script against a target server

              ScreenHunter_01 Nov. 30 22.39.gif

              3. Created a compliance rule using the output of the script

              ScreenHunter_02 Nov. 30 22.46.gif


              Hope this is something you can work with.



              1 of 1 people found this helpful