$ sudo yum -y install net-snmp net-snmp-utils $ sudo yum -y install rrdtool $ sudo yum -y install cacti
# diff -u /etc/snmp/snmpd.conf.original /etc/snmp/snmpd.conf --- /etc/snmp/snmpd.conf.original 2010-07-31 23:59:47.901056095 +0900 +++ /etc/snmp/snmpd.conf 2010-08-01 00:14:10.963061509 +0900 @@ -52,14 +52,17 @@ # Make at least snmpwalk -v 1 localhost -c public system fast again. # name incl/excl subtree mask(optional) -view systemview included .1.3.6.1.2.1.1 -view systemview included .1.3.6.1.2.1.25.1.1 - +#view systemview included .1.3.6.1.2.1.1 +#view systemview included .1.3.6.1.2.1.25.1.1 +view all included .1 80 + #### # Finally, grant the group read-only access to the systemview view. # group context sec.model sec.level prefix read write notif -access notConfigGroup "" any noauth exact systemview none none +#access notConfigGroup "" any noauth exact systemview none none +access notConfigGroup "" any noauth exact all none none +access notConfigGroup "" any noauth exact all all none # -----------------------------------------------------------------------------
$ sudo /sbin/chkconfig --level 35 snmpd on
$ sudo /etc/init.d/snmpd start
$ snmpwalk -v1 -c public localhost SNMPv2-MIB::sysDescr.0 = STRING: Linux orange.homelan 2.6.33.6-147.fc13.i686.PAE #1 SMP Tue Jul 6 22:24:44 UTC 2010 i686 SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::org DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (88494) 0:14:44.94 SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf) SNMPv2-MIB::sysName.0 = STRING: orange.homelan SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf) ... End of MIB
$ mysql -u root -p Enter password: mysql> create database cacti; Query OK, 1 row affected (0.26 sec) mysql> grant all privileges on cacti.* to cactiuser@localhost identified by 'cactiuser'; Query OK, 0 rows affected (0.34 sec) mysql> exit Bye $ mysql -u cactiuser -p cacti < /usr/share/doc/cacti-0.8.7f/cacti.sql Enter password:
$ sudo vi /usr/share/cacti/include/config.php
パスワードのデフォルト値は "cactiuser"。DBを作る際に、これと違うパスワードを設定していた場合に変更する必要がある。
$ sudo /etc/init.d/httpd reload
$ snmpwalk -v1 -c public localhostと同じように設定する 同じ画面の最後で、SNMP Interface Statistics を追加して SAVE
# cat /etc/cron.d/cacti */5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1
$ sudo mkdir /var/www/html/sysrepo $ sudo chown apache:apache sysrepo/ $ sudo chmod 777 sysrepo/
Export Method | Classic(Local path) |
Path | /var/www/html/sysrepo |
Timing | Daily at specified time(21:00) |
Graph +----GraphTemplate +----DataSource +----DataTemplate +----DataInputMethod +---- Script
$ cat /var/lib/cacti/scripts/temp.sh #!/bin/bash CPU=`/usr/bin/sensors | grep "Core 0" | awk '{print $3}'` CPU=${CPU//°C/} CPU=${CPU//+/} CPU=${CPU//.[0-9]*/} HDD=`/usr/sbin/smartctl -i -a /dev/sda | grep Temperature_Celsius | awk '{print $10}'` echo -n "CPU:"$CPU" HDD:"$HDD
$ sudo /var/lib/cacti/scripts/temp.sh CPU:49 HDD:51$改行しないのがミソ
$ cat /etc/cron.d/cacti */5 * * * * root /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1 # */5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1