Monitoring Linux and Windows hosts with snmp and Cacti

Gentoo, Linux, Windows, snmp Add comments

Download Video (989 KB)

SNMP is a communication specification that defines how management information is exchanged between network management applications and management agents.

Cacti is a resource monitoring software. It uses RRDtool to store data and the data is used create graphs. It also comes with fast poller to collect data from different resources simultaneously and has many user management features. The interface and management is very userfriendly that even a layman can get it working with less effort.

This video is about how to monitor Linux and Windows hosts with SNMP (2c version)  Cacti. Video tutorial consists from 4 parts:

Part 1. Setup snmpd on Linux host (3:00 min)
Part 2. Setup snmp service on Windows host (3:01 min)
Part 3. Setup Cacti (5:29 min)
Part 4. Graphing Linux and Windows hosts (5:14 min)

Installation steps.
Part 1. Setup snmpd on Linux host:

  1. Enable diskio MIB module for net-analyzer/net-snmp to enable to graph I/O statistics:
  2. echo net-analyzer/net-snmp diskio > /etc/portage/package.use

  3. Install snmpd:
  4. emerge -av net-snmp

  5. snmpd is installed, and now I have to tweak it a little bit:
  6. vi /etc/conf.d/snmpd

  7. If you want snmpd to listen on all interfaces, remove the 127.0.0.1:
  8. SNMPD_FLAGS="${SNMPD_FLAGS} -Lsd -Lf /dev/null 127.0.0.1"

  9. Configure snmpd:
  10. wget video4admin.com/stuff/snmpd.conf -O /etc/snmp/snmpd.conf
    vi /etc/snmp/snmpd.conf

  11. Start snmpd and add it to runlevel default:
  12. /etc/init.d/snmpd start && rc-update add snmpd default

  13. Test whether SNMP can read the system MIBs using the snmpwalk command:
  14. snmpwalk -v 2c -c cacti_com 127.0.0.1 system



Part 2. Setup snmp service on Windows host:

  1. Install snmp service. Go to Start->Run and type:
  2. appwiz.cpl @,2

    This will open Add/Remove Windows Components Wizard.

  3. In list find Management and Monitoring Tools and click Details. In new window check Simple Network Management Protocol and press OK. Press Next to begin installation of snmp service.
  4. Configure snmp service. Go to Start->Run and type:
  5. services.msc

    This will open System Services window.

  6. In list find SNMP service and double-click on it. Go to Agent Tab, fill the Contact and Location boxes and check all Service checkboxes.
    Go to Security Tab and edit the community name.
    Optional: you can specify from what hosts your windows machine can accept SNMP packets.
  7. Test snmp service. In video I test it from Gentoo box: read the system MIBs with snmpwalk command. Windows host ip is 172.16.50.179:

    snmpwalk -v 2c -c cacti_com 172.16.50.179 system

Part 3. Setup Cacti:

  1. Install Cacti:

    emerge -av cacti
    webapp-config -I -h localhost -d cacti-dir cacti 0.8.6j-r6

  2. Create the new cacti database:

    mysqladmin -p -u root create cacti_db

  3. Import the default cacti database:

    mysql -p cacti_db</var/www/localhost/htdocs/cacti-dir/cacti.sql

  4. Create a MySQL username and password for cacti:

    mysql -p -u root mysql

    mysql> GRANT ALL ON cacti_db.* TO cacti_user@localhost IDENTIFIED BY 'cacti db password';
    mysql> flush privileges;
    mysql> quit

  5. Edit cacti config file and modify the MySQL user, password and database for your cacti configuration:

    vi /var/www/localhost/htdocs/cacti-dir/include/config.php

    $database_default = "cacti_db";
    $database_hostname = "localhost";
    $database_username = "cacti_user";
    $database_password = "cacti db password";

  6. Point your browser to the IP address of the cacti system like http://localhost/cacti-dir/

    links http://localhost/cacti-dir/

    Verify all settings and paths and finish the installation. Exit links.

  7. Verify poller functionality:

    /usr/bin/php /var/www/localhost/htdocs/cacti-dir/poller.php

  8. Add poller line to /etc/crontab file:

    vi /etc/crontab

    */5 * * * * apache /usr/bin/php /var/www/localhost/htdocs/cacti-dir/poller.php > /dev/null 2>&1

  9. Also make sure that the user apache that runs poller.php has permission to create new files in cacti's 'rra/' and 'log/' directory:

    cd /var/www/localhost/htdocs/cacti-dir
    ls -ald rra log
    chown -R apache:apache rra/ log/



Part 4. Graphing Linux and Windows hosts:

  1. Go to main Cacti page and login as
    Username: admin
    Password: admin
  2. Create devices (this will be Linux and Windows hosts):
    Go to Management->Devices and select Add
    Fill fields Description, Hostname and SNMP Community. Don't forget to select Host Template and SNMP Version.
  3. Create graphs for Windows and Linux hosts:
    In Devices click on new-created Devices and select Create Graphs for this Host.
    You can follow instructions in video to graph Logged in Users, Processes, Disk Space on partitions, Virtual Memory, Physical Memory, Interface Statistics etc.
  4. Optional. You can add grapths to default tree.
    Go to Management->Graph Trees and select the Default Tree to edit it.
    On Tree Items by selecting Add you can add items to this tree as shown in video.
  5. You can view your new-created graphs by selecting the Graphs tab. In video you can see how the graphs changes after 1 hour.

3 Responses to “Monitoring Linux and Windows hosts with snmp and Cacti”

  1. Ion Says:

    cool video tutorial even a noob in linux can follow this tutorial a do very advanced monitoring :) ,
    thanks for your work and y think you will continue to write cool tutorials :)

  2. Andy Says:

    thanx, this tutorial was really helpful to me. I am new with cacti and the video's made it really clear how to set up monitoring both linux and windows.

  3. momentics Says:

    great.
    but it has several gotchas that probably pure nob will not be able to resolve…
    anyhow - thanks gents

Leave a Reply

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 6 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a

Entries RSS Comments RSS