Deprecated: Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 63

Deprecated: Return type of Requests_Cookie_Jar::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 73

Deprecated: Return type of Requests_Cookie_Jar::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 89

Deprecated: Return type of Requests_Cookie_Jar::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 102

Deprecated: Return type of Requests_Cookie_Jar::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Cookie/Jar.php on line 111

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 40

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 51

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 68

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 82

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 91

Deprecated: Return type of AIOSEO\Plugin\Common\Models\Model::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 409

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174
CentOS7でmuninでサーバを監視する | reyfox blog

reyfox blog

reyfox tech info

Apache2.4系 CentOS Linux munin

CentOS7でmuninでサーバを監視する

投稿日:2019年1月22日 更新日:

muninは非常に簡単でサーバの状態を確認できるツールとなっています。

インストールと設定


yum install munin-apache.noarch munin-node munin-common vlgothic-fonts vlgothic-p-fonts
# fonts は文字化けの対応のためのインストール

インストールされるバージョンは、2.0.43となります。

muninはApacheを経由して見るので、事前に httpd のインストールが必要です。

Apacheのインストール

Apacheの監視を入れる(任意)

Apacheの status を取得するため、server-status を有効化します。


vi /etc/httpd/conf.d/server-status.conf

<Location "/server-status">
    SetHandler server-status
    Require host localhost
</Location>

MySQLを監視する設定を入れる(任意)

PHPMyAdmin に root でログインし、munin 用のユーザを作成します。

munin 用のユーザは、管理権限にすべてチェックを入れておくと良いでしょう。

munin のコンフィグファイルを調整します。


vi /etc/munin/plugin-conf.d/00-default

[mysql*]
env.mysqlopts -umunin --password=[設定したパスワード]
env.mysqlconnection DBI:mysql:mysql;host=localhost;port=3306
env.mysqluser munin
env.mysqlpassword [設定したパスワード]
#env.mysqlopts -u someuser

一部抜粋ですが[mysql*]の部分のみ変更を行います。
[設定したパスワード]の[ ] は不要です。

PHPMyAdminの設置

設定の確認

munin-node-configure -suggest というコマンドを実行します。


munin-node-configure -suggest

mysql 部分が yes になっているのを確認してください。
(mysql の監視が不要の場合は no のままで問題ありません)

設定からプラグインを反映する

munin-node-configure から簡単に反映することが出来ます。


munin-node-configure -shell | sh

muninの起動と自動実行設定

munin の自動起動の設定をします。
ついでに httpd も起動します。


systemctl enable munin-node
systemctl enable httpd
systemctl start munin-node
systemctl start httpd

munin用のVH(今回の場合は共有VH)を作成

/etc/httpd/conf.d/munin-vhost.conf を作成します。


vi /etc/httpd/conf.d/munin-vhost.conf

<VirtualHost *:80>
    ServerName 192.168.xxx.2
    DocumentRoot "/var/www/html"
    ScriptAlias /munin-cgi/munin-cgi-graph /var/www/html/munin/cgi/munin-cgi-graph
    <Directory />
        Options +FollowSymLinks -Indexes
        AllowOverride All
        Allow from 192.168.
        Allow from 127.0.0.1
        deny from all
    </Directory>
</VirtualHost>

IPアドレス直でアクセスがあった場合、上記のVirtualHostを表示するようにします。
セキュリティのため、一応ローカルからしかアクセスできないようにも設定します。

Apacheへ設定の反映


systemctl restart httpd

Basic認証が出る場合

muninのデフォルトではbasic認証が出るようになっています。
これを回避するには、 /var/www/html/munin/.htaccess の
以下をコメントアウトします。
または適切なBasic認証を設定します。

AuthName “Munin”
AuthType Basic
require valid-user

ブラウザでアクセス

http://[サーバIP]/munin/ でmunin の画面が表示されるようになります。

強制的にグラフをアップデート

グラフは5分毎に更新されますが、テストですぐに更新したい場合は下記のコマンドを打つと更新されます。


su - munin --shell=/usr/bin/munin-cron

実際の表示

munin.conf munin-node.conf を書き換えることにより、localhost の部分を変更できますが今回はこのままにしています。
上記の例では、ACPIの温度(CPU)を自動でとってきてグラフ化してくれています。

-Apache2.4系, CentOS, Linux, munin

執筆者:

関連記事

CentOS7にMySQLサーバ(mariaDB)をインストールする

CentOS7からMySQLにかわりmariaDBが採用されていますが、使い方はほぼ MySQLと同じでいけます。 インストール いつもの通り、yumで。 yum install mariadb-se …

CentOS7にPHP 7.2をインストール

WebプログラミングでおなじみPHPをインストール設定します。PHPは現在では最新が7.2となっていて、CentOS7標準のリポジトリで提供されている5.4は古いのでインストールしません。 インストー …

CentOS7にSambaサーバを立ててWindows/Macとファイルを共有する

Linux上にsambaサーバを立てて、Windows及びMacとファイル共有をします。 ストレージは以前増設した3TBのHDDを用いて3TBすべてを共有してNASのように使用します。 Intel N …

CentOS7にApacheをインストール

CentOS7はnetworkインストールで最小構成だと httpd(Apache)が入りません。しかし、yumコマンドで簡単にインストールすることが出来ます。 インストール yum install …

CentOS7で内向き専用DNSサーバを立てる

内向きDNSとは、LAN内でだけドメイン名を解決できるDNSサーバを言います。今回は、LAN内だけでドメイン名を解決するDNSサーバを立て、デフォルトのDNSとして動作するように設定します。なお、内向 …


Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Utils/Database.php on line 535

Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in /var/www/blog.reyfox.com/htdocs/wp/wp-content/plugins/all-in-one-seo-pack/app/Common/Models/Model.php on line 174