<commit_before># install lsof for some port and fd monitors to get as nagios user
package "lsof"

case node.platform
when "redhat","centos","fedora"
  execute "chmod +s /usr/sbin/lsof"
when "suse","ubuntu"
  execute "chmod +s /usr/bin/lsof"
end

nagios_service = "nagios"
case node.platform
when "redhat","centos","fedora","suse"
  package "nagios"    
  package "nagios-plugins"
  
  unless node.platform == "suse"
    package "nagios-devel"  
    package "nagios-plugins-load"
    package "nagios-plugins-http"
  end
  
  execute "cp /usr/lib64/nagios/plugins/check_load /opt/nagios/libexec/" do
    not_if "test -f /opt/nagios/libexec/check_load"
    only_if "test -d /usr/lib64/nagios/plugins"
  end
  execute "cp /usr/lib/nagios/plugins/check_load /opt/nagios/libexec/" do
    not_if "test -f /opt/nagios/libexec/check_load"
    only_if "test -d /usr/lib/nagios/plugins"
  end
  execute "cp /usr/lib64/nagios/plugins/check_http /opt/nagios/libexec/" do
    not_if "test -f /opt/nagios/libexec/check_http"
    only_if "test -d /usr/lib64/nagios/plugins"
  end
  execute "cp /usr/lib/nagios/plugins/check_http /opt/nagios/libexec/" do
    not_if "test -f /opt/nagios/libexec/check_http"
    only_if "test -d /usr/lib/nagios/plugins"
  end
  
  # in case conf.d doesn't exist
  directory "/etc/nagios/conf.d"
  
  # remove default stuff added by redhat
  execute "rm -f internet.cfg" do
   cwd "/etc/nagios3/conf.d/"
   returns [0,1]
  end
else
  nagios_service = "nagios3"
  package "nagios3-core"

  # ubuntu 12.04 + nagios 3.2.3 has issue with not setting p1_file, but ok with it empty
  execute "mkdir -p /usr/lib/nagios3 ; touch /usr/lib/nagios3/p1.pl"
  execute "rm -f /etc/nagios-plugins/config/ping.cfg" do<commit_msg>perform check before nagios yum install<commit_after># install lsof for some port and fd monitors to get as nagios user
package "lsof" do
  not_if { ::File.exists?("/usr/sbin/lsof") }
end

case node.platform
when "redhat","centos","fedora"
  execute "chmod +s /usr/sbin/lsof"
when "suse","ubuntu"
  execute "chmod +s /usr/bin/lsof"
end

nagios_service = "nagios"
case node.platform
when "redhat","centos","fedora","suse"
  package "nagios" do
    not_if "rpm -qa | egrep -qe 'nagios-[0-9]+'"
  end    
  package "nagios-plugins" do
    not_if "rpm -qa | egrep -qe 'nagios-plugins-[0-9]+'"
  end
  
  unless node.platform == "suse"
    package "nagios-devel" do
      not_if "rpm -qa | egrep -qe 'nagios-devel-[0-9]+'"
    end  
    package "nagios-plugins-load" do
      not_if "rpm -qa | egrep -qe 'nagios-plugins-load-[0-9]+'"
    end
    package "nagios-plugins-http" do
      not_if "rpm -qa | egrep -qe 'nagios-plugins-[0-9]+'"
    end
  end
  
  execute "cp /usr/lib64/nagios/plugins/check_load /opt/nagios/libexec/" do
    not_if "test -f /opt/nagios/libexec/check_load"
    only_if "test -d /usr/lib64/nagios/plugins"
  end
  execute "cp /usr/lib/nagios/plugins/check_load /opt/nagios/libexec/" do
    not_if "test -f /opt/nagios/libexec/check_load"
    only_if "test -d /usr/lib/nagios/plugins"
  end
  execute "cp /usr/lib64/nagios/plugins/check_http /opt/nagios/libexec/" do
    not_if "test -f /opt/nagios/libexec/check_http"
    only_if "test -d /usr/lib64/nagios/plugins"
  end
  execute "cp /usr/lib/nagios/plugins/check_http /opt/nagios/libexec/" do
    not_if "test -f /opt/nagios/libexec/check_http"
    only_if "test -d /usr/lib/nagios/plugins"
  end
  
  # in case conf.d doesn't exist
  directory "/etc/nagios/conf.d"
  
  # remove default stuff added by redhat
  execute "rm -f internet.cfg" do
   cwd "/etc/nagios3/conf.d/"
   returns [0,1]
  end
else
  nagios_service = "nagios3"
  package "nagios3-core" do
    not_if "dpkg -l | egrep -qe 'nagios3-core'"
  end

  # ubuntu 12.04 + nagios 3.2.3 has issue with not setting p1_file, but ok with it empty
  execute "mkdir -p /usr/lib/nagios3 ; touch /usr/lib/nagios3/p1.pl"
  execute "rm -f /etc/nagios-plugins/config/ping.cfg" do
{'fraction_non_alphanumeric': 0.13642148129294987, 'fraction_numerical': 0.01501654364978366, 'mean_word_length': 3.059917355371901, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7387496', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1618, 'n_words': 378}