Munin(munin-node)の監視項目を追加する方法です。
CentOS7に「yum」でインストールされた「Munin」を想定し記述していますので、他のディストリビューションの場合適宜読み替えてください。
プラグインについて
「Munin」の監視項目はプラグインという形で提供されていて、デフォルトで非常に多くのプラグインが「/usr/share/munin/plugins/」ディレクトリ内に用意されています。
このプラグイン自体は、サーバのステータス値を取得するスクリプトになっています。
提供プラグイン一覧
初期設定で提供されているプラグインは下記の通り、非常に多くの項目について用意されています。
# ls /usr/share/munin/plugins/ acpi lpstat qmailqstat amavis mailman qmailscan apache_accesses mailscanner qmailscan-simple apache_processes mbmon_ quota_usage_ apache_volume meminfo samba apc_envunit_ memory selinux_avcstat apc_nis mhttping sendmail_mailqueue apt multiping sendmail_mailstats apt_all multips sendmail_mailtraffic asterisk_channels multips_memory sensors_ asterisk_channelstypes munin_stats slapd_ asterisk_codecs munin_update slapd_bdb_cache_ asterisk_meetme mysql_ slony_lag_ asterisk_meetmeusers mysql_bytes smart_ asterisk_sipchannels mysql_innodb snmp__cpuload asterisk_sippeers mysql_isam_space_ snmp__df asterisk_voicemail mysql_queries snmp__df_ram bind9 mysql_slowqueries snmp__fc_if_ bind9_rndc mysql_threads snmp__fc_if_err_ bonding_err_ named snmp__if_ buddyinfo netopia snmp__if_err_ cmc_tc_sensor_ netstat snmp__if_multi courier_ netstat_multi snmp__load courier_mta_mailqueue nfs4_client snmp__memory courier_mta_mailstats nfs_client snmp__netapp_diskusage_ courier_mta_mailvolume nfsd snmp__netapp_inodeusage_ cps_ nfsd4 snmp__netstat cpu nginx_request snmp__print_pages cpuspeed nginx_status snmp__print_supplies cupsys_pages nomadix_users_ snmp__processes df ntp_kernel_err snmp__rdp_users df_abs ntp_kernel_pll_freq snmp__sensors_fsc_bx_fan df_inode ntp_kernel_pll_off snmp__sensors_fsc_bx_temp digitemp_ ntp_offset snmp__sensors_fsc_fan diskstat_ ntp_states snmp__sensors_fsc_temp diskstats nut_misc snmp__sensors_mbm_fan ejabberd_ nut_volts snmp__sensors_mbm_temp entropy nutups_ snmp__sensors_mbm_volt exim_mailqueue nvidia_ snmp__swap exim_mailqueue_alt open_files snmp__uptime exim_mailstats open_inodes snmp__users fail2ban openvpn snmp__winload foldingathome perdition snmp__winmem foldingathome_rank pgbouncer_connections snort_alerts foldingathome_wu pgbouncer_requests snort_bytes_pkt forks ping_ snort_drop_rate freeradius_acct plugin.sh snort_pattern_match freeradius_auth plugins.history snort_pkts freeradius_proxy_acct pm3users_ snort_traffic freeradius_proxy_auth pop_stats spamstats fw_conntrack port_ squeezebox_ fw_forwarded_local postfix_mailqueue squid_cache fw_packets postfix_mailstats squid_icp haproxy_ postfix_mailvolume squid_objectsize haproxy_ng postgres_autovacuum squid_requests hddtemp postgres_bgwriter squid_traffic hddtemp2 postgres_cache_ surfboard hddtemp_smartctl postgres_checkpoints swap hddtempd postgres_connections_ tcp hp2000_ postgres_connections_db threads http_loadtime postgres_locks_ tomcat_access if_ postgres_oldest_prepared_xact_ tomcat_jvm if_err_ postgres_prepared_xacts_ tomcat_threads ifx_concurrent_sessions_ postgres_querylength_ tomcat_volume interrupts postgres_scans_ uptime iostat postgres_size_ users iostat_ios postgres_streaming_ varnish_ ip_ postgres_transactions_ vlan_ ipac-ng postgres_tuples_ vlan_inetuse_ ipmi_ postgres_users vlan_linkuse_ ipmi_sensor_ postgres_xlog vmstat ircu proc vserver_cpu_ irqstats proc_pri vserver_loadavg jmx_tomcat_dbpools processes vserver_resources load proxy_plugin yum loggrep ps_ zimbra_ lpar_cpu psu_
※下記2つはプラグインではありません。
- plugin.sh プラグイン管理用シェル
- plugins.history プラグイン履歴ファイル
監視項目(プラグイン)の追加方法
監視項目追加は「プラグインを追加する」といい、「/etc/munin/plugins」にプラグインを設置することでプラグインと認識されます。
実際には「/etc/munin/plugins」から「/usr/share/munin/plugins/」にあるプラグインの実態にシンボリックリンクを作成してプラグインを追加していく形となります。
下記は「Munin」インストール直後の「/etc/munin/plugins」ディレクトリ内を表示させた結果ですが、「/usr/share/munin/plugins」にあるプラグインの実態にシンボリックリンクが設定されていることが確認できます。
# ls -l /etc/munin/plugins 合計 0 lrwxrwxrwx. 1 root root 28 9月 21 13:07 cpu -> /usr/share/munin/plugins/cpu lrwxrwxrwx. 1 root root 27 9月 21 13:07 df -> /usr/share/munin/plugins/df lrwxrwxrwx. 1 root root 33 9月 21 13:07 df_inode -> /usr/share/munin/plugins/df_inode lrwxrwxrwx. 1 root root 34 9月 21 13:07 diskstats -> /usr/share/munin/plugins/diskstats lrwxrwxrwx. 1 root root 32 9月 21 13:07 entropy -> /usr/share/munin/plugins/entropy lrwxrwxrwx. 1 root root 30 9月 21 13:07 forks -> /usr/share/munin/plugins/forks lrwxrwxrwx. 1 root root 37 9月 21 13:07 fw_conntrack -> /usr/share/munin/plugins/fw_conntrack lrwxrwxrwx. 1 root root 43 9月 21 13:07 fw_forwarded_local -> /usr/share/munin/plugins/fw_forwarded_local lrwxrwxrwx. 1 root root 35 9月 21 13:07 fw_packets -> /usr/share/munin/plugins/fw_packets lrwxrwxrwx. 1 root root 28 9月 21 13:07 if_eno16777736 -> /usr/share/munin/plugins/if_ lrwxrwxrwx. 1 root root 32 9月 21 13:07 if_err_eno16777736 -> /usr/share/munin/plugins/if_err_ lrwxrwxrwx. 1 root root 35 9月 21 13:07 interrupts -> /usr/share/munin/plugins/interrupts lrwxrwxrwx. 1 root root 33 9月 21 13:07 irqstats -> /usr/share/munin/plugins/irqstats lrwxrwxrwx. 1 root root 29 9月 21 13:07 load -> /usr/share/munin/plugins/load lrwxrwxrwx. 1 root root 31 9月 21 13:07 memory -> /usr/share/munin/plugins/memory lrwxrwxrwx. 1 root root 35 9月 21 13:07 open_files -> /usr/share/munin/plugins/open_files lrwxrwxrwx. 1 root root 36 9月 21 13:07 open_inodes -> /usr/share/munin/plugins/open_inodes lrwxrwxrwx. 1 root root 42 9月 21 13:07 postfix_mailqueue -> /usr/share/munin/plugins/postfix_mailqueue lrwxrwxrwx. 1 root root 43 9月 21 13:07 postfix_mailvolume -> /usr/share/munin/plugins/postfix_mailvolume lrwxrwxrwx. 1 root root 33 9月 21 13:07 proc_pri -> /usr/share/munin/plugins/proc_pri lrwxrwxrwx. 1 root root 34 9月 21 13:07 processes -> /usr/share/munin/plugins/processes lrwxrwxrwx. 1 root root 29 9月 21 13:07 swap -> /usr/share/munin/plugins/swap lrwxrwxrwx. 1 root root 32 9月 21 13:07 threads -> /usr/share/munin/plugins/threads lrwxrwxrwx. 1 root root 31 9月 21 13:07 uptime -> /usr/share/munin/plugins/uptime lrwxrwxrwx. 1 root root 30 9月 21 13:07 users -> /usr/share/munin/plugins/users lrwxrwxrwx. 1 root root 31 9月 21 13:07 vmstat -> /usr/share/munin/plugins/vmstat
監視項目(プラグイン)の追加
実際に「iostat」を監視するプラグインを追加してみます。
# ln -s /usr/share/munin/plugins/iostat /etc/munin/plugins/iostat
※プラグインによっては、そのままシンボリックリンクを作成するだけではなく、リンクを作成する際にターゲットを指定したり、設定ファイルを作成したりする必要がある場合もあります。
設定反映
シンボリックリンクを作成してプラグインを追加しましたら、「munin-node」を再起動させて追加したプラグインを認識させます。
CentOS7の場合
# systemctl restart munin-node
CentOS6以前の場合
# service restart munin-node
動作確認
追加したプラグインが、正常にステータスを取得できるかは「munin-run」コマンドを使用することで確認できます。
# munin-run プラグイン名
実際に先ほど追加した「iostat」プラグインで確認してみます。
# munin-run iostat dev8_0_read.value 384099 dev8_0_write.value 11500425
このようにステータス値が取得できれば問題ありませんので、あとはwebブラウザで正常にグラフが表示されるかの確認を行ってください。
コメント