Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Instead of a hash of hashes you might try an array of hashes, which will be ordered:

$ncpa_passive_checks = [  
   {
     "title" => "check root partition",
     "test_name" => "disk usage",
     "args"      => "--warning 20% --critical 10% -p /",
     "ncpa_branch" => "/disk/logical/|boot/used_percent",
   },
   {
      "title" => "swap usage",
      "test_name" => "swap usage",
      "args"      => "--warning 40 --critical 80",
      "ncpa_branch" => "/memory/swap/percent", 
   },
   {
      "title" => "cpu util",
      "test_name" => "cpu usage",
      "args"      => "--warning 85 --critical 90",
      "ncpa_branch" => "/cpu/percent",
   },
   {
       "title" => "memory usage",
       "test_name" => "memory usage",
       "args"     => "--warning 80 --critical 90",
       "ncpa_branch" => "/memory/virtual/percent",
   }
]

Then the template is very similar, just take out the key parameter

<% @ncpa_passive_checks.each do | hash | -%>
    %HOSTNAME%|<%= hash['test_name'] %> = <%= hash['ncpa_branch']%> <%= hash['args']
<%- end %>