lost and found ( for me ? )

Showing posts with label cacti. Show all posts
Showing posts with label cacti. Show all posts

cacti : create a custom template for SNMP monitoring ( SNMP Data Query )

Here’s an example of how to create a custom template to monitor the remote box’s storage info.

just referred to http://docs.cacti.net/manual:088:3a_advanced_topics.3b_snmp_data_query_walkthrough#snmp_data_query_walkthrough
http://forums.cacti.net/viewtopic.php?t=11647

I am not familiar with cacti. just follow the instructions.

many thanks!

cacti ( ubuntu ) – node ( centos )

[ on the cacti box ]

root@ubuntu12-04-vm4:/etc# apt-cache policy cacti
cacti:
 Installed: 0.8.7i-2ubuntu1
 Candidate: 0.8.7i-2ubuntu1
 Version table:
*** 0.8.7i-2ubuntu1 0
       500 http://jp.archive.ubuntu.com/ubuntu/ precise/universe amd64 Packages
       100 /var/lib/dpkg/status


retrieve hdStorageTable
# snmptable -c public -v 2c 192.168.10.223 HOST-RESOURCES-MIB::hrStorageTable
SNMP table: HOST-RESOURCES-MIB::hrStorageTable

hrStorageIndex                        hrStorageType  hrStorageDescr hrStorageAllocationUnits hrStorageSize hrStorageUsed hrStorageAllocationFailures
             1 HOST-RESOURCES-MIB::hrStorageTypes.2 Physical memory               1024 Bytes       1020588        180320                           ?
             3 HOST-RESOURCES-MIB::hrStorageTypes.3  Virtual memory               1024 Bytes       3117732        180320                           ?
             6 HOST-RESOURCES-MIB::hrStorageTypes.1  Memory buffers               1024 Bytes       1020588          9204                           ?
             7 HOST-RESOURCES-MIB::hrStorageTypes.1   Cached memory               1024 Bytes        104948        104948                           ?
            10 HOST-RESOURCES-MIB::hrStorageTypes.3      Swap space               1024 Bytes       2097144             0                           ?
            31 HOST-RESOURCES-MIB::hrStorageTypes.4               /               4096 Bytes       4644287        619762                           ?
            35 HOST-RESOURCES-MIB::hrStorageTypes.4        /dev/shm               4096 Bytes        127573             0                           ?

# snmpwalk -c public -v 2c -On 192.168.10.223 HOST-RESOURCES-MIB::hrStorageTable|more
.1.3.6.1.2.1.25.2.3.1.1.1 = INTEGER: 1
.1.3.6.1.2.1.25.2.3.1.1.3 = INTEGER: 3
.1.3.6.1.2.1.25.2.3.1.1.6 = INTEGER: 6
.1.3.6.1.2.1.25.2.3.1.1.7 = INTEGER: 7
.1.3.6.1.2.1.25.2.3.1.1.10 = INTEGER: 10
.1.3.6.1.2.1.25.2.3.1.1.31 = INTEGER: 31
.1.3.6.1.2.1.25.2.3.1.1.35 = INTEGER: 35
.1.3.6.1.2.1.25.2.3.1.2.1 = OID: .1.3.6.1.2.1.25.2.1.2
.1.3.6.1.2.1.25.2.3.1.2.3 = OID: .1.3.6.1.2.1.25.2.1.3


Index Base is .1.3.6.1.2.1.25.2.3.1.1.

create xml file.
on the cacti box , go to <path to cacti>/resource/snmp_queries directory
root@ubuntu12-04-vm4:~# cd /usr/share/cacti/resource/snmp_queries
root@ubuntu12-04-vm4:/usr/share/cacti/resource/snmp_queries#

root@ubuntu12-04-vm4:/usr/share/cacti/resource/snmp_queries# cat hrStorageTable.xml
<interface>
       <name>Get hrStoragedTable Information</name>
       <description>Get SNMP based Partition Information out of hrStorageTable</description>
       <index_order>hrStorageDescr:hrStorageIndex</index_order>
       <index_order_type>numeric</index_order_type>
       <oid_index>.1.3.6.1.2.1.25.2.3.1.1</oid_index>

       <fields>
               <hrStorageIndex>
                       <name>Index</name>
                       <method>walk</method>
                       <source>value</source>
                       <direction>input</direction>
                       <oid>.1.3.6.1.2.1.25.2.3.1.1</oid>
               </hrStorageIndex>
       </fields>
</interface>


on the cacti GUI , go to Data Queries ( GUI -> console -> collection methods -> Data Queries )


click Add and register “hrStorageTable.xml”



go to the device and add “SNMP – hrStoragedTable”

click “Verbose Query”
nnn error.



edit xml ( delete “Index_order” )

# cat hrStorageTable.xml
<interface>
       <name>Get hrStoragedTable Information</name>
       <description>Get SNMP based Partition Information out of hrStorageTable</description>
       <index_order_type>numeric</index_order_type>
       <oid_index>.1.3.6.1.2.1.25.2.3.1.1</oid_index>

       <fields>
               <hrStorageIndex>
                       <name>Index</name>
                       <method>walk</method>
                       <source>value</source>
                       <direction>input</direction>
                       <oid>.1.3.6.1.2.1.25.2.3.1.1</oid>
               </hrStorageIndex>
       </fields>
</interface>


Okay.



let’s add storage description
edit xml file

# cat hrStorageTable.xml
<interface>
  <name>Get hrStoragedTable Information</name>
  <description>Get SNMP based Partition Information out of hrStorageTable</description>
  <index_order_type>numeric</index_order_type>
  <oid_index>.1.3.6.1.2.1.25.2.3.1.1</oid_index>

  <fields>
     <hrStorageIndex>
        <name>Index</name>
        <method>walk</method>
        <source>value</source>
        <direction>input</direction>
        <oid>.1.3.6.1.2.1.25.2.3.1.1</oid>
     </hrStorageIndex>
     <hrStorageType>
        <name>Type</name>
        <method>walk</method>
        <source>value</source>
        <direction>input</direction>
        <oid>.1.3.6.1.2.1.25.2.3.1.2</oid>
     </hrStorageType>
     <hrStorageDescr>
        <name>Description</name>
        <method>walk</method>
        <source>value</source>
        <direction>input</direction>
        <oid>.1.3.6.1.2.1.25.2.3.1.3</oid>
     </hrStorageDescr>
     <hrStorageAllocationUnits>
        <name>Allocation Units (Bytes)</name>
        <method>walk</method>
        <source>value</source>
        <direction>input</direction>
        <oid>.1.3.6.1.2.1.25.2.3.1.4</oid>
     </hrStorageAllocationUnits>
  </fields>
</interface>



go to “create graphs for this host”




edit the xml to get output.

# cat hrStorageTable.xml
<interface>
  <name>Get hrStoragedTable Information</name>
  <description>Get SNMP based Partition Information out of hrStorageTable</description>
  <index_order_type>numeric</index_order_type>
  <oid_index>.1.3.6.1.2.1.25.2.3.1.1</oid_index>

  <fields>
     <hrStorageIndex>
        <name>Index</name>
        <method>walk</method>
        <source>value</source>
        <direction>input</direction>
        <oid>.1.3.6.1.2.1.25.2.3.1.1</oid>
     </hrStorageIndex>
     <hrStorageDescr>
        <name>Description</name>
        <method>walk</method>
        <source>value</source>
        <direction>input</direction>
        <oid>.1.3.6.1.2.1.25.2.3.1.3</oid>
     </hrStorageDescr>
     <hrStorageAllocationUnits>
        <name>Allocation Units (Bytes)</name>
        <method>walk</method>
        <source>value</source>
        <direction>input</direction>
        <oid>.1.3.6.1.2.1.25.2.3.1.4</oid>
     </hrStorageAllocationUnits>
     <hrStorageSize>
        <name>Total Size (Units)</name>
        <method>walk</method>
        <source>value</source>
        <direction>output</direction>
        <oid>.1.3.6.1.2.1.25.2.3.1.5</oid>
     </hrStorageSize>
     <hrStorageUsed>
        <name>Used Space (Units)</name>
        <method>walk</method>
        <source>value</source>
        <direction>output</direction>
        <oid>.1.3.6.1.2.1.25.2.3.1.6</oid>
     </hrStorageUsed>
  </fields>
