installing cacti on ubuntu

setting up cacti

apt-get install mysql-server 
apt-get install cacti

be sure to set a root-password in first step and write it down cause you’ll need it in the second one.

After you setup cacti, you can access it at http://your.host.name/cacti

The default-password is admin/admin and you are forced to change it on first login.

setting up snmpd on a server you like to monitor

On each device you like to monitor, you should install snmpd.

apt-get install snmpd

Then have to configure it so that cacti can access it. You need to:

  1. set up a communityname
  2. make snmpd listen to external interface
  3. use version1

I set up the same communityname on all devices and I allow all networks access to my snmpd which is ok, cause I’m behind a firewall. If you do this in the wild, please check how to additionally secure your snmpd-setup.

Here are my two files that control snmpd:

/etc/snmp/snmpd.conf has only one line here:

rocommunity  YOURCOMMUNITYNAME  0.0.0.0

and /etc/default/snmpd is allready fine, you only have to change one line (remove the IP-add)

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid'

you can test smtpd from your cacti-host (or any machine) with the following command, which should return no timeout, no error and no nothing, but a full bunch of data:

snmpwalk -Os -c YOURCOMMUNITYNAME -v 1 HOST.TO.TEST
or
snmpwalk -v3 -u USER -l authNoPriv -a md5 -A PASS   tng.goldfisch.at 

configuring cacti

Now you have setup snmpd and remembered your communityname, you can configure cacti to remotewatch this servers. There is a good howto at debuntu (page1 and page2 are about setting cacti up in oldfashioned way, but page3 is exactely what I needed).

So here is only the short comprehension of the above howto at debuntu.

  • each host/router/machine you want to monitor is called “device”. Each device can collect data in several graphs and each device can be located in the tree of cacti-graphs. so we start adding a new device for each host:
    1. devices -> add -> enter the description, hostname and choose ucd/net snmp host as template and snmp-version1 and dont forget to set the COMMUNITYNAME you choose during smtpd-setup above
    2. press create
    3. press create graphs for this host on the next page
    4. select the stuff you’d like to monitor under graph templates and the interface and graph-type (in/out-bits with total bandwidht is a good choice !!) for the interfaces you’d like to monitor
    5. press create
    6. goto graph-trees -> default and add a new host-type for each device:
      • parent-item : root
      • tree item-type : host
      • host : the device you like to add
      • graph-grouping-style : graph template
    7. press create

Note that you can add graphs within the graph-section but to me its much more simpler and intuitive to go to the devices-section, choose the device you like to add a graph to and press “create graphs for this host”



extending cacti

adding a 5-year graph

data-sources -> RRA is where you have to go. Create a new RRA by pressing ADD and enteriung the following data:

  • steps : 2016 - this means that assuming one step every 5 minutes (thats the cacti-poller) then 2016 steps is exactely one week and this is how often a new point is added to the graph
  • rows : 1000 - that many values are kept in the RRA-database.
  • timespan : 158112000 - this is 5 Years in seconds
  • name : Five Years (7 day - average)

Then you go to the data-templates and for each template you can add you new RRA in the multi-select-field of “associated rra’s”. From this second on you will see the new “5-year-graph” in every graph using this datasource

disk I/O

