Advertisement
Kayleb

Nagios Install Script

Aug 16th, 2011
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.68 KB | None | 0 0
  1. # Script to ease installation of Nagios, it assumes you have internet connection and need nagios downloaded, if you already have it downloaded move to it's folder and comment out next three lines
  2.  
  3. # comment these out if you already have nagios downloaded
  4. cd /var/tmp
  5. apt-get -y install build-essential
  6. apt-get -y install libgd2-xpm-dev
  7. apt-get -y install xinetd
  8. apt-get -y install mcrypt
  9. apt-get -y install libcurl4-openssl-dev
  10. wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.3.1.tar.gz
  11. wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
  12. wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
  13. wget http://prdownloads.sourceforge.net/sourceforge/nagios/nsca-2.7.2.tar.gz
  14. # comment these out if you already have nagios downloaded
  15.  
  16. echo "Please enter account that will run Nagios"
  17. read NAGUSER
  18. echo "Please enter installation path withoud leading and trailing / (ie. nagios-czech)"
  19. read NAGIOS
  20. echo "Please enter www address where you want to see Nagios, without leading and trailing / (ie. nagios-czech will result in http://localhost/nagios-czech as your page)"
  21. read DOHLED
  22. echo "Please enter username for webaccess - it will also be granted admin permissions for web"
  23. read NAGWEBUSER
  24. echo "Please enter instance name (ie. nagios-czech this will put configs in /nagios-czech/SCRIPTS"
  25. read NAGIOSINIT
  26. echo "*************"
  27. echo "*** RECAP ***"
  28. echo "*************"
  29. echo "You entered: $NAGUSER as username under which will Nagios run"
  30. echo "You entered: $NAGIOS as path for installation"
  31. echo "You entered: $DOHLED as desired webpage for Nagios"
  32. echo "You entered: $NAGWEBUSER as user for web access"
  33. echo "You entered: $NAGIOSINIT as instance name for SCRIPTS"
  34. echo "You will be prompted for passwords during installation"
  35. echo "*************"
  36. echo "*** RECAP ***"
  37. echo "*************"
  38. tar -zxvf nagios-3.3.1.tar.gz
  39. tar -zxvf nagios-plugins-1.4.15.tar.gz
  40. tar -zxvf nrpe-2.12.tar.gz
  41. tar -zxvf nsca-2.7.2.tar.gz
  42. cd nagios
  43. useradd -m $NAGUSER
  44. usermod -a -G $NAGUSER www-data
  45. passwd $NAGUSER
  46. ./configure --with-nagios-user=$NAGUSER --with-nagios-group=$NAGUSER --with-command-user=$NAGUSER --with-command-group=$NAGUSER --prefix=/$NAGIOS --exec-prefix=/$NAGIOS/exec --with-htmurl=/$DOHLED --with-cgiurl=/$DOHLED/cgi-bin --with-httpd-conf=/$DOHLED/SCRIPTS --with-init-dir=/$DOHLED/SCRIPTS
  47. sed -i 's:for file in includes/rss/\*;:for file in includes/rss/\*.\*;:g' ./html/Makefile
  48. sed -i 's:for file in includes/rss/extlib/\*;:for file in includes/rss/extlib/\*.\*;:g' ./html/Makefile
  49. make all
  50. make install
  51. make install-init
  52. make install-config
  53. make install-commandmode
  54. make install-webconf
  55. htpasswd -c /$NAGIOS/etc/htpasswd.users $NAGWEBUSER
  56. sed -i "s/nagiosadmin/$NAGWEBUSER/g" /$NAGIOS/etc/cgi.cfg
  57. cd ..
  58. cd nagios-plugins-1.4.15
  59. ./configure --prefix=/$NAGIOS --exec-prefix=/$NAGIOS/exec --with-nagios-user=$NAGUSER --with-nagios-group=$NAGUSER --with-cgiurl=/$DOHLED/cgi-bin
  60. make
  61. make install
  62. cd ..
  63. cd nrpe-2.12
  64. ./configure --prefix=/$NAGIOS --exec-prefix=/$NAGIOS/exec --with-nagios-user=$NAGUSER --with-nagios-group=$NAGUSER --with-cgiurl=/$DOHLED/cgi-bin
  65. make all
  66. make install
  67. make install-plugin
  68. make install-daemon
  69. make install-daemon-config
  70. make install-xinetd
  71. cd ..
  72. cd nsca-2.7.2
  73. ./configure --prefix=/$NAGIOS --exec-prefix=/$NAGIOS/exec --with-nagios-user=$NAGUSER --with-nagios-group=$NAGUSER --with-cgiurl=/$DOHLED/cgi-bin
  74. make all
  75. make install
  76. cp /$DOHLED/SCRIPTS/nagios /etc/init.d/$NAGIOSINIT
  77. cp /$DOHLED/SCRIPTS/nagios.conf /etc/apache2/conf.d/$NAGIOSINIT.conf
  78. ln -s /etc/init.d/$NAGIOSINIT /etc/rcS.d/S99nagios
  79. /etc/init.d/apache2 reload
  80. /etc/init.d/$NAGIOSINIT checkconfig
  81. /etc/init.d/$NAGIOSINIT start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement