ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject git commit: AMBARI-6100. Integrate Ambari with Nagios packages for Ubuntu (aonishuk)
Date Thu, 12 Jun 2014 15:31:10 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 44ced4d5d -> d7246f095


AMBARI-6100. Integrate Ambari with Nagios packages for Ubuntu (aonishuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d7246f09
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d7246f09
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d7246f09

Branch: refs/heads/trunk
Commit: d7246f0957db836cfb2fdc6494fd32a22c7e32cd
Parents: 44ced4d
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Thu Jun 12 18:30:58 2014 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Thu Jun 12 18:30:58 2014 +0300

----------------------------------------------------------------------
 .../HDP/2.0.6/services/NAGIOS/metainfo.xml      | 43 +++++++++++++++++---
 .../services/NAGIOS/package/scripts/nagios.py   | 10 +++--
 .../NAGIOS/package/scripts/nagios_server.py     | 11 ++---
 .../NAGIOS/package/scripts/nagios_service.py    |  7 ++--
 .../services/NAGIOS/package/scripts/params.py   | 41 +++++++++++++++++--
 .../package/templates/hadoop-hosts.cfg.j2       |  2 +-
 .../NAGIOS/package/templates/nagios.cfg.j2      | 25 +++++-------
 .../NAGIOS/package/templates/nagios.conf.j2     |  8 ++--
 .../services/NAGIOS/package/templates/nagios.j2 |  2 +-
 .../stacks/2.0.6/NAGIOS/test_nagios_server.py   |  4 +-
 .../package/deb/create_nagios_addon_deb.sh      |  4 +-
 11 files changed, 109 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d7246f09/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/metainfo.xml
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/metainfo.xml
index a097d47..db15697 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/metainfo.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/metainfo.xml
@@ -86,22 +86,53 @@
               <name>perl</name>
             </package>
             <package>
-              <name>nagios-plugins-1.4.9</name>
+              <name>fping</name>
             </package>
             <package>
-              <name>nagios-3.5.0-99</name>
+              <name>hdp_mon_nagios_addons</name>
             </package>
+          </packages>
+        </osSpecific>
+        <osSpecific>
+          <osFamily>debian12</osFamily>             
+          <packages>
             <package>
-              <name>nagios-www-3.5.0-99</name>
+              <name>nagios3</name>
             </package>
             <package>
-              <name>nagios-devel-3.5.0-99</name>
+              <name>nagios3-common</name>
             </package>
             <package>
-              <name>fping</name>
+              <name>nagios3-dbg</name>
             </package>
             <package>
-              <name>hdp_mon_nagios_addons</name>
+              <name>nagios3-doc</name>
+            </package>
+            <package>
+              <name>nagios-plugins-extra</name>
+            </package>
+            <package>
+              <name>php5-curl</name>
+            </package>
+            <package>
+              <name>libapache2-mod-php5</name>
+            </package>
+          </packages>
+        </osSpecific>
+        <osSpecific>
+          <osFamily>redhat5,redhat6,suse11</osFamily>
+          <packages>
+            <package>
+              <name>nagios-plugins-1.4.9</name>
+            </package>
+            <package>
+              <name>nagios-3.5.0-99</name>
+            </package>
+            <package>
+              <name>nagios-www-3.5.0-99</name>
+            </package>
+            <package>
+              <name>nagios-devel-3.5.0-99</name>
             </package>
           </packages>
         </osSpecific>

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7246f09/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios.py
index 7756c47..47c3459 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios.py
@@ -77,13 +77,13 @@ def nagios():
 def set_web_permisssions():
   import params
 
-  cmd = format("{htpasswd_cmd} -c -b  /etc/nagios/htpasswd.users {nagios_web_login} {nagios_web_password!p}")
-  test = format("grep {nagios_web_login} /etc/nagios/htpasswd.users")
+  cmd = format("{htpasswd_cmd} -c -b  {conf_dir}/htpasswd.users {nagios_web_login} {nagios_web_password!p}")
+  test = format("grep {nagios_web_login} {conf_dir}/htpasswd.users")
   Execute( cmd,
     not_if = test
   )
 
-  File( "/etc/nagios/htpasswd.users",
+  File( format("{conf_dir}/htpasswd.users"),
     owner = params.nagios_user,
     group = params.nagios_group,
     mode  = 0640
@@ -91,7 +91,9 @@ def set_web_permisssions():
 
   if System.get_instance().os_family == "suse":
     command = format("usermod -G {nagios_group} wwwrun")
-  else:
+  elif System.get_instance().os_family == "debian":
+    command = format("usermod -G {nagios_group} www-data") # check -a ???
+  elif System.get_instance().os_family == "redhat":
     command = format("usermod -a -G {nagios_group} apache")
   
   Execute( command)

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7246f09/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios_server.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios_server.py
index c115e9a..ed7cebc 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios_server.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios_server.py
@@ -68,11 +68,12 @@ def remove_conflicting_packages():
   Package( 'nagios-plugins',
     action = "remove"
   )
-
-  Execute( "rpm -e --allmatches --nopostun nagios",
-    path    = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
-    ignore_failures = True 
-  )
+  
+  if System.get_instance().os_family in ["redhat","suse"]:
+    Execute( "rpm -e --allmatches --nopostun nagios",
+      path    = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
+      ignore_failures = True 
+    )
 
 def update_ignorable(params):
   if not params.config.has_key('passiveInfo'):

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7246f09/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios_service.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios_service.py
index cc411b5..f98344c 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios_service.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/nagios_service.py
@@ -26,11 +26,10 @@ def nagios_service(action='start'): # start or stop
   import params
 
   if action == 'start':
-   command = "service nagios start"
+   command = format("service {nagios_service_name} start")
   elif action == 'stop':
-   command = format("service nagios stop && rm -f {nagios_pid_file}")
+   command = format("service {nagios_service_name} stop && rm -f {nagios_pid_file}")
 
-  Execute( command,
-     path    = "/usr/local/bin/:/bin/:/sbin/"      
+  Execute( command,      
   )
   MonitorWebserver("restart")
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7246f09/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/params.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/params.py
index 5947cf6..8fcdd14 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/scripts/params.py
@@ -27,11 +27,40 @@ import status_params
 # server configurations
 config = Script.get_config()
 
-conf_dir = "/etc/nagios"
+if System.get_instance().os_family == "debian":
+  nagios_service_name = "nagios3"
+else:
+  nagios_service_name = "nagios"
+
+conf_dir = format("/etc/{nagios_service_name}")
+nagios_obj_dir = format("{conf_dir}/objects")
 nagios_var_dir = "/var/nagios"
 nagios_rw_dir = "/var/nagios/rw"
-plugins_dir = "/usr/lib64/nagios/plugins"
-nagios_obj_dir = "/etc/nagios/objects"
+
+if System.get_instance().os_family == "debian":
+  host_template = "generic-host"
+  plugins_dir = "/usr/lib/nagios/plugins"
+  nagios_web_dir = "/usr/share/nagios3/htdocs"
+  
+  cfg_files = [
+    format("{conf_dir}/commands.cfg"),
+    format("{conf_dir}/conf.d/contacts_nagios2.cfg"),
+    format("{conf_dir}/conf.d/generic-host_nagios2.cfg"),
+    format("{conf_dir}/conf.d/generic-service_nagios2.cfg"),
+    format("{conf_dir}/conf.d/timeperiods_nagios2.cfg"),
+  ]
+else:
+  host_template = "linux-server"
+  plugins_dir = "/usr/lib64/nagios/plugins"
+  nagios_web_dir = "/usr/share/nagios"
+  
+  cfg_files = [
+    format("{nagios_obj_dir}/commands.cfg"),
+    format("{nagios_obj_dir}/contacts.cfg"),
+    format("{nagios_obj_dir}/timeperiods.cfg"),
+    format("{nagios_obj_dir}/templates.cfg"),
+  ]
+  
 check_result_path = "/var/nagios/spool/checkresults"
 nagios_log_dir = "/var/log/nagios"
 nagios_log_archives_dir = format("{nagios_log_dir}/archives")
@@ -122,7 +151,11 @@ if System.get_instance().os_family == "suse":
   nagios_p1_pl = "/usr/lib/nagios/p1.pl"
   htpasswd_cmd = "htpasswd2"
   nagios_httpd_config_file = format("/etc/apache2/conf.d/nagios.conf")
-else:
+elif System.get_instance().os_family == "debian":
+  nagios_p1_pl = "/usr/lib/nagios3/p1.pl"
+  htpasswd_cmd = "htpasswd"
+  nagios_httpd_config_file = format("/etc/apache2/conf.d/nagios3.conf")
+elif System.get_instance().os_family == "redhat":
   nagios_p1_pl = "/usr/bin/p1.pl"
   htpasswd_cmd = "htpasswd"
   nagios_httpd_config_file = format("/etc/httpd/conf.d/nagios.conf")

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7246f09/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-hosts.cfg.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-hosts.cfg.j2
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-hosts.cfg.j2
index 4cfecf3..8bcc980 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-hosts.cfg.j2
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/hadoop-hosts.cfg.j2
@@ -38,7 +38,7 @@
 define host {
         alias                     {{host}}
         host_name                 {{host}}
-        use                       linux-server
+        use                       {{host_template}}
         address                   {{host}}
         check_command             check_tcp_wrapper!{{all_ping_ports[loop.index-1]}}!-w 1
-c 1
         check_interval            0.25

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7246f09/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.cfg.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.cfg.j2
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.cfg.j2
index 05d94b5..528ddc2 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.cfg.j2
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.cfg.j2
@@ -57,30 +57,27 @@
 log_file=/var/log/nagios/nagios.log
 
 
-
 # OBJECT CONFIGURATION FILE(S)
 # These are the object configuration files in which you define hosts,
 # host groups, contacts, contact groups, services, etc.
 # You can split your object definitions across several config files
 # if you wish (as shown below), or keep them all in a single config file.
 
-# You can specify individual object config files as shown below:
-cfg_file=/etc/nagios/objects/commands.cfg
-cfg_file=/etc/nagios/objects/contacts.cfg
-cfg_file=/etc/nagios/objects/timeperiods.cfg
-cfg_file=/etc/nagios/objects/templates.cfg
+{% for cfg_file in cfg_files %}
+cfg_file={{cfg_file}}
+{% endfor %}
 
 # Definitions for monitoring the local (Linux) host
-#cfg_file=/etc/nagios/objects/localhost.cfg
+#cfg_file={{conf_dir}}/objects/localhost.cfg
 
 # Definitions for monitoring a Windows machine
-#cfg_file=/etc/nagios/objects/windows.cfg
+#cfg_file={{conf_dir}}/objects/windows.cfg
 
 # Definitions for monitoring a router/switch
-#cfg_file=/etc/nagios/objects/switch.cfg
+#cfg_file={{conf_dir}}/objects/switch.cfg
 
 # Definitions for monitoring a network printer
-#cfg_file=/etc/nagios/objects/printer.cfg
+#cfg_file={{conf_dir}}/objects/printer.cfg
 
 # Definitions for hadoop servers
 cfg_file={{nagios_host_cfg}}
@@ -94,10 +91,10 @@ cfg_file={{nagios_command_cfg}}
 # extension) in a particular directory by using the cfg_dir
 # directive as shown below:
 
-#cfg_dir=/etc/nagios/servers
-#cfg_dir=/etc/nagios/printers
-#cfg_dir=/etc/nagios/switches
-#cfg_dir=/etc/nagios/routers
+#cfg_dir={{conf_dir}}/servers
+#cfg_dir={{conf_dir}}/printers
+#cfg_dir={{conf_dir}}/switches
+#cfg_dir={{conf_dir}}/routers
 
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7246f09/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.conf.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.conf.j2
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.conf.j2
index 0ec3c8c..f8420d2 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.conf.j2
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.conf.j2
@@ -57,13 +57,13 @@ ScriptAlias /nagios/cgi-bin "/usr/lib/nagios/cgi"
 #  Allow from 127.0.0.1
    AuthName "Nagios Access"
    AuthType Basic
-   AuthUserFile /etc/nagios/htpasswd.users
+   AuthUserFile {{conf_dir}}/htpasswd.users
    Require valid-user
 </Directory>
 
-Alias /nagios "/usr/share/nagios"
+Alias /nagios "{{nagios_web_dir}}"
 
-<Directory "/usr/share/nagios">
+<Directory "{{nagios_web_dir}}">
 #  SSLRequireSSL
    Options None
    AllowOverride None
@@ -74,7 +74,7 @@ Alias /nagios "/usr/share/nagios"
 #  Allow from 127.0.0.1
    AuthName "Nagios Access"
    AuthType Basic
-   AuthUserFile /etc/nagios/htpasswd.users
+   AuthUserFile {{conf_dir}}/htpasswd.users
    Require valid-user
 </Directory>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7246f09/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.j2
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.j2
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.j2
index f4ad87d..0927915 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.j2
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/NAGIOS/package/templates/nagios.j2
@@ -63,7 +63,7 @@ prefix="/usr"
 exec_prefix="/usr"
 exec="/usr/sbin/nagios"
 prog="nagios"
-config="/etc/nagios/nagios.cfg"
+config="{{conf_dir}}/nagios.cfg"
 pidfile="{{nagios_pid_file}}"
 user="{{nagios_user}}"
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7246f09/ambari-server/src/test/python/stacks/2.0.6/NAGIOS/test_nagios_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/NAGIOS/test_nagios_server.py b/ambari-server/src/test/python/stacks/2.0.6/NAGIOS/test_nagios_server.py
index c7a52f0..1e9b5f3 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/NAGIOS/test_nagios_server.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/NAGIOS/test_nagios_server.py
@@ -41,7 +41,6 @@ class TestNagiosServer(RMFTestCase):
     )
     self.assert_configure_default()
     self.assertResourceCalled('Execute', 'service nagios start',
-                              path=['/usr/local/bin/:/bin/:/sbin/']
     )
     self.assertResourceCalled('MonitorWebserver', 'restart',
     )
@@ -56,8 +55,7 @@ class TestNagiosServer(RMFTestCase):
       config_file="default.json"
     )
     self.assertResourceCalled('Execute',
-                              'service nagios stop && rm -f /var/run/nagios/nagios.pid',
-                              path=['/usr/local/bin/:/bin/:/sbin/']
+                              'service nagios stop && rm -f /var/run/nagios/nagios.pid'
     )
     self.assertResourceCalled('MonitorWebserver', 'restart',
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7246f09/contrib/addons/package/deb/create_nagios_addon_deb.sh
----------------------------------------------------------------------
diff --git a/contrib/addons/package/deb/create_nagios_addon_deb.sh b/contrib/addons/package/deb/create_nagios_addon_deb.sh
index bd81748..a64e045 100644
--- a/contrib/addons/package/deb/create_nagios_addon_deb.sh
+++ b/contrib/addons/package/deb/create_nagios_addon_deb.sh
@@ -48,8 +48,8 @@ SRC_DIR="${BASEDIR}/../../src/addOns/nagios/"
 mkdir -p "${MON_TAR_DIR}/usr/lib64/nagios"
 cp -r "${SRC_DIR}/plugins" "${MON_TAR_DIR}/usr/lib64/nagios"
 
-mkdir -p "${MON_TAR_DIR}/etc/httpd"
-cp -r "${SRC_DIR}/conf.d" "${MON_TAR_DIR}/etc/httpd"
+mkdir -p "${MON_TAR_DIR}/etc/apache2"
+cp -r "${SRC_DIR}/conf.d" "${MON_TAR_DIR}/etc/apache2"
 
 mkdir -p "${MON_TAR_DIR}/usr/share/hdp/nagios"
 cp -r ${SRC_DIR}/scripts/* "${MON_TAR_DIR}/usr/share/hdp/nagios"


Mime
View raw message