http://forums.cacti.net/about8777-0-asc-0.html is the place to start. There are 7 pages of discussions about things that work or dont work. It took me 5 days to get it working, so I try to make it shorter next time.

  1. check if your host even delivers snmp-DISKIO-data at all:
    snmpwalk -v1 -c COMMUNITYNAME  HOST-IP .1.3.6.1.4.1.2021.13.15.1.1.1

    should return a number of DISKIO-MIB-lines. If it does not you need to rebuild net-snmp with diskio-module. Modern ubuntus at least have diskio-module precompiled in their snmp-versions

  2. download diskio.tgz (all credits to gandalf and rodre in the above thread. I just put a copy of their work on my server.
  3. extract the archive
  4. put net-snmp_devio.xml to /usr/share/cacti/site/resource/snmp_queries/ or whereever your cacti-installation keeps its xml-query-files. (Its the same folder where net-snmp_disk.xml is located)
  5. import cacti_data_query_ucdnet_device_io.xml
  6. for each device you want to monitor diskIO you go to the device-menue and under “associated data-query” you choose and add the following data-query ucd/net Device I/O.
  7. still in the devive-menu you goto “create graphs for this host” and at the very bottom of the page !! you find all your devices and can select them and select graph-type (bytes read/write - average load - reads/writes) and create a load of graphs. If you have more then 20 devices then the next-button will help you to find the other ones :)
  8. wait 5 minutes to be sure the poller has already collected data before trying to view a graph or panicing on some debug-output that claims about missing rrd-files. They are created when the poller is executed first
  9. if things go wrong, then execute verbose query in the associcated data-queries-section of your device and same in other places like graph-managment and then read the 7 pages in the above mentioned link to possibly find your problem !!

multi-CPU graphing

start at http://forums.cacti.net/about11615-0-asc-150.html

  1. for each device that has multiple cpu’s you can add the associated query SNMP - Get Processor Information
  2. when you add graphs for this device (create graphs for this host) you have the data-query “SNMP - Get Processor Information” and can select the cpu’s you like to monitor and create a graph for each of them !!
  3. download the template that suites your situation: (all templates are simply copies from the above thread - all credits goes there and none to me !!)
  1. import the template in cacti
  2. in devices -> yourhost -> create graph for this host you can now add a graph “HOST MIB - MULT CPU utilization on X processor box”:
  3. on the next screen you will asked the index-value/type ... just click on save and its not over yet !!
  4. in graphs-managment locate the graph you just created and in supplemental “graph template data” you select the cpus you wish to graph in your multi-cpu-graph. This is most likely HOSTNAME - CPU Utilization - CPU0 (cpu), HOSTNAME - CPU Utilization - CPU1 (cpu) and so on ...
  5. and now the trick : you can now delete the inital graphs that you created in step2 but when asked be sure to keep the data-sources intact cause the multi-cpu-graph needs this sources !!
  6. and now you have finished the task of creating the graphs and can view your result. After a while you will notice that the graphs are somehow odd. The Average-Value is calculated wrong !!. Fixing is quite easy:
    • graph managment -> CDEFS : you will find a CDEF named Average All data sources - X sources (X depending on your setup and the file you imported before). You open it and will find a CDEF-items like Item #1 Custom String: a,b,+,2,/ or Item #1 Custom String: a,b,+,c+,d+,4,/. This is simply wrong. Delete this item and add the following three items:
      1. Item #1 Special Data Source: ALL_DATA_SOURCES_NODUPS
      2. Item #2 Custom String: 2/4/8 : depending on X above
      3. Item #3 Operator: /
    • When you now click on graph-managment and your graph, the graph will be drawn with the new values and you will see that its finde

advanced ping

standard ping-template might proove not cool enough, so you can install the advanced ping-template. It can ping of course icmp (the normal ping) but also any other tcp/udp-port (in case icmp is blocked or whatever). Additionally it will send a number of packages with no delay and measure the latency and the derivation of the latency. The average value is printed and the deriviation is printed in shades of grey. (smoke). Je bigger the smoke the bigger the deriviation of the latency.

The template was introduced in the [http://forums.cacti.net/viewtopic.php?t=10049|cacti-forum]. All credits there - especially to the creator *TheWitness* and no credits to me. I just did the copy-paste.

  • download and import the template cacti_graph_template_ping_advanced_ping_v1_3.xml (I didnt need to install any of the scripts mentioned and distributed in the original thread)
  • change /etc/cron.d/cacti and replace www-data with root in the poller-line (which should be the only line). This means that root will do the polling instead of www-data, which is very important, cause only root can construct the packages to do the actual advanced ping
  • thats it :)


 
knowwiki/howtos/cacti.txt · Last modified: 2009/05/06 00:16 by peter