■環境は以下の通り
・Cactiサーバー
OS:CentOS 6.5 on vagrant(Windows8.1)
Cacti:0.8.8c
host:cacti1
IP:192.168.0.76
・監視対象
OS:Windows2012 R2
監視方式はsnmp
host:w2k12
ip:192.168.0.70
1.cactiのインストール
1.1 必要パッケージのインストール
$ yum install -y httpd php php-mysql php-snmp php-xml mysql mysql-server net-snmp rrdtool1.2 phpの設定
#外部コマンドを実行するためsafe_modeをOFFにする safe_mode = Off #タイムゾーンを合わせる date.timezone = "Asia/Tokyo" #TemplateがImportできるようにする file_uploads = On #インストール手順にはずしたほうがよいと・・ ;session.save_path = "/var/lib/php/session"1.3 Apacheの設定
#以下の設定になっていることを確認する LoadModule php5_module modules/libphp5.so AddHandler php5-script .php AddType text/html .php DirectoryIndex index.php
# Cacti - the complete rrdtool-based graphing solution # # Allows only localhost by default # # Allowing cacti to anyone other than localhost should be considered # dangerous unless properly secured by SSL # Make sure, that httpd can read your cacti directories. # At minimum, you need # chmod ugo+r -R /your/cacti/dir # Make sure to replace with your directories # When using SELinux, set the following: # chcon -R -h -t httpd_sys_content_t /your/cacti/dir # when using SELinux and you private homedir, enable # setsebool -P httpd_enable_homedirs 1 # setsebool -P httpd_read_user_content 1 Alias /cacti /var/www/html/cacti1.4 MySQLの設定AllowOverride None Order Deny,Allow Deny from all Allow from 127.0.0.1 Allow from 192.168.0.0/24 Allow from ::1 Options Indexes Includes FollowSymLinks # These directories do not require access over HTTP #Order Deny,Allow Deny from All Allow from None
$ sudo service mysqld start $ sudo chkconfig mysqld on $ /usr/bin/mysqladmin -u root password 'new-password' $ /usr/bin/mysqladmin -u root -h cacti1.hayachi617.jp password 'new-password' $ sudo /usr/bin/mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] n ... skipping. By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! $ mysqladmin --user=root --password reload Enter password:1.5 snmpの設定
snmp-netで構築してみる(spiderは別途)
$ yum install -y net-snmp net-snmp-libs net-snmp-utils以下の設定を追加
rocommunity public
$ sudo service snmpd start #稼働確認 $ snmpwalk -v 1 -c public localhost .1.3.6.1.2.1.1.1.0 SNMPv2-MIB::sysDescr.0 = STRING: Linux cacti1.hayachi617.jp 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_641.6 cactiの設定
まずはモジュールの入手
$ cd /var/www/html/ $ sudo wget http://www.cacti.net/downloads/cacti-0.8.8c.tar.gz $ sudo tar xvfz cacti-0.8.8c.tar.gzつぎにMySQLへの設定です。
$ cd cacti-0.8.8c $ mysql cacti --user=root -p < cacti.sql $ mysql --user=root mysql -p mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) $ sudo useradd cactiuser $ sudo chown -R cactiuser rra/ log/ $ sudo chmod ugo+r -R /var/www/html/cacti $ sudo su - cactiuser $ crontab -e */5 * * * * /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1 $ sudo cd .. $ sudo ln -s cacti-0.8.8c /var/www/html/cacti $ sudo chkconfig httpd on $ sudo chkconfig snmpd on $ sudo service httpd startここで、端末からブラウザでアクセスしてみる http://192.168.0.76/cacti
0 件のコメント:
コメントを投稿