</interface>


define the data template

go to “data template”
click Add







add data source “hrStorageUsed” as well.

click “save”

define the graph template
Templates -> Graph templates
click “create”




click “add”









Data Queries -> SNMP – hrStoragedtable


check “hrStorageSize” and “hrStorageUsed”

create graphs for this host





graph




nnn , it’s difficult for me to define custom templates..

cacti : monitor remote hosts via SNMP



centos6 ( remote host ) --- ubuntu12.04 ( cacti box )

assume you have finished installing cacti and configuring initial setup.

[ configure the remote host ( centos ) ]

install net-snmp

# yum install net-snmp net-snmp-utils


configure snmpd.conf to accept snmp requests from remote hosts.
# egrep -v ^# /etc/snmp/snmpd.conf | grep -v ^$
com2sec notConfigUser  default       public
group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c           notConfigUser
view    systemview    included   .1
access  notConfigGroup ""      any       noauth    exact  systemview none none
com2sec any any     public
group MyROGroup  any        mynetwork
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
dontLogTCPWrappersConnects yes


on the cacti box , confirm you can receive snmp replies from the centos box
# snmpbulkwalk -v2c -c public 192.168.10.223 system -m all
SNMPv2-MIB::sysDescr.0 = STRING: Linux centos6-64-vm1.localdomain 2.6.32-279.22.1.el6.x86_64 #1 SMP Wed Feb 6 03:10:46 UTC 2013 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-TC::linux
DISMAN-EXPRESSION-MIB::sysUpTimeInstance = Timeticks: (181129) 0:30:11.29
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: centos6-64-vm1.localdomain
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (3) 0:00:00.03
<snip>


[ configure cacti box ]

add the remote device
console -> create graphs -> create new host




enter the remote host information and then click “create”




click “create graphs for this host”






register graphs
console -> graph trees -> add




enter name and click create




click Add



select the host and click create
configuration of collecting resources and outputting graphs are separated.
So you need to register graphs to collect info and register graphs to output those graphs.


graphs -> cnetos6064-vm1 -> Host: centos6-64-vm1
you will see resource graphs of the remote host ( centos6-64-vm1 )



install cacti on ubuntu 12.04 part1


root@ubuntu1204-vm5:~# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
root@ubuntu1204-vm5:~# uname -ri
3.2.0-38-generic x86_64


install cacti via apt-get
root@ubuntu1204-vm5:~# apt-get install cacti cacti-spine


The installation process is very easy.
just configure DB credentials and select front end GUI during the installation.
I selected Apache2 as front end GUI.

configuration files for cacti and Apache will be created automatically during installation process.
root@ubuntu1204-vm5:~# ls /etc/apache2/conf.d/
cacti.conf  charset  localized-error-pages  other-vhosts-access-log  security



start apache
root@ubuntu1204-vm5:~# apache2ctl start



after finishing installing cacti , launch browser and accesss to http:// cacti IP/cacti



click Next , select “Net Install”
click “Finish”

login

user : Admin
credentials : admin

change password










you can check how cacti collects stats
root@ubuntu1204-vm5:/usr/share/cacti/site/scripts# pwd
/usr/share/cacti/site/scripts

root@ubuntu1204-vm5:/usr/share/cacti/site/scripts# cat linux_memory.pl
#!/usr/bin/perl

open(PROCESS, "cat /proc/meminfo | grep -w $ARGV[0] |");
foreach (<PROCESS>) {
if ($_ =~ /($ARGV[0].*\s)(.*[0-9])( kB)/) {
print $2;
}
}
close(PROCESS);
root@ubuntu1204-vm5:/usr/share/cacti/site/scripts# cat /proc/meminfo | grep -w $ARGV[0]
Unevictable:           0 kB
Mlocked:               0 kB
Writeback:             0 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
HardwareCorrupted:     0 kB
AnonHugePages:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
root@ubuntu1204-vm5:/usr/share/cacti/site/scripts#


there are templates for some devices / processes .
http://docs.cacti.net/templates
http://www.debianhelp.co.uk/cactitemplates.htm

Of course , you can create your custom templates.