lost and found ( for me ? )

Showing posts with label snmp. Show all posts
Showing posts with label snmp. Show all posts

Ubuntu 12.04: monitor system resource with netmrg

Here are trial and error logs when installing netmrg.

about netmrg
http://www.netmrg.net/

# tail -1 /etc/lsb-release ;uname -ri
DISTRIB_DESCRIPTION="Ubuntu 12.04.4 LTS"
3.2.0-58-virtual x86_64



The installation procedures are:

- install mysql and create a database for netmrg
- install net-snmp and MIB files
- install netmrg and configure it

at first, install mysql server and run mysql server before installing netmrg
# apt-get install mysql-server

confirm that mysql is running.
# pgrep mysql
4875
5370

then, install netmrg.
# apt-get install netmrg
during the installation, you will be asked for the database name for netmrg.
I use “netmrg” as database name which is default setting.

confirm “netmrg” database exits.
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 65
Server version: 5.5.34-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| netmrg             |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

mysql> quit
Bye

edit apache2.conf
# tail -1 /etc/apache2/apache2.conf
Include /etc/netmrg/netmrg.conf

start httpd.
# apachectl start

access to http:// IP /netmrg
The default login is admin and the default password is nimda


collect data every 5 minutes
# pwd
/etc/cron.d

# cat netmrg
#
# Regular cron jobs for the netmrg package
#
*/5 * * * * netmrg test -x /usr/bin/netmrg-gatherer && /usr/bin/netmrg-gatherer -l31

how can I manage my ubuntu box?
Seen from documents (http://wiki.netmrg.net/wiki/Basic_Tutorial), need to add the device which I would like to monitor.

Before adding the device, install net-snmp.
# apt-get install snmp snmpd

edit /etc/snmp/snmpd.conf
# egrep -v ^# /etc/snmp/snmpd.conf | grep -v ^$ | grep -v "#"
view   systemonly  included   .1
rocommunity public  localhost
rocommunity public  default    -V systemonly
rouser   authOnlyUser
sysLocation    Sitting on the Dock of the Bay
sysContact     Me <me@example.org>
sysServices    72
proc  mountd
proc  ntalkd    4
proc  sendmail 10 1
disk       /     10000
disk       /var  5%
includeAllDisks  10%
load   12 10 5
trapsink     localhost public
iquerySecName   internalUser
rouser          internalUser
defaultMonitors          yes
linkUpDownNotifications  yes
extend    test1   /bin/echo  Hello, world!
extend-sh test2   echo Hello, world! ; echo Hi there ; exit 35
master          agentx

restart snmpd
# service snmpd restart

issue snmpbulkwalk to check you can get information.
# snmpbulkwalk -v 2c -c public 127.0.0.1 . | head -3
iso.3.6.1.2.1.1.1.0 = STRING: "Linux ubuntu 3.2.0-58-virtual #88-Ubuntu SMP Tue Dec 3 17:58:13 UTC 2013 x86_64"
iso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.8072.3.2.10
iso.3.6.1.2.1.1.3.0 = Timeticks: (4057) 0:00:40.57

On the netmrg GUI, add the device.

Admin tab -> Add

clieck group “HOME” -> Add in the Monitored Devices section -> Create a new device


create a new sub device
sub-device type: Group



add graph you want to monitor


can’t see the graph.
Seen from the GUI, SNMP failed..


rrd files are stored under /var/lib/netmrg/rrd directory for sure.
# pwd
/var/lib/netmrg/rrd

# ls
mon_27.rrd  mon_29.rrd  mon_31.rrd  mon_33.rrd  mon_35.rrd  mon_37.rrd
mon_28.rrd  mon_30.rrd  mon_32.rrd  mon_34.rrd  mon_36.rrd  zero.rrd

Googling “netmrg snmp failed”, it seems that I need to install MIB files.
# apt-get install snmp-mibs-downloader
# download-mibs

edit /etc/snmp/snmp.conf
# egrep -v ^# /etc/snmp/snmp.conf
mibs +ALL

okay.




SNMP MIB browser for Windows : Unbrowse SNMP

about Unbrowse SNMP
http://www.unleashnetworks.com/products/unbrowse-snmp.html

The installation is very easy.
download setup_unbrowse_R_1_6_0_1328.msi and just click it.
I’ve installed it on Windows 7 32bit ver.





when compiling private MIBs
File -> Add MIBs



SNMP MIB Browser : iReasoning MIB browser Free edition

about iReasoning MIB Browser
http://ireasoning.com/mibbrowser.shtml

[ install MIB browser on Ubuntu 12.10 ]

root@ubuntu-1:~# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 12.10"
root@ubuntu-1:~# uname -ri
3.5.0-25-generic x86_64


download free edition
mibbrowser.zip


unzip
# unzip mibbrowser.zip
# cd ireasoning/mibbrowser
# ls
README.txt                   browser.command  lib          snmpgetnext.sh  trapdconsole.sh
THIRDPARTYLICENSEREADME.txt  browser.sh       license.txt  snmpset.sh
audio                        config           log          snmpwalk.sh
bin                          docs             mibs         trap.sh
browser.app                  images           snmpget.sh   trapd.sh

# cat README.txt
               iReasoning MIB Browser

browser.bat:     script for launching MIB browser on windows.
browser.sh:      script for launching MIB browser on UNIX.
browser.commad:  script for launching MIB browser on OS X.


start MIB browser
Please not that java is required to run MIB browser.
# /usr/bin/java -version
java version "1.7.0_15"
OpenJDK Runtime Environment (IcedTea7 2.3.7) (7u15-2.3.7-0ubuntu1~12.10.1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

# ./ browser.sh



you can load MIB files up to 10 MIB files.
File -> Load MIBs




It’s very helpful for me to understand MIBs structure.

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..