Page 1 of 6 123 ... LastLast
Results 1 to 10 of 59

Thread: My Notes for Installing Nagios on Ubuntu Server 12.04 LTS

  1. #1
    Join Date
    Sep 2011
    Location
    Behind you!
    Beans
    1,690
    Distro
    Ubuntu 20.04 Focal Fossa

    Post My Notes for Installing Nagios on Ubuntu Server 12.04 LTS

    Greetings and salutations,

    I hope this thread will be helpful to those who follow in my foot steps as well as getting any advice based on what I have done / documented.

    This is a Work-In-Progress topic so I will be updating this thread as I complete/update my notes.

    High-level overview

    This thread will cover installation of a dedicated Ubuntu server and Nagios monitoring system. The server will be installed inside a virtual machine vSphere 4.1 running on ESXi 4.1 servers. I will also supply notes for doing the same thing for Oracle's VirtualBox on a Windows 7 PC. Although there are some VMware-specific and VirtualBox-specific steps, they are very few and the majority of this documentation will work for other Virtual Machines or even directly installed onto a physical machine (e.g. bare-metal install). Please excuse any ignorance on my part since I am fairly new to Linux...if you have any advice on doing things better, please let me know. I love feedback and learning better ways of doing things!

    This thread will also cover some custom scripts to help automate tasks such as backing up, automatically growing the file system when free space is low, etc.

    I choose to build Nagios from the source download rather than install from the repository with aptitude / apt-get. The reason is that you get the newer version this way and you have full control over the installation options.

    This documentation will only cover a very specific installation. Nagios was designed to be able to handle just about anything you want to monitor so it will be different for each install and even with the same hardware needing to be monitored, two administrators may decide differently on what needs to be monitored.

    Tools utilized in this process




    Helpful links

    The list below are sources of information that helped me configure this system as well as some places that might be helpful to me later on as this process continues.



    Assumptions

    This documentation will need to make use of some very-specific information that will most-likely be different for each person / location. And as such, I will note some of these in this section. They will be highlighted in red throughout the document as a reminder that you should plug-in your own value rather than actually using my "place-holder" value.

    Under no circumstance should you use the actual values I list below. They are place-holders for the real thing. This is just a checklist template you need to have answered before you start the install process.

    Wherever you see RED in this document, you need to substitute it for what your company uses. Use the list below as a template you need to have answered before you continue.


    • Ubuntu Server name: srv-nagios
    • Internet domain: mydomain.com
    • Ubuntu Server IP address: 192.168.107.21
    • Ubuntu Server IP subnet mask: 255.255.255.0
    • Ubuntu Server IP gateway: 192.168.107.1
    • Internal DNS Server 1: 192.168.107.212
    • Internal DNS Server 2: 192.168.107.213
    • External DNS Server 1: 8.8.8.4
    • External DNS Server 2: 8.8.8.5
    • Ubuntu Admin ID: administrator
    • Ubuntu Admin Password: myadminpass
    • Nagios Admin Password: mynagiospass
    • Nagios NSClient Port #: 12489
    • Nagios NRPE Port #: 5666
    • Nagios Service Password: myservicepass
    • Email Server (remote): 192.168.107.25
    • Windows Share ID: myshare
    • Windows Share Password: mysharepass


    I also assume the reader knows how to use the VI editor. If not, you will need to beef up your skill set or use a different editor in place of it.
    Last edited by LHammonds; May 30th, 2012 at 07:04 PM.

  2. #2
    Join Date
    Sep 2011
    Location
    Behind you!
    Beans
    1,690
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: My Notes for Installing Nagios on Ubuntu Server 12.04 LTS

    Analysis and Design

    The Ubuntu Server Long-Term Support (LTS) is free but we have the option of buy support and that is the main reason this server was selected.

    The largest decision over the configuration of Ubuntu seems to be how the hard drive space is sliced up (partitioned). I lot of my time was spent researching and learning the various options when it comes to the design layout of the storage.

    I like to make use of a design that allows for dynamic growth and fine-tuning if need be. I also do not like being caught offguard with a scenario where space is filled up with no immediate option other than deleting files. Long-term life and growth of the system as well as budgeting concerns have to be taken into consideration.

    I like to contain the root volume to mainly just static data that won't grow much and push the other folders that are dynamic into their own volumes. In case you don't know, filling up the root volume on a *nix system is a very bad thing and should be avoided at all costs. I also want to configure it where the file systems are not taking up 100% of the logical volume. This will allow me (through automated scripts) to grow the file system as needed and give me some time to add more drives if necessary or shrink other volumes to get more space.

    Here are my thoughts on how to slice up the space.


    • boot - This will remain static in size. It is also the only space residing outside the Logical Volume Manager (LVM)
    • root volume - Operating system and everything else which should remain fairly static.
    • swap volume - This will remain static in size. However, if amount of RAM is adjusted, this should be adjusted as well.
    • var volume - This is the app/database/log storage and will continue to grow over time.
    • srv volume - This will contain the files stored in the Samba share.
    • bak volume - This will contain a local backup of the application. So space needs to be around double /var.
    • tmp volume - This location will be used for temporary storage. Size should be adjusted to match however it is being used.
    • Offsite Storage - This will be handled elsewhere but will be mounted on this server.


    My estimated database store will be about 2 GB. However, we will start this server off with a lower number. We will then pretend some event happened such as a popular content site which causes quick growth of the database. This will increase our storage needs and we will go through adjusting the entire system to accommodate a larger storage capacity. This will be a good exercise / documentation for what will eventually need to be done later to handle growth.

    To get a good idea of the initial hard drive layout and to understand the process better, here is a graphical representation of the initial design for the server:



    These numbers will be used for the initial build of the system:

    boot = 200 MB
    root = 4 GB
    swap = 2 GB
    bak = 500 MB
    tmp = 500 MB
    srv = 500 MB
    var = 500 MB

    NOTE: When the logical volumes and file systems are initially created, they consume the maximum amount of space allocated so that the logical volume size = file system size. These partition sizes are artificially small for that reason. These will be later modified so that the logical volume will be larger than the file system so that the file system has room to expand when needed.

    Important info:
    - The /tmp folder is strictly temporary. Each time the server reboots, this folder is deleted and re-created.
    - The /bak folder will retain the most recent backup and is considered the "local" copy of the backup.

    VMware Virtual Machine Settings

    Virtual Manager: VMware vSphere Client 4.1
    Virtual Host: VMware ESXi Server 4.1


    • Configuration: Custom
    • Name: srv-nagios
    • Datastore: DS3400-LUN0
    • Virtual Machine Version: 7
    • Guest Operating System: Linux, Version: Ubuntu Linux (64-bit)
    • Number of virtual processors: 1
    • Memory Size: 1024 MB
    • Number of NICs: 1
    • NIC 1: VM Network
    • Adapter: E1000, Connect at Power On: Checked
    • SCSI controller: LSI Logic Parallel
    • Select a Disk: Create a new virtual disk
    • Create a Disk: 8 GB, No thin provisioning, No cluster features, Store with the virtual machine
    • Advanced Options: Virtual Device Node = SCSI (0:0)
    • Remove Floppy Drive
    • Mount CD/DVD Drive to Ubuntu ISO (ubuntu-12.04-server-amd64.iso). Make sure CD/DVD is set to Connect at power on
    • Set boot options to Force BIOS Setup so you can set CDROM to boot before the Hard Disk


    VirtualBox Virtual Machine Settings

    Virtual Manager: Oracle VirtualBox 4.1.14
    Virtual Host: Windows 7 Ultimate with SP1 (64-bit)


    • Name: srv-nagios
    • Operating System: Linux
    • Version: Ubuntu (64 bit)
    • Memory: 1024 MB
    • Check - Start-up Disk
      - Create new hard disk
      - VMDK
      - Dynamically allocated
      - Size: 8 GB
    • Select srv-nagios and click Settings (CTRL+S)
      - System, Processor, Enable PAE/NX
      - Network, Attached to: Bridged Adapter, Advanced, Adapter Type: Intel PRO/1000 MT Server
      - Storage, IDE Controller, Choose a virtual CD/DVD disk file, ubuntu-12.04-server-amd64.iso


    Install PuTTY

    The 1st time I installed Ubuntu, I used the console for everything but it was painfully slow to view man (manual) pages and navigating in VI (text editor). However, I found out that PuTTY is a far better solution for your Ubuntu console because it handles the screen draws much faster and allows for scrolling and copying text.

    Download the portable edition and run the install...except it doesn't really "install" like a normal program, it simply extracts to a specified folder and will run from that folder even if you put it on a USB stick and carry over to a new computer (requires no install to run and thus leaves a very small footprint on your system)


    1. Start PuTTY
    2. Type the following and click the Save button:
      Host Name: SRV-Nagios (or the IP such as 192.168.107.21)
      Port: 22
      Connection type: SSH
      Saved Sessions: SRV-Nagios
    3. Now all you have to do is double-click on the session and it will connect to your server (when online).
    Last edited by LHammonds; May 27th, 2012 at 09:16 AM.

  3. #3
    Join Date
    Sep 2011
    Location
    Behind you!
    Beans
    1,690
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: My Notes for Installing Nagios on Ubuntu Server 12.04 LTS

    Install Ubuntu Server

    NOTE: During the setup process throughout this entire document, most commands will require "sudo" as a prefix. However, I will be using "sudo su" to temporarily gain root privileges.


    1. Power on the Virtual Machine (VM)
    2. Press {ENTER} to accept English
    3. Select Install Ubuntu Server {ENTER}
    4. Press {ENTER} to accept English
    5. Press {ENTER} to accept United States
    6. Select No to not detect keyboard layout
    7. Press {ENTER} to accept English (US)
    8. Press {ENTER} to accept English (US)
    9. Type srv-nagios {ENTER} (this is your hostname)
    10. Type Administrator, {ENTER} for the full name
    11. Press {ENTER} to accept the default of the lowercase name of administrator
    12. Type myadminpass, {ENTER}, myadminpass, {ENTER}
    13. Select No, {ENTER} to not encrypt your home directory
    14. Press {ENTER} to accept detected time zone (America/Chicago)
    15. Select Manual {ENTER}
    16. Select SCSI3 (0,0,0) (sda) - 8.6 GB VMware Virtual disk {ENTER}
    17. Select Yes to create new empty partition table, {ENTER}
    18. Select pri/log 8.6 GB FREE SPACE {ENTER}
    19. Select Create a new partition {ENTER}
    20. Type 200 MB, {ENTER} (NOTE: This will be the /boot partition)
    21. Select Primary {ENTER}
    22. Select Beginning {ENTER}
    23. Select Use as: Ext4 journaling file system {ENTER}
    24. Select Ext2 file system {ENTER}
    25. Select Mount point: / {ENTER}
    26. Select /boot - static files of the boot loader {ENTER}
    27. Select Bootable flag: off {ENTER} (NOTE: This toggles it on)
    28. Select Done setting up the partition {ENTER}
    29. Select Configure the Logical Volume Manager {ENTER}
    30. Select Yes to write change to disks and configure LVM, {ENTER}
    31. Select Create volume group {ENTER}
    32. Type LVG {ENTER}
    33. Select /dev/sda free #1 (12684MB; FREE SPACE), {SPACEBAR}, {ENTER}
    34. Select Yes to write change to disks and configure LVM, {ENTER}
    35. Select Create logical volume {ENTER}
    36. Select LVG (8384MB) {ENTER}
    37. Type swap {ENTER}
    38. Type 2G {ENTER} (NOTE: This is double the amount of RAM)
    39. Select Create logical volume {ENTER}
    40. Select LVG (6387MB) {ENTER}
    41. Type bak {ENTER}
    42. Type 500M {ENTER}
    43. Select Create logical volume {ENTER}
    44. Select LVG (5888MB) {ENTER}
    45. Type var {ENTER}
    46. Type 500M {ENTER}
    47. Select Create logical volume {ENTER}
    48. Select LVG (5389MB) {ENTER}
    49. Type tmp {ENTER}
    50. Type 500M {ENTER}
    51. Select Create logical volume {ENTER}
    52. Select LVG (4890MB) {ENTER}
    53. Type srv {ENTER}
    54. Type 500M {ENTER}
    55. Select Create logical volume {ENTER}
    56. Select LVG (4391MB) {ENTER}
    57. Type root {ENTER}
    58. Type 4G {ENTER} (we will have a small amount leftover in LVG)
    59. Select Finish {ENTER}
    60. Select #1 2.0 GB directly under LVM VG LVG, LV swap, {ENTER}
    61. Select Use as: do not use {ENTER}
    62. Select swap area {ENTER}
    63. Select Done setting up the partition {ENTER}
    64. Select #1 4.0 GB directly under LVM VG LVG, LV root, {ENTER}
    65. Select Use as: do not use {ENTER}
    66. Select Ext4 journaling file system {ENTER}
    67. Select Mount point: none {ENTER}
    68. Select / - the root file system {ENTER}
    69. Select Done setting up the partition {ENTER}
    70. Select #1 499.1 MB directly under LVM VG LVG, LV bak, {ENTER}
    71. Select Use as: do not use {ENTER}
    72. Select Ext4 journaling file system {ENTER}
    73. Select Mount point: none {ENTER}
    74. Select Enter manually {ENTER}
    75. Type /bak {ENTER}
    76. Select Label: none {ENTER}
    77. Type bak {ENTER}
    78. Select Done setting up the partition {ENTER}
    79. Select #1 499.1 MB directly under LVM VG LVG, LV var, {ENTER}
    80. Select Use as: do not use {ENTER}
    81. Select Ext4 journaling file system {ENTER}
    82. Select Mount point: none {ENTER}
    83. Select /var {ENTER}
    84. Select Label: none {ENTER}
    85. Type var {ENTER}
    86. Select Done setting up the partition {ENTER}
    87. Select #1 499.1 MB directly under LVM VG LVG, LV tmp, {ENTER}
    88. Select Use as: do not use {ENTER}
    89. Select Ext4 journaling file system {ENTER}
    90. Select Mount point: none {ENTER}
    91. Select /tmp {ENTER}
    92. Select Label: temp {ENTER}
    93. Select Done setting up the partition {ENTER}
    94. Select #1 499.1 MB directly under LVM VG LVG, LV srv, {ENTER}
    95. Select Use as: do not use {ENTER}
    96. Select Ext4 journaling file system {ENTER}
    97. Select Mount point: none {ENTER}
    98. Select /srv {ENTER}
    99. Select Label: srv {ENTER}
    100. Select Done setting up the partition {ENTER}
    101. Here is what the screen looks like at this point: Partitions
    102. Select Finish partitioning and write changes to disk {ENTER}
    103. Select Yes to write changes to disk, {ENTER}
    104. Press {ENTER} to accept a blank line for the HTTP proxy
    105. Select Install security updates automatically, {ENTER}
    106. Highlight only OpenSSH server and press {SPACEBAR} to enable, {ENTER} to continue. NOTE: This allows us to use PuTTY after installation to connect to the server.
    107. Select Yes, {ENTER} to install GRUB boot loader to the master boot record
    108. Installation Complete - from the VM menu, select VM --> Edit Settings and select CD/DVD Drive 1 and change to "Client Device" which will effectively remove the ISO. Now press {ENTER} to reboot.



    Initial Configurations


    1. At the console login prompt, login with your administrator account (administrator / myadminpass)
    2. At the $ prompt, temporarily grant yourself super user privilages by typing sudo su {ENTER} and then provide the administrator password (myadminpass).
    3. Type vi /etc/network/interfaces {ENTER} and change the following: (We need to change the network interface card (NIC) from using DHCP to a static IP)
      From:
      Code:
      iface eth0 inet dhcp
      To:
      Code:
      iface eth0 inet static
      address 192.168.107.21
      netmask 255.255.255.0
      gateway 192.168.107.1
      network 192.168.107.0
      broadcast 192.168.107.255
      dns-nameservers 192.168.107.212 192.168.107.213 8.8.8.4 8.8.8.5
      
      NOTE #1: You may need to manually remove the DHCP record (lease) associated to this Ubuntu server from your DHCP server so the correct IP can be found by other machines on the network. This can be avoided by temporarily configuring the VM Network Adapter connection to be "Host Only Network" instead of "VM Network" so the server is isolated during setup...at least until you reach the testing of the static IP below.

      NOTE #2: You might also need to manually add a HOST(A) record to your Windows DNS server (for srv-mysql.mydomain.com and srv-mysql.work.mydomain.com)
    4. Restart the network by typing /etc/init.d/networking restart
    5. Sanity check! Type ifconfig and make sure the settings are correct. Then type ping www.google.com or similar and see if ping works.
    6. Shutdown and power off the server by typing shutdown -P now
    7. At this point forward, you can use PuTTY to access the console rather than the console itself for better performance, ability to scroll, etc.
    8. In VM menu, select VM --> Snapshot --> Take Snapshot. Give it a name like STEP 1 and description of Ubuntu Server 12.04 LTS, clean install, Static IP: 192.168.107.21 and click OK



    Software Configurations


    1. Start the Ubuntu server and connect using PuTTY.
    2. At the $ prompt, temporarily grant yourself super user privilages by typing sudo su {ENTER} and then provide the administrator password (myadminpass).
    3. At the $ prompt, type aptitude -y install vim-nox for use instead of the built-in VI editor. more info
    4. At the $ prompt, type aptitude -y install p7zip-full to install 7-zip archive utility.
    5. At the $ prompt, type aptitude -y install sendemail to install a command-line email utility.
    6. Change the default shell from dash to bash. Type ls -l /bin/sh to see that it points to /bin/dash. Type dpkg-reconfigure dash and answer No. Type ls -l /bin/sh and it should now be pointing to /bin/bash
    7. Remove AppArmor to avoid problems by typing the following:
      Code:
      /etc/init.d/apparmor stop
      /etc/init.d/apparmor teardown
      update-rc.d -f apparmor remove
      aptitude remove apparmor apparmor-utils
    8. Type vi /etc/hosts and add your email server:
      Code:
      192.168.107.25    srv-mail
    9. Test the ability to send email by typing:
      Code:
      sendemail -f root@myserver -t MyTargetAddress@MyDomain.com -u "This is the Subject" -m "This is the body of the email" -s srv-mail:25
    10. Reboot the server by typing reboot



    VMware Tools

    If you are installing under VMware like me, be sure to install the tools to insure maximum performance in a virtual environment.


    1. In the VM toolbar for the VM, click Guest, Install VMware Tools
    2. At the Ubuntu prompt, type the following:
      Code:
      
      mkdir /mnt/cdrom
      mount /dev/cdrom /mnt/cdrom
      ls /mnt/cdrom       ( make sure you see a file such as VMwareTools-8.3.2-257589.tar.gz)
      tar zxvf /mnt/cdrom/VMwareTools* -C /tmp/
      cd /tmp/vmware-tools-distrib/
      ./vmware-install.pl -d
      reboot
      



    VirtualBox Guest Additions - Installation

    If you are installing under VirtualBox, be sure to install the Guest Additions to insure maximum performance in a virtual environmnet.


    1. Login with your administrator account. At the $ prompt, temporarily grant yourself super user privilages by typing sudo su {ENTER} and then provide the administrator password (myadminpass).
    2. You need to perform the following commands to fulfill the prerequisites:
      Code:
      
      aptitude update
      aptitude safe-upgrade
      aptitude install dkms
      reboot
      
    3. Login with your administrator account. At the $ prompt, temporarily grant yourself super user privilages by typing sudo su {ENTER} and then provide the administrator password (myadminpass).
    4. From the VirtualBox menu, click Devices, Install Guest Additions
    5. At the console, type the following:
      Code:
      
      mkdir -p /mnt/cdrom
      mount /dev/cdrom /mnt/cdrom
      /mnt/cdrom/VBoxLinuxAdditions.run
      
    6. NOTE: The X Windows System drivers will fail to load because this is a headless server with no GUI (which is OK)
    7. To see if the services are running, type /etc/init.d/vboxadd-service status or service vboxadd-service status



    VirtualBox Guest Additions - Upgrading

    If you upgraded VirtualBox on your host machine, you also need to upgrade the Guest Additions on all your guest operating systems.

    Then mount the CDROM and run the installer just like the above. Reboot after it is upgraded.


    1. Login with your administrator account. At the $ prompt, temporarily grant yourself super user privilages by typing sudo su {ENTER} and then provide the administrator password (myadminpass).
    2. From the VirtualBox menu, click Devices, Install Guest Additions
    3. At the console, type the following:
      Code:
      
      mount /dev/cdrom /mnt/cdrom
      /mnt/cdrom/VBoxLinuxAdditions.run
      reboot
      



    VirtualBox Guest Additions - Uninstallation

    If you are about to migrate from a VirtualBox host to something like a VMware host, you will need to uninstall VirtualBox's Guest Additions.


    1. Login with your administrator account. At the $ prompt, temporarily grant yourself super user privilages by typing sudo su {ENTER} and then provide the administrator password (myadminpass).
    2. Type the following:
      Code:
      
      cd /opt/VBox*
      ./uninstall.sh
      
    Last edited by LHammonds; June 18th, 2012 at 04:36 PM.

  4. #4
    Join Date
    Sep 2011
    Location
    Behind you!
    Beans
    1,690
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: My Notes for Installing Nagios on Ubuntu Server 12.04 LTS

    Volume / Disk Management

    At this point, each volume is fairly small and the file systems contained in them are taking up all of the volume space. This setup allows no room to expand our file system as needed! We need to change this.

    We are going to add an additional hard drive and give that space to the LVM. Then space is going to be given to each volume we are going to grow. However, we are not going to max-out the size of the file system. We are going to leave some head room for expansion later which will give us the necessary time to acquire more storage but allow us to immediately grow the file system to accomodate our immediate needs.

    bak volume = 4 GB, file system = 2 GB (2 GB available for growth)
    srv volume = 1 GB, file system = 500 MB (500 MB available for growth)
    tmp volume = 2 GB, file system = 1 GB (1 GB available for growth)
    var volume = 2 GB, file system = 1 GB (1 GB available for growth)

    We started off with 2 GB to hold these volumes but now need 9 GB. We means we need at least 7 GB more. Adding a 10 GB hard drive will be enough with a little extra left over. (NOTE: This was an arbitrary number because I mainly want to show you how to add an additional hard drives to the system)

    Here is a graphical representation of what needs to be accomplished:



    If we were to type df -h right now, we should see something like this:

    Code:
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/LVG-root  3.8G  912M  2.7G  26% /
    udev                  489M  4.0K  489M   1% /dev
    tmpfs                 200M  240K  199M   1% /run
    none                  5.0M     0  5.0M   0% /run/lock
    none                  498M     0  498M   0% /run/shm
    /dev/sda1             179M   25M  145M  15% /boot
    /dev/mapper/LVG-bak   473M   23M  427M   5% /bak
    /dev/mapper/LVG-var   473M  261M  189M  59% /var
    /dev/mapper/LVG-tmp   473M   23M  427M   5% /tmp
    /dev/mapper/LVG-srv   473M   23M  427M   5% /srv
    Since I am running VMware, adding additional space is a snap. However, I will add it in such a way that Ubuntu will see 1 drive added to the system just as if we were to add a physical drive to a physical server.

    1. Shutdown and power off the server by typing shutdown -P now
    2. In the vSphere client, right-click the Virtual Machine and choose Edit Settings.
    3. On the hardware tab, click the Add button and select Hard Disk. Click Next, choose "Create a new virtual disk", click Next, set the size to 10 GB, click Next, Next, Finish. Click OK to close the settings and allow VMware to process the changes.


    Collect information about the newly added drive.

    1. Start the Ubuntu server and connect using PuTTY.
    2. Login with your administrator account. At the $ prompt, temporarily grant yourself super user privilages by typing sudo su {ENTER} and then provide the administrator password (myadminpass).
    3. Type pvdisplay which should show something similar to this:
      Code:
        --- Physical volume ---
        PV Name               /dev/sda5
        VG Name               LVG
        PV Size               7.81 GiB / not usable 3.00 MiB
        Allocatable           yes
        PE Size               4.00 MiB
        Total PE              1999
        Free PE               94
        Allocated PE          1905
        PV UUID               HbQisN-2jhS-FGGG-t5aF-IuMZ-mEDQ-iQNfwx
      The important bits of info here are the PV Name and VG Name for our existing configuration.
    4. Type fdisk -l which should show something similar to this (however I abbreviated it to show just the important parts):
      Code:
      Disk /dev/sda: 8589 MB, 8589934592 bytes
         Device Boot      Start         End      Blocks   Id  System
      /dev/sda1   *        2048      391167      194560   83  Linux
      /dev/sda2          393214    16775167     8190977    5  Extended
      /dev/sda5          393216    16775167     8190976   8e  Linux LVM
      
      
      Disk /dev/sdb:  10.7 GB, 10737418240 bytes
      Disk /dev/sdb doesn't contain a valid partition table
      The important bits of info here is the device path for the new drive which I highlighted in red.


    Prepare the first drive (/dev/sdb) to be used by the LVM

    Type the following:
    Code:
    fdisk /dev/sdb
    n (Create New Partition)
    p (Primary Partition)
    1 (Partition Number)
    {ENTER} (use default for first cylinder)
    {ENTER} (use default for last cylinder)
    t (Change partition type)
    8e (Set to Linux LVM)
    p (Preview how the drive will look)
    w (Write changes)
    If we type fdisk -l, we now see /dev/sdb1 which is a Linux LVM partition.

    Type the following to create physical volume:
    Code:
    pvcreate /dev/sdb1
    Now add the physical volume to the volume group (LVG) by typing the following:
    Code:
    vgextend LVG /dev/sdb1
    Now that the space has been added to the logical volume group called LVG, we can now allocate that space to grow the logical volumes.

    To get a list of volume paths to use in the next commands, type lvscan to show your current volumes and their sizes.

    Type the following to grow each volume by a specified amount (the number after the plus sign):
    Code:
    
    lvextend -L+3500M /dev/LVG/bak
    lvextend -L+500M /dev/LVG/srv
    lvextend -L+1500M /dev/LVG/tmp
    lvextend -L+1500M /dev/LVG/var
    
    or you can specify the exact size by excluding the plus sign and specifying the end-result size you want:
    Code:
    
    lvextend -L4G /dev/LVG/bak
    lvextend -L1G /dev/LVG/srv
    lvextend -L2G /dev/LVG/tmp
    lvextend -L2G /dev/LVG/var
    
    To see the new sizes, type lvscan

    The last thing to do now is the actual growth of the file systems. We want to grow the existing file systems but only to the size we mentioned earlier so we do not take up all the space in the volume...we want room to grow in the future so we have time to order and install new drives when needed.
    Code:
    
    resize2fs /dev/LVG/bak 2G
    resize2fs /dev/LVG/tmp 1G
    resize2fs /dev/LVG/var 1G
    
    NOTE: The srv file system is already at the desired 500 MB size so no resize was necessary.

    If we need to increase space in /var at a later point, we can issue the following command without any downtime (we will automate this in a nifty script later):

    Code:
    resize2fs /dev/LVG/var 1536MB
    We could continue to increase this particular file system all the way until we reach the limit of the volume which is 2 GB at the moment.

    Remember, df -h will tell you the size of the file system and lvscan will tell you the size of the volumes where the file systems live in.

    If we were to type df -h right now, we should see something like this:

    Code:
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/LVG-root  3.8G  912M  2.7G  26% /
    udev                  489M  4.0K  489M   1% /dev
    tmpfs                 200M  244K  199M   1% /run
    none                  5.0M     0  5.0M   0% /run/lock
    none                  498M     0  498M   0% /run/shm
    /dev/sda1             179M   25M  145M  15% /boot
    /dev/mapper/LVG-bak   2.0G   23M  1.9G   2% /bak
    /dev/mapper/LVG-var  1004M  261M  692M  28% /var
    /dev/mapper/LVG-tmp  1004M   23M  931M   3% /tmp
    /dev/mapper/LVG-srv   473M   23M  427M   5% /srv
    TIP: If you want to see everything in a specific block size, such as everything showing up in megabytes, you can use df --block-size m
    Last edited by LHammonds; May 27th, 2012 at 09:17 AM.

  5. #5
    Join Date
    Sep 2011
    Location
    Behind you!
    Beans
    1,690
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: My Notes for Installing Nagios on Ubuntu Server 12.04 LTS

    Configure Ubuntu for File Sharing

    This file sharing section is optional but can be handy if you need to swap files between the Linux server and a Windows machine.

    This documentation will utilize this share for passing pre-configured files (configs, scripts, etc.) to make it faster/easier during installation.


    1. Start the Ubuntu server and connect using PuTTY.
    2. Login with your administrator account. At the $ prompt, temporarily grant yourself super user privilages by typing sudo su {ENTER} and then provide the administrator password (myadminpass).
    3. Install Samba by typing aptitude -y install samba smbfs (NOTE: To share a folder with Windows, you just need the samba package, to connect to a Windows share, you need both samba and smbfs)
    4. Type the following commands:
      Code:
      
      cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
      mkdir -p /srv/samba/share
      chown nobody:nogroup /srv/samba/share/
      chmod 0777 /srv/samba/share
      
    5. Edit the configuration file by typing vi /etc/samba/smb.conf
    6. Change workgroup = WORKGROUP to workgroup = work (you are using the domain alias)
    7. Change:
      Code:
      #   security = user
      to:
      Code:
         security = user
    8. Add the following section to the end of the file:
      Code:
      [share]
      comment = Ubuntu File Server Share
      path = /srv/samba/share
      browsable = yes
      guest ok = yes
      read only = no
      create mask = 0755
    9. Save and exit the file.
    10. Restart the samba services to utilize the new configuration by typing:
      Code:
      restart smbd
      restart nmbd
    11. You should now be able to click Start --> Run and type \\srv-nagios or \\192.168.107.21 {ENTER} and see an explorer window with a Share folder. Drag-n-drop a file into the Share folder. If it worked, it will not display an error message and you should be able to view it from the server by typing ls -l /srv/samba/share/
    12. Shutdown and power off the server by typing shutdown -P now
    13. In VM menu, select VM --> Snapshot --> Take Snapshot. Give it a name like STEP 2 and description of Ubuntu Server 12.04 LTS, File share configured, Static IP: 192.168.107.21. The Snapshot Manager should now have a nice hierarchy of snapshots (STEP 1 --> STEP 2 --> You are here)


    Configure Windows Remote Mount Point

    The remote offsite location is a Windows 2008 server that has a vast amount of hard drive space and currently backs up other servers.

    Part of the backup process will be to write files to a mounted folder to a Windows share.

    First, let's document the variables for this solution below and highlight them in red throughout the document for easy identification.

    The values below are merely samples which you need to change in order to match your environment:

    Windows AD Domain Name: work
    Windows Server Name: SRV-Backup
    Windows Server IP: 192.168.107.218
    Windows Share Name: nagios
    Windows Physical Share Location: D:\Nagios\
    Windows Share ID: myshare
    Windows Share Password: mysharepass

    Create a share on a Windows 2008 server


    1. In Windows Explorer, right-click on the D:\Nagios folder and select Properties
    2. Click the Sharing tab
    3. Click the Advanced Sharing button
    4. Place a checkmark beside Share this folder
    5. Change the Share name to nagios
    6. Set the Comment to Nagios Backup
    7. Click the Permissions button
    8. Select Everyone and click the Remove button
    9. Click the Add button
    10. Type in your share account: work\myshare and click the Check Names button, click OK
    11. Place a checkmark for Allow Full Control and click OK, click OK, click OK
    12. Create a text file in the root of the shared folder called "online.txt" and you might want to add some text inside saying to never delete this file because it is used (will be) by a backup script. Probably a good idea to make it read-only as well. Example: [B]D:\Nagios\online.txt[B]


    Create an NFS mount to the Windows 2008 server

    Connecting to a Windows share requires the samba and smbfs packages to be installed. If you do not have them, type aptitude -y install samba smbfs


    1. Login with your administrator account. At the $ prompt, temporarily grant yourself super user privilages by typing sudo su {ENTER} and then provide the administrator password (myadminpass).
    2. Type the following commands:
      Code:
      
      mkdir -p /mnt/backup
      chown root:root /mnt/backup
      chmod 0755 /mnt/backup
      echo "This file is used to tell if the mount is active or not" > /mnt/backup/offline.txt
      chown root:root /mnt/backup/offline.txt
      chmod 0444 /mnt/backup/offline.txt
      touch /etc/cifspw
      chmod 0600 /etc/cifspw
      echo -e "username=work\\myshare\npassword=mysharepass" >> /etc/cifspw
      
    3. Type vi /etc/hosts and add the following line anywhere in the file:
      Code:
      
      192.168.107.218    srv-backup
      
    4. At this point, you might want to type ping srv-backup to make sure you typed the right IP address as well as seeing a good response.
    5. To mount this system for backups, type the following command:
      Code:
      
      mount -t cifs //srv-backup/nagios /mnt/backup --options nouser,rw,nofail,noatime,noexec,credentials=/etc/cifspw
      
    6. To test it, type cp /etc/hosts /mnt/backup/hosts.txt and look on the Windows server and see if the file shows up. Then type rm /mnt/backup/hosts.txt and verify that the file was deleted on the windows server.
    7. This would also be a good time to verify that you can see the "online.txt" file that will be used by the backup script. Type ls -l /mnt/backup/*.txt
    8. To dismount the windows share, type the following command:
      Code:
      
      umount /mnt/backup
      


    The scripts will call a common mount and unmount function to connect to this share only when needed.

    However, if you would rather have it mounted all the time (even after a reboot), do the following (but remember to not use the mount/umount functions in the scripts later):


    1. Type vi /etc/fstab and add the following line at the bottom of the file:
      Code:
      //srv-backup/mysql    /mnt/backup    cifs nouser,rw,nofail,noatime,noexec,credentials=/etc/cifspw    0    0
    2. Type mount -a and if it does not spew out any error messages, it will quietly mount the share.
    3. To test it, type cp /etc/hosts /mnt/backup/hosts.txt and look on the Windows server and see if the file shows up. Then type rm /mnt/backup/hosts.txt and verify that the file was deleted on the windows server.
    4. If you need to unmount it, simply type umount /mnt/backup and it will remain unmounted until you reboot. To make it permanent, you need to remove the line you added in the /etc/fstab file.
    Last edited by LHammonds; May 27th, 2012 at 09:18 AM.

  6. #6
    Join Date
    Sep 2011
    Location
    Behind you!
    Beans
    1,690
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: My Notes for Installing Nagios on Ubuntu Server 12.04 LTS

    Nagios Prerequisites


    1. Install the required programs:
      Code:
      
      aptitude -y install build-essential apache2 php5-gd wget wibgd2-xpm libgd2-xpm-dev libapache2-mod-php5
      
    2. Type vi /etc/apache2/apache2.conf and add the following line:
      Code:
      
      DirectoryIndex index.html index.php index.cgi
      
    3. Restart Apache by typing: /etc/init.d/apache2 restart
    4. Create users and groups:
      Code:
      
      mkdir -p /etc/nagios /var/nagios
      groupadd --system --gid 9000 nagios
      groupadd --system --gid 9001 nagcmd
      adduser --system --gid 9000 --home /usr/local/nagios nagios
      usermod --groups nagcmd nagios
      usermod --append --groups nagcmd www-data
      chown nagios:nagios /usr/local/nagios /etc/nagios /var/nagios
      



    Build and Install Nagios from Source


    • Download Nagios software (NOTE: You can use newer links once new versions become available):
      Code:
      
      cd /usr/local/src
      wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz
      
    • Build and install Nagios Core:
      Code:
      
      tar -xzvf /usr/local/src/nagios-3.4.1.tar.gz
      cd /usr/local/src/nagios
      ./configure --sysconfdir=/etc/nagios --localstatedir=/var/nagios --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd --with-mail=/usr/bin/sendemail
      make all
      make install
      make install-init
      make install-config
      make install-commandmode
      
    • Edit the commands by typing vi /etc/nagios/objects/commands.cfg to change both sendemail references to match the correct sendemail syntax:
      Code:
      define command{
       command_name    notify-host-by-email
       command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/sendemail -s srv-mail:25 -f "admin <admin@nagios.server>" -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **"
      }
      
      define command{
      command_name    notify-service-by-email
      command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/sendemail -s srv-mail:25 -f "admin <admin@nagios.server>" -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **"
      }
    • Save and close commands.cfg
    • Edit the contacts by typing vi /etc/nagios/objects/contacts.cfg and change the following:
      Code:
      define contact{
          contact_name     nagiosadmin             ; Short name of user
          use              generic-contact         ; Inherit default values from generic-contact template (defined above)
          alias            John Doe                ; Full name of user
          email            John.Doe@mydomain.com   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
      }
    • Save and close contacts.cfg
    • Type the following:
      Code:
      
      cd /usr/local/src/nagios
      make install-webconf
      
    • Set the nagiosadmin password to mynagiospassword by typing the following:
      Code:
      
      htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
      /etc/init.d/apache2 reload
      
    • Ensure Nagios can execute by typing chmod +x /etc/init.d/nagios (NOTE: On this version of Ubuntu and Nagios, it is already set correctly)
    • Type the following to avoid startup problems: (NOTE: This is not documented anywhere, it is just my trial, error and observation)
      Code:
      
      mkdir -p /usr/local/nagios/var/spool/checkresults
      chown nagios:nagios /var/nagios/spool/checkresults
      chown nagios:nagios /var/nagios/spool
      chown nagios:nagios /var/nagios
      
    • Ensure Nagios is started whenever the system boots up:
      Code:
      
      /usr/sbin/update-rc.d -f nagios defaults 99
      ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
      
    • Check your Nagios configuration file for errors. Look for errors in red.
      Code:
      /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg
    • NOTE TO SELF: I need to generate (and document) an SSL certificate to enable SSL to protect the password during authentication. Self-Signed Certs
    • Start Nagios for the 1st time.
      Code:
      /etc/init.d/nagios start
    • Access the web-based administration utility at http://192.168.107.21/nagios/ (use nagiosadmin for the ID and mynagiospassword for the password)


    NOTE: The Nagios server is now up-and-running but doing absolutely nothing. We need plugins to actually make it do something so we will install a base plugin pack. However, we will eventually need to get other plugins and maybe write our own in order to monitor everything we want.
    Last edited by LHammonds; May 27th, 2012 at 09:19 AM.

  7. #7
    Join Date
    Sep 2011
    Location
    Behind you!
    Beans
    1,690
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: My Notes for Installing Nagios on Ubuntu Server 12.04 LTS

    Nagios Plugin Prerequisites

    Nagios Plugin Requirements for check_snmp:
    Code:
    perl -MCPAN -e 'install Net::SNMP'
    Configure as much as possible automatically? yes
    aptitude -y install snmp
    Requirements for check_mysql: (NOTE: For my site, this is not necessary because I will run it locally on MySQL server)
    Code:
    aptitude -y install libmysqlclient-dev
    Requirements for check_nrpe:
    Code:
    aptitude -y install libssl-dev
    Nagios Plugins

    Download, build and install Nagios plugins (NOTE: You can use newer links once new versions become available):
    Code:
    
    cd /usr/local/src
    wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
    tar xzf /usr/local/src/nagios-plugins-1.4.15.tar.gz
    cd /usr/local/src/nagios-plugins-1.4.15
    ./configure --sysconfdir=/etc/nagios --localstatedir=/var/nagios --with-nagios-user=nagios --with-nagios-group=nagios
    make
    make install
    
    Download, build and install NRPE plugin
    Code:
    
    cd /usr/local/src
    wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
    tar xzf /usr/local/src/nrpe-2.13.tar.gz
    cd /usr/local/src/nrpe-2.13
    ./configure --sysconfdir=/etc/nagios --libexecdir=/usr/local/nagios/libexec --prefix=/usr/local/nagios --localstatedir=/var/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-nrpe-user=nagios --with-nrpe-group=nagios --enable-ssl=yes --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu
    make all
    make install-plugin
    
    Verify that Plugins are Working!

    For all the plugins we intend on using, we need to verify they are working before trying to integrate them into Nagios. However, not all plugins will work without first configuring the target to be monitored.

    Ping an IP address you know to be active:
    Code:
    
    /usr/local/nagios/libexec/check_icmp -H 192.168.107.20
    
    Check for an HTTP reply from a web server:
    Code:
    
    /usr/local/nagios/libexec/check_http -H 192.168.107.20
    
    Check for a response from an HP LaserJet printer:
    Code:
    
    /usr/local/nagios/libexec/check_hpjd -H 192.168.107.51 -C public
    
    Check the uptime of a router via SNMP:
    Code:
    
    /usr/local/nagios/libexec/check_snmp -H 192.168.107.1 -C public -o sysUpTime.0
    
    NOTE: For whatever reason, this command hangs on me. Not sure what I did wrong this time but I'll track it down, fix it and update these dox.

    Check a MySQL server (if on local host):
    Code:
    
    /usr/local/nagios/libexec/check_mysql -H 192.168.107.20 -P 3306 -u mysqlid -p mysqlpassword
    
    NOTE: This will fail if you do not configure the MySQL server 1st. However, you might want to run the MySQL command remotely via NRPE instead.
    Last edited by LHammonds; May 28th, 2012 at 12:49 AM.

  8. #8
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: My Notes for Installing Nagios on Ubuntu Server 12.04 LTS

    Howdy!

    This is a great How-To. The only suggestion I would have is to make the default position to use sudo rather than "enabling" the root account.By all means explain there is a different way of doing things but as this will be a great resource to people with less understanding, it should stick as closely as possible to the established guidelines for this site.

    Please see http://ubuntuforums.org/showthread.php?t=1486138 for a little more info, I think you may be venturing out on thin ice here and the rest of the How-To is excellent, I'd hate to see it get into bother for this.

    Kindest regards,
    Stefan
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

  9. #9
    Join Date
    Sep 2011
    Location
    Behind you!
    Beans
    1,690
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: My Notes for Installing Nagios on Ubuntu Server 12.04 LTS

    Quote Originally Posted by spynappels View Post
    Howdy!

    This is a great How-To. The only suggestion I would have is to make the default position to use sudo rather than "enabling" the root account.By all means explain there is a different way of doing things but as this will be a great resource to people with less understanding, it should stick as closely as possible to the established guidelines for this site.

    Please see http://ubuntuforums.org/showthread.php?t=1486138 for a little more info, I think you may be venturing out on thin ice here and the rest of the How-To is excellent, I'd hate to see it get into bother for this.

    Kindest regards,
    Stefan
    I already stated as a NOTE before installing Ubuntu that using the root account was just for the initial setup and recommended to switch back to using sudo once setup is complete. However, I did not document the command...which now has the command listed. The article you linked me to is mainly pointed towards desktop / GUI interfaces and incorrectly using root to fix problems to run the GUI...thus making the normal use of the system as the root user. This is NOT even close to what I am doing with this documentation.

    That article also mentions the concern of an "influx of new users" but I'd be willing to bet it is in regard to the desktop usage of Ubuntu. The server crowd is significantly smaller. And the documentation for what I am doing will be even smaller than that. I would be interested to see a show of hands as to how many people are actually setting up their server and following what I have written. Of the niche crowd that would actually read all of this, they would probably only use bits and pieces. But I still don't see how I am using the root account as being a problem...even for production systems. Again, these how-to's that I write are all about the initial setup of a server (which by definition means they are not in "production"). I see no problem with any of these setups eventually becoming production systems.

    I seriously doubt the ice is that thin regarding that topic and this thread.

    However, if these forums require me to re-write them using sudo for everything, I would simply request that the threads I have created to be deleted and I will post them elsewhere. I have no intention of documenting how I will not be setting up a server. If someone would like to make a copy and re-write it using sudo for everything, they can be my guest. I'm just not interested in doing it that way and feel it would be a waste of my time.

    LHammonds

  10. #10
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: My Notes for Installing Nagios on Ubuntu Server 12.04 LTS

    I'm sorry my (well meant) comments seem to have upset you, I was saying that it is an excellent how-to, and was simply offering a suggestion as to how it could be done in a way that most matches the recommended setup according to the article I linked to.

    A rewrite is not required, I was suggesting an alternative which did not require setting up a root password,
    Code:
    sudo su
    instead of
    Code:
    su root
    Anyway, enjoy using Linux, it is always good to have more than one way of doing things.
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

Page 1 of 6 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •