CFEngine Community 3.5.3 and file templates

28 views
Skip to first unread message

Jeremy Finn

unread,
Nov 17, 2014, 5:22:15 PM11/17/14
to help-c...@googlegroups.com
First, let me just say that I attended the CFEngine coffee hour last Thursday, and thank you. The conversation was interesting, engaging, and the feedback I received was very helpful.

Now, I'm attempting to use CFEngine to maintain a configuration file for a monitoring software called Nimsoft, and I'm running into some hurdles that perhaps someone can shed some light on.

I need to feed a list of file system devices and mount points into a configuration file. To do this, I'm using a template. I posted a gist of the policy here:


And the template here:


I'm using an associative array to contain the file system devices and mount points. I know that much is working because the report output when the policy runs is as follows:

$ pfexec /var/cfengine/bin/cf-agent -IKf ./nimsoft_cdm.cf
2014-11-17T15:41:21-0500   notice: R: rpool/ROOT/2014Q4A /
2014-11-17T15:41:21-0500   notice: R: rpool/ROOT/2014Q4A/var /var
2014-11-17T15:41:21-0500   notice: R: rpool/export /export
2014-11-17T15:41:21-0500   notice: R: rpool/git_repo /export/git_repo
2014-11-17T15:41:21-0500   notice: R: rpool/export/home /export/home
2014-11-17T15:41:21-0500   notice: R: rpool /rpool
$

But when I check the file that the policy creates, I get the name of the array instead of the data that it should contain.

### BEGIN sample ########################################
<disk>
   interval = 15 min
   samples = 4
   use_systemspace = no
   ignore_filesystem =
   ignore_device =
      <fixed>
         </>
            active = yes
            description = File system /
            disk = $(nimsoft_cdm.fs_tbl[$(mnt_lst)])
            percent = yes
            qos_disk_usage = no
            qos_disk_usage_perc = no
            inode_percent = yes
            qos_inode_usage = no
            qos_inode_usage_perc = no
            delta_percent = no
            delta_calculate_all = yes
            delta_type = both
            qos_disk_delta = no
            <error>
               active = yes # / disk error active
               threshold = 5 # / error threshold
               message = DiskError
            </error>
            <warning>
               active = yes # / disk warning active
               threshold = 10 # / warning threshold
               message = DiskWarning
            </warning>
            <inode_error>
               active = no # / inode_error active
               threshold = 10 # / inode_error threshold
               message = InodeError
            </inode_error>
            <inode_warning>
               active = no # / inode_warning active
               threshold = 20 # / inode_warning threshold
               message = InodeWarning
            </inode_warning>
            <missing>
               active = yes # / disk missing active
               message = DiskMissing
            </missing>
            <delta_error>
               active = no # / delta_error active
               threshold = 10 # / delta_error threshold
               message = DeltaError
            </delta_error>
            <delta_warning>
               active = no # / delta_warning active
               threshold = 8 # / delta_warning threshold
               message = DeltaWarning
            </delta_warning>
         <//>

### END sample ##########################################

Are templates in 3.5.3 able to support associative arrays? If not, is there another way to accomplish what I am trying to do? Or will I need to get my upgrade to 3.6 out of the way first, and check out some of the expanded data features it offers?

Thanks again for any insights you can share.

Regards,
Jeremy

bishwa SHRESTHA

unread,
Nov 18, 2014, 4:45:55 AM11/18/14
to Jeremy Finn, Help cfengine
Hi,

Please try with:

disk = $(nimsoft_cdm.fs_tbl[$(nimsoft_cdm.mnt_lst)])

mnt_lst(not a global variable) is unrecognisable unless we tell cfengine about its bundle context.

Regards,
Bishwa

--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengin...@googlegroups.com.
To post to this group, send email to help-c...@googlegroups.com.
Visit this group at http://groups.google.com/group/help-cfengine.
For more options, visit https://groups.google.com/d/optout.

Jeremy Finn

unread,
Nov 18, 2014, 5:43:21 PM11/18/14
to bishwa SHRESTHA, Help cfengine
Bishwa,
 
Thank you very much - this was indeed my problem all along. I have tested and verified this is working as expected.
 
Thanks again,
Jeremy
Reply all
Reply to author
Forward
0 new messages