Langkau ke kandungan utama

Asas install & setting MRTG pada Centos


Step # 1 : Make sure snmp server installed

Please note that snmpd configuration does not require using mrtg with remote network devices such as Routers and switches. If you just want mrtg graphs for router or switch then please refer to step # 4 (as all these devices comes preconfigured with snmpd software).
Run rpm commands query option to find out snmp server installed or not:
# rpm -qa | grep snmp
If snmp installed then please refer step # 2; otherwise snmp server and utils were not present and your need to install them using following steps (login as a root user):
(a) Visit rpmfind.net to get snmp server and utilities rpms. If you are fedora user then use yum command as follows to install it:
# yum install net-snmp-utils net-snmp
(b) If you are RHEL subscriber then use up2date command as follows to install:
#up2date -v -i net-snmp-utils net-snmp

Step # 2 : Determine if snmp server is running or not

Run 'ps' command to see if snmp server is running or not:
# ps -aux | grep snmp
Output:
root   5512  0.0  2.3  5872 3012 pts/0    S    22:04   0:00 /usr/sbin/snmpd
Alternatively, you can try any of the following two commands as well:
# lsof -i :199
Output:
COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME
snmpd   5512 root    4u  IPv4  34432       TCP *:smux (LISTEN)
OR try out netstat command:
# netstat -natv | grep ':199'
Output:
tcp        0      0 0.0.0.0:199             0.0.0.0:*               LISTEN
If you found service is running or listing on port 199 then please see step #3; otherwise start service using following command:
# service snmpd start
Make sure snmpd service starts automatically, when linux comes us (add snmpd service):
# chkconfig --add snmpd

Step # 3 : Make sure snmp server configured properly

Run snmpwalk utility to request for tree of information about network entity. In simple words query snmp server for your IP address (assigned to eth0, eth1, lo etc):
# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.0.3 = 2
If you can see your IP address then please proceed to step 4; else it is a time to configure snmp server as follows (by default RHEL and RH 8/9 are not configured for snmp server for security reason):

Configure SNMP

(1) Edit file /etc/snmp/snmpd.conf using text editor:
# vi /etc/snmp/snmpd.conf
Change/Modify line(s) as follows:
Find following Line:
com2sec notConfigUser  default       public
Replace with (make sure you replace 192.168.0.0/24 replace with your network IPs) following lines:
com2sec local     localhost           public
com2sec mynetwork 192.168.0.0/24      public
Scroll down bit and change:
Find Lines:
group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c           notConfigUser
Replace with:
group MyRWGroup v1         local
group MyRWGroup v2c        local
group MyRWGroup usm        local
group MyROGroup v1         mynetwork
group MyROGroup v2c        mynetwork
group MyROGroup usm        mynetwork
Again scroll down bit and locate following line:
Find line:
view    systemview     included      system
Replace with:
view all    included  .1                               80
Again scroll down bit and change:
Find line:
access  notConfigGroup ""      any       noauth    exact  systemview none none
Replace with:
access MyROGroup ""      any       noauth    exact  all    none   none
access MyRWGroup ""      any       noauth    exact  all    all    none
Scroll down bit and change:
Find lines:
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root  (configure /etc/snmp/snmp.local.conf)
Replace with (make sure you supply appropriate values):
syslocation Linux (RH3_UP2), Home Linux Router.
syscontact Vivek G Gite <vivek@nixcraft.com>
For your convenient, here is my /etc/snmp/snmpd.conf file. Feel free to use this file. Make sure you make backup of your existing file if you use this file as it is.
Start your snmp server and test it:
(a) Make sure when linux comes up snmpd always starts:
 # chkconfig snmpd on
(b) Make sure service start whenever Linux comes up (after reboot):
 # service snmpd start
(c) Finally test your snmp server:
  #updatedb
 # snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex

Step # 4 : Install mrtg if not installed

Mrtg software may install during initial installation; you can verify if MRTG installed or not with following RPM command:
rpm -qa | grep mrtg
If mrtg already installed please see step # 5; else use rpmfind.net to find MRTG rpm or up2date command to install MRTG software:
# up2date -v -i mrtg
Fedora Linux user can use yum command as follows to install MRTG:
# yum install mrtg

Step # 5 : Commands to Configure mrtg

(a) Create document root to store mrtg graphs/html pages:
# mkdir -p /var/www/html/mrtg/

Configuring MRTG
Use MRTG’s cfgmaker command to create a configuration file named mrtg.cfg for the server using a Read Only community string of public. Place all data files in the directory /var/www/mrtg.
# cfgmaker --output=/etc/mrtg/mrtg.cfg
--global "workdir: /var/www/html/mrtg" -ifref=ip
--global 'options[_]: growright,bits'
public@localhost
--base: Get Device Info on public@localhost:
--base: Vendor Id:
--base: Populating confcache
--snpo: confcache public@localhost: Descr lo --> 1
....
--base: Walking ifOperStatus
--base: Writing /etc/mrtg/mrtg.cfg
Run MRTG using /etc/mrtg/mrtg.cfg as your argument three times. You’ll get an error twice as MRTG tries to move old data files, and naturally, the first time it is run, MRTG has no data files to move.
# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
Use MRTG’s indexmaker command to create a Web index page using your new mrtg.cfg file as a guide. The MRTG Web GUI expects to find the index file in the default MRTG Web directory of /var/www/mrtg/, so the format of the command would be.
# indexmaker --output=/var/www/html/mrtg/index.html
/etc/mrtg/mrtg.cfg
MRTG is run every five minutes by default, and the file that governs this is /etc/cron.d/mrtg. For MRTG to work correctly, edit this file, replacing all occurrences of /usr/bin/mrtg with
env LANG=C /usr/bin/mrtg
The RHEL 4 MRTG installation process creates a cron file named /etc/cron.d/mrtg. This file tells the cron daemon to run MRTG using the /etc/mrtg/mrtg.cfg file every five minutes to poll your network devices.
Let’s add other things to monitor such as CPU and Memory. The following is my configuration to query CPU and memoy usage.
#
# File: /etc/mrtg/server-stats.cfg
#
# Configuration file for non bandwidth server statistics
#
#
# Define global options
#
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt,/usr/share/snmp/mibs/TCP-MIB.txt
workdir: /var/www/html/mrtg/
#
# CPU Monitoring
# (Scaled so that the sum of all three values doesn't exceed 100)
#
Target[server.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:public@localhost + ssCpuRawNice.0&ssCpuRawNice.0:public@localhost
Title[server.cpu]: Server CPU Load
PageTop[server.cpu]: <H1>CPU Load - System, User and Nice Processes</H1>
MaxBytes[server.cpu]: 100
ShortLegend[server.cpu]: %
YLegend[server.cpu]: CPU Utilization
Legend1[server.cpu]: Current CPU percentage load
LegendI[server.cpu]: Used
LegendO[server.cpu]:
Options[server.cpu]: growright,nopercent
Unscaled[server.cpu]: ymwd
#
# Memory Monitoring (Total Versus Available Memory)
#
Target[server.memory]: memAvailReal.0&memTotalReal.0:public@localhost
Title[server.memory]: Free Memory
PageTop[server.memory]: <H1>Free Memory</H1>
MaxBytes[server.memory]: 100000000000
ShortLegend[server.memory]: B
YLegend[server.memory]: Bytes
LegendI[server.memory]: Free
LegendO[server.memory]: Total
Legend1[server.memory]: Free memory, not including swap, in bytes
Legend2[server.memory]: Total memory
Options[server.memory]: gauge,growright,nopercent
kMG[server.memory]: k,M,G,T,P,X

#
# Memory Monitoring (Percentage usage)
#
Title[server.mempercent]: Percentage Free Memory
PageTop[server.mempercent]: <H1>Percentage Free Memory</H1>
Target[server.mempercent]: ( memAvailReal.0&memAvailReal.0:public@localhost ) * 100 / ( memTotalReal.0&memTotalReal.0:public@localhost )
options[server.mempercent]: growright,gauge,transparent,nopercent
Unscaled[server.mempercent]: ymwd
MaxBytes[server.mempercent]: 100
YLegend[server.mempercent]: Memory %
ShortLegend[server.mempercent]: Percent
LegendI[server.mempercent]: Free
LegendO[server.mempercent]: Free
Legend1[server.mempercent]: Percentage Free Memory
Legend2[server.mempercent]: Percentage Free Memory
Test server-stats.cfg configuration.
# service snmpd restart
# env LANG=C /usr/bin/mrtg /etc/mrtg/server-stats.cfg
Create a new MRTG index file to include the server-stats.cfg file
# indexmaker --output=/var/www/html/mrtg/index.html
/etc/mrtg/mrtg.cfg /etc/mrtg/server-stats.cfg
Configuring Crond to use the new MRTG file, To do so, add this line to your /etc/cron.d/mrtg file:

*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/server-info.cfg
Restart the cron daemon.
# service crond restart

Catatan popular daripada blog ini

Setting APACHE Tomcat Dengan Configure mod_jk Connector pada RHEL6.4 cara ringkas.

 Asas - Apakah mod_jk?   Penyambung mod_jk ialah modul Apache httpd yang membolehkan httpd untuk berkomunikasi dengan Apache Tomcat  bagi  seluruh  keadaan  protokol AJP. Modul ini digunakan bersama- s ama dengan komponen Penyambung AJP Tomcat ini.  Mengenai Penyambung   Apache Tomcat menggunakan komponen Penyambung untuk membolehkan komunikasi antara contoh nya  Tomcat dan pihak lain, seperti pelayar, pelayan atau contoh lain Tomcat yang merupakan sebahagian daripada rangkaian yang sama. Sebagai contoh, penyambung HTTP mendengar untuk permintaan lebih protokol HTTP/1.1 pada pelbagai port TCP...

Pasang Fedora 21 pada Surface Pro 3

Sila buat recovery untuk pc anda dulu guna USB yang bersaiz > 8 GB. Windows 8 Tak boleh  shrink volume lebih dari 4 partision. Tapi boleh guna cara khas nak    shrink volume. Jika alat Pengurusan Cakera tidak membenarkan berbuat demikian kerana "fail unmovable", anda akan perlu memasang semula Windows - dan menggunakan helah khas.  Gunakan opsyen Pemulihan untuk Pasang semula (tidak memuat semula) Windows.  Jangan meneruskan Ubahsuaian Awal selepas Windows but untuk kali pertama, sebaliknya, secara paksa mematikannya menggunakan butang kuasa, dan hidupkannya semula. Anda mungkin perlu mematikannya dan pada dua atau tiga kali, sehingga but Windows dan dicadangkan anda untuk menggunakan Advanced Startup untuk membaikinya.  Masukkan Command Prompt daripada pilihan Advanced Startup - Troubleshoot - advance options - command prompt - administrator - continue. .  Gunakan DISKPART mengecut partition C dengan saiz yang anda inginkan.  But s...

GlusterFS & cara penggunaan

Apa itu GlusterFS? GlusterFS ialah sistem fail storan yang dilampirkan berskala. Ia aplikasi yang dijumpai di pengkomputeran awan, perkhidmatan media streaming dan penghantaran kandungan rangkaian . GlusterFS telah dibangunkan semula oleh Gluster, Inc. dan kemudian oleh Red Hat, Inc. Hasilnya Red Hat memperoleh Gluster pada tahun 2011. Pada Jun 2012, Red Hat Storage Server diumumkan sebagai penyepaduan komersil antara GlusterFS dengan Red Hat Enterprise Linux. Red Hat membeli  Inktank Storage  pada bulan April 2014, yang merupakan syarikat di sebalik sistem teragih (Ceph), dan menjenamakan semula Red Hat Storage Server berasaskan GlusterFS kepada "Red Hat Gluster Storage". GlusterFS mengagregat pengiraan, penyimpanan, dan sumber I/O ke dalam ruang nama global.Setiap pelayan ditambah storan komoditi sama ada (storan berhubung langsung, JBOD atau menggunakan storan SAN) dianggap sebagai nod. Kapasiti diperkecil dengan menambahkan nod tambahan atau menambahkan storan ...