Package: nagvis
Version: 1:1.7.10+dfsg1-1
Severity: wishlist

Hello,

The attached patches allows quick configuration of nagvis with shinken.

Regards
-- 
Mathieu
From b29cbf2e0a0f192c2c98b761f448429001510754 Mon Sep 17 00:00:00 2001
From: Mathieu Parent <math.par...@gmail.com>
Date: Thu, 26 Dec 2013 10:43:48 +0100
Subject: [PATCH 1/2] Refactor monitoring configuration

---
 debian/nagvis.postinst | 60 ++++++++++++++++++++------------------------------
 1 file changed, 24 insertions(+), 36 deletions(-)

diff --git a/debian/nagvis.postinst b/debian/nagvis.postinst
index fac9f84..4a2cfe6 100644
--- a/debian/nagvis.postinst
+++ b/debian/nagvis.postinst
@@ -90,8 +90,8 @@ case "$1" in
         . /usr/share/debconf/confmodule
         db_get nagvis/monitoring_system
         MONITORING="$RET"
-	case "$MONITORING" in
-	    "icinga")
+        case "$MONITORING" in
+            "icinga"|"nagios")
                 ## Creating Configuration file for Nagvis
                 nagvis_tmp=$(mktemp)
                 cat /usr/share/nagvis/defaults/nagvis.ini.php-sample | sed \
@@ -99,12 +99,22 @@ case "$1" in
                   -e "s#;file_mode=\"660\"#file_mode=\"660\"#g" \
                   -e "s#;base=\"/usr/local/nagvis/\"#base=\"/usr/share/nagvis/\"#" \
                   -e "s#;htmlbase=\"/nagvis\"#htmlbase=\"/nagvis\"#" \
-                  -e "s#;htmlcgi=\"/nagios/cgi-bin\"#htmlcgi=\"/icinga/cgi-bin\"#" \
-                  -e "s#;socket=\"unix:/usr/local/nagios/var/rw/live\"#socket=\"unix:/var/lib/icinga/rw/live\"#" \
                   -e "s#\[rotation_demo\]#;\[rotation_demo\]#" \
                   -e "s#interval=15#;interval=15#" \
                   -e "s#maps=\"\(.*\)\"#;maps=\"\1\"#" \
                   > "$nagvis_tmp"
+                case "$MONITORING" in
+                    "icinga")
+                        sed -i "$nagvis_tmp" \
+                          -e "s#;htmlcgi=\"/nagios/cgi-bin\"#htmlcgi=\"/icinga/cgi-bin\"#" \
+                          -e "s#;socket=\"unix:/usr/local/nagios/var/rw/live\"#socket=\"unix:/var/lib/icinga/rw/live\"#"
+                    ;;
+                    "nagios")
+                        sed -i "$nagvis_tmp" \
+                          -e "s#;htmlcgi=\"/nagios/cgi-bin\"#htmlcgi=\"/nagios/cgi-bin\"#" \
+                          -e "s#;socket=\"unix:/usr/local/nagios/var/rw/live\"#socket=\"unix:/var/lib/nagios3/rw/live\"#"
+                    ;;
+                esac
                 chgrp www-data "$nagvis_tmp"
                 chmod g+rw "$nagvis_tmp"
                 ucf --debconf-ok "$nagvis_tmp" /etc/nagvis/nagvis.ini.php
@@ -114,40 +124,18 @@ case "$1" in
                 apache_tmp=$(mktemp)
                 sed -e "s#@NAGVIS_PATH@#/usr/share/nagvis/share/#g" \
                   -e "s#@NAGVIS_WEB@#/nagvis#g" \
-                  -e "s#@NAGIOS_PATH@/etc#/etc/icinga#g" \
-                  < /usr/share/nagvis/defaults/apache2-nagvis.conf-sample \
-                  > "$apache_tmp"
-                chmod go+r "$apache_tmp"
-                ucf --debconf-ok "$apache_tmp" /etc/nagvis/apache2.conf
-                ucfr nagvis /etc/nagvis/apache2.conf
-                rm -f "$apache_tmp"
-            ;;
-            "nagios")
-                ## Creating Configuration file for Nagvis
-                nagvis_tmp=$(mktemp)
-                cat /usr/share/nagvis/defaults/nagvis.ini.php-sample | sed \
-                  -e "s#;file_group=\"\"#file_group=\"www-data\"#g" \
-                  -e "s#;file_mode=\"660\"#file_mode=\"660\"#g" \
-                  -e "s#;base=\"/usr/local/nagvis/\"#base=\"/usr/share/nagvis/\"#" \
-                  -e "s#;htmlbase=\"/nagvis\"#htmlbase=\"/nagvis\"#" \
-                  -e "s#;htmlcgi=\"/nagios/cgi-bin\"#htmlcgi=\"/nagios/cgi-bin\"#" \
-                  -e "s#;socket=\"unix:/usr/local/nagios/var/rw/live\"#socket=\"unix:/var/lib/nagios3/rw/live\"#" \
-                  -e "s#\[rotation_demo\]#;\[rotation_demo\]#" \
-                  -e "s#interval=15#;interval=15#" \
-                  -e "s#maps=\"\(.*\)\"#;maps=\"\1\"#" \
-                  > "$nagvis_tmp"
-                chgrp www-data "$nagvis_tmp"
-                chmod g+rw "$nagvis_tmp"
-                ucf --debconf-ok "$nagvis_tmp" /etc/nagvis/nagvis.ini.php
-                ucfr nagvis /etc/nagvis/nagvis.ini.php
-                rm -f "$nagvis_tmp"
-                ## Creating Configuration snipplet for Apache
-                apache_tmp=$(mktemp)
-                sed -e "s#@NAGVIS_PATH@#/usr/share/nagvis/share/#g" \
-                  -e "s#@NAGVIS_WEB@#/nagvis#g" \
-                  -e "s#@NAGIOS_PATH@/etc#/etc/nagios3#g" \
                   < /usr/share/nagvis/defaults/apache2-nagvis.conf-sample \
                   > "$apache_tmp"
+                case "$MONITORING" in
+                    "icinga")
+                        sed -i "$apache_tmp" \
+                          -e "s#@NAGIOS_PATH@/etc#/etc/icinga#g"
+                    ;;
+                    "nagios")
+                        sed -i "$apache_tmp" \
+                          -e "s#@NAGIOS_PATH@/etc#/etc/nagios3#g"
+                    ;;
+                esac
                 chmod go+r "$apache_tmp"
                 ucf --debconf-ok "$apache_tmp" /etc/nagvis/apache2.conf
                 ucfr nagvis /etc/nagvis/apache2.conf
-- 
1.8.5.1

From f2baad4efefd797acfbdc1b5b5c8653151b572ef Mon Sep 17 00:00:00 2001
From: Mathieu Parent <math.par...@gmail.com>
Date: Thu, 26 Dec 2013 10:45:08 +0100
Subject: [PATCH 2/2] Shinken support

---
 debian/nagvis.postinst  | 13 +++++++++++--
 debian/nagvis.templates |  4 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/debian/nagvis.postinst b/debian/nagvis.postinst
index 4a2cfe6..4220b70 100644
--- a/debian/nagvis.postinst
+++ b/debian/nagvis.postinst
@@ -91,7 +91,7 @@ case "$1" in
         db_get nagvis/monitoring_system
         MONITORING="$RET"
         case "$MONITORING" in
-            "icinga"|"nagios")
+            "icinga"|"nagios"|"shinken")
                 ## Creating Configuration file for Nagvis
                 nagvis_tmp=$(mktemp)
                 cat /usr/share/nagvis/defaults/nagvis.ini.php-sample | sed \
@@ -114,6 +114,11 @@ case "$1" in
                           -e "s#;htmlcgi=\"/nagios/cgi-bin\"#htmlcgi=\"/nagios/cgi-bin\"#" \
                           -e "s#;socket=\"unix:/usr/local/nagios/var/rw/live\"#socket=\"unix:/var/lib/nagios3/rw/live\"#"
                     ;;
+                    "shinken")
+                        sed -i "$nagvis_tmp" \
+                          -e "s#;htmlcgi=\"/nagios/cgi-bin\"#htmlcgi=\"/nagios/cgi-bin\"#" \
+                          -e "s#;socket=\"unix:/usr/local/nagios/var/rw/live\"#socket=\"tcp:localhost:50000\"#"
+                    ;;
                 esac
                 chgrp www-data "$nagvis_tmp"
                 chmod g+rw "$nagvis_tmp"
@@ -135,6 +140,10 @@ case "$1" in
                         sed -i "$apache_tmp" \
                           -e "s#@NAGIOS_PATH@/etc#/etc/nagios3#g"
                     ;;
+                    "shinken")
+                        sed -i "$apache_tmp" \
+                          -e "s#@NAGIOS_PATH@/etc#/etc/shinken#g"
+                    ;;
                 esac
                 chmod go+r "$apache_tmp"
                 ucf --debconf-ok "$apache_tmp" /etc/nagvis/apache2.conf
@@ -147,7 +156,7 @@ case "$1" in
         esac
 
         # enable apache when file exists and we are on autoconfigure
-        if [ -f /etc/nagvis/apache2.conf ] && ( [ "$MONITORING" = "nagios" ] || [ "$MONITORING" = "icinga" ] ); then
+        if [ -f /etc/nagvis/apache2.conf ] && ( [ "$MONITORING" = "nagios" ] || [ "$MONITORING" = "icinga" ] || [ "$MONITORING" = "shinken" ] ); then
             echo "enabling Apache2 config..."
 
             COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
diff --git a/debian/nagvis.templates b/debian/nagvis.templates
index 1b84b0e..3ab0fe2 100644
--- a/debian/nagvis.templates
+++ b/debian/nagvis.templates
@@ -10,8 +10,8 @@
 Template: nagvis/monitoring_system
 Type: select
 Default: icinga
-#flag:translate:3
-__Choices: icinga, nagios, other
+#flag:translate:4
+__Choices: icinga, nagios, shinken, other
 _Description: Monitoring suite used with NagVis:
  The NagVis package supports Icinga as well as
  Nagios, using the check-mk-live broker backend.
-- 
1.8.5.1

Reply via email to