※現在(2021/01/28)は提供されてないようです.
gitで.
$ mkdir logmon🆑 $ cd logmon🆑 $ git clone https://github.com/moomindani/logmon.git🆑 Cloning into 'logmon'... remote: Enumerating objects: 21, done. remote: Total 21 (delta 0), reused 0 (delta 0), pack-reused 21 Unpacking objects: 100% (21/21), done. $ ls -la🆑 total 0 drwxr-xr-x 3 ujpadmin staff 96 9 4 00:44 . drwx------+ 62 ujpadmin staff 1984 9 4 00:44 .. drwxr-xr-x 8 ujpadmin staff 256 9 4 00:44 logmon $ cd logmon🆑 $ ls -la🆑 total 20 drwxr-xr-x 8 ujpadmin staff 256 9 4 00:44 . drwxr-xr-x 3 ujpadmin staff 96 9 4 00:44 .. drwxr-xr-x 12 ujpadmin staff 384 9 4 00:44 .git -rw-r--r-- 1 ujpadmin staff 14 9 4 00:44 README.md -rwxr-xr-x 1 ujpadmin staff 1254 9 4 00:44 logmon -rw-r--r-- 1 ujpadmin staff 94 9 4 00:44 logmon.conf -rwxr-xr-x 1 ujpadmin staff 2867 9 4 00:44 logmon.pl -rwxr-xr-x 1 ujpadmin staff 277 9 4 00:44 setup.sh $
http://localhost/ #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7465&macOSServer1.jpg,center)
gaia:~ ujpadmin$ gaia:~ ujpadmin$
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7466&macOSServer2.jpg,center)
変更後のポートに接続できました.
High SierraにServer.appを導入したOS X Serverでは,管理用のWebサーバが起動している.このままだとFileMakerを入れたり他のWebサービスを稼働できないので,これを動作ポートを変更する.
ターミナルからプロセスを確認.
gaia:~ ujpadmin$ ps -ef|grep httpd🆑
プロセス確認.
$ ps -ef|grep httpd
0 373 1 0 金01AM ?? 0:18.91 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/apache2/services/ACSServer.conf -E /var/log/apache2/services/ACSServer_error_log 70 375 373 0 金01AM ?? 0:01.54 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/apache2/services/ACSServer.conf -E /var/log/apache2/services/ACSServer_error_log 0 376 1 0 金01AM ?? 0:19.46 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 380 376 0 金01AM ?? 0:00.02 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 381 376 0 金01AM ?? 0:01.61 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 382 376 0 金01AM ?? 0:00.02 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 383 376 0 金01AM ?? 0:00.02 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 384 376 0 金01AM ?? 0:00.02 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 502 13880 12211 0 5:07PM ttys007 0:00.01 grep httpd $
$ ls -la /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf🆑 -rw-r--r-- 1 root wheel 20452 8 9 19:07 /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf $
設定ファイルが/Library/Server/Web/Config/Proxy/apache_serviceproxy.confにある事が確認できた.
ブラウザでサーバに接続してみる
編集前にバックアップコピーを行う.
sudo cp /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf ¥ > /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf.20200817.v01🆑
編集後の,diff結果は次の通り.
$ diff /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf.20200817.v01 /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf 2,3c2,5 < ErrorLog "/private/var/log/apache2/service_proxy_error.log" < CustomLog "/private/var/log/apache2/service_proxy_access.log" combinedvhost --- > #ErrorLog "/private/var/log/apache2/service_proxy_error.log" > #CustomLog "/private/var/log/apache2/service_proxy_access.log" combinedvhost > CustomLog "/Users/server/Documents/AppleServer/service_proxy_access.log" combinedvhost > ErrorLog "/Users/server/Documents/AppleServer/service_proxy_error.log" 5c7,8 < PidFile /var/run/service_proxy.pid --- > #PidFile /var/run/service_proxy.pid > PidFile /Users/server/Documents/service_proxy.pid 11,12c14,15 < listen 80 < listen 443 --- > listen 8001 > listen 8101 150c153 < <VirtualHost *:80> --- > <VirtualHost *:8001> 215c218 < <VirtualHost *:443> --- > <VirtualHost *:8101> $
ポート番号を80から8001,443を8101に変更している.
プロセスを停止させる.
gaia:~ ujpadmin$ sudo killall httpd🆑 gaia:~ ujpadmin$
自動的に起動してくるので,プロセスを確認.
gaia:~ ujpadmin$ !ps🆑 ps -ef|grep httpd 0 34001 1 0 10:33PM ?? 0:00.19 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 34004 34001 0 10:33PM ?? 0:00.01 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 34005 34001 0 10:33PM ?? 0:00.01 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 34006 34001 0 10:33PM ?? 0:00.01 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 34007 34001 0 10:33PM ?? 0:00.01 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 34008 34001 0 10:33PM ?? 0:00.01 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 501 34010 15267 0 10:33PM ttys003 0:00.01 grep httpd gaia:~ ujpadmin$
新しいポートに接続してみる.
変更後のポートに接続できました.
> /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf.20160718🆑 kairos:~ ujpadmin$ diff /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf.20160718 \ > /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf🆑 kairos:~ ujpadmin$ sudo killall httpd🆑 kairos:~ ujpadmin$ !ps🆑 0 34001 1 0 10:33PM ?? 0:00.19 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log
http://192.168.20.27:8081
¶http://localhost:8081/
¶http://localhost:8081/
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=3623&OSXElcapitanhttpServer.jpg,center)
¶apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log
El CapitanにServer.appを導入したOS X Serverでは,管理用のWebサーバが起動している.このままだとFileMakerを入れたり他のWebサービスを稼働できないので,これを動作ポートを変更する.
ターミナルからプロセスを確認.
kairos:~ ujpadmin$ 🆑ps -ef|grep httpd 0 10267 1 0 7:09PM ?? 0:00.74 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 10274 10267 0 7:09PM ?? 0:00.09 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 10275 10267 0 7:09PM ?? 0:00.02 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 10276 10267 0 7:09PM ?? 0:00.02 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 10277 10267 0 7:09PM ?? 0:00.03 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 10278 10267 0 7:09PM ?? 0:00.03 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 33567 10267 0 9:33PM ?? 0:00.01 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 501 33890 15267 0 10:11PM ttys003 0:00.00 grep httpd kairos:~ server$
設定ファイルが/Library/Server/Web/Config/Proxy/apache_serviceproxy.confにある事が確認できた.
ブラウザでサーバに接続してみる
編集前にバックアップコピーを行う.
sudo cp /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf ¥ > /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf.20160718🆑
編集後の,diff結果は次の通り.
kairos:~ ujpadmin$ diff /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf.20160718 \ > /Library/Server/Web/Config/Proxy/apache_serviceproxy.conf🆑 10,11c10,13 < listen 80 < listen 443 --- > #listen 80 > #listen 443 > listen 8081 > listen 8943 140c142,143 < <VirtualHost *:80> --- > #<VirtualHost *:80> > <VirtualHost *:8081> 145c148 < RequestHeader set X-Forwarded-Port "80" --- > RequestHeader set X-Forwarded-Port "8081" 202c205,206 < <VirtualHost *:443> --- > #<VirtualHost *:443> > <VirtualHost *:8943> 206c210,211 < RequestHeader set X-Forwarded-Port "443" --- > #RequestHeader set X-Forwarded-Port "443" > RequestHeader set X-Forwarded-Port "8943" kairos:~ server$
ポート番号を80から8081,443を8943に変更している.
プロセスを停止させる.
kairos:~ ujpadmin$ sudo killall httpd🆑 kairos:~ server$
自動的に起動してくるので,プロセスを確認.
kairos:~ ujpadmin$ !ps🆑 ps -ef|grep httpd 0 34001 1 0 10:33PM ?? 0:00.19 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 34004 34001 0 10:33PM ?? 0:00.01 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 34005 34001 0 10:33PM ?? 0:00.01 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 34006 34001 0 10:33PM ?? 0:00.01 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 34007 34001 0 10:33PM ?? 0:00.01 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 70 34008 34001 0 10:33PM ?? 0:00.01 /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/Proxy/ apache_serviceproxy.conf -E /private/var/log/apache2/service_proxy_error.log 501 34010 15267 0 10:33PM ttys003 0:00.01 grep httpd kairos:~ server$
新しいポートに接続してみる.
Disabledになっているので,起動してないのかな.
¶今回,設定した内容を整理.
$ cat /etc/snmp/snmpd.conf|grep -v -e '^#'|grep -v -e '^$'🆑 com2sec local localhost private com2sec mynetwork NETWORK/24 public group MyRWGroup v1 local group MyRWGroup v2c local group MyRWGroup usm local group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork view all included .1 80 access MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none rwuser admin rocommunity public default .1 rwcommunity private syslocation Right here, right now. syscontact Administrator <postmaster@example.com> sysservices 76 proc httpd exec echotest /bin/echo hello world exec web_status /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin status web exec netboot /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin status netboot disk / 10000 $ $ cat /usr/share/snmp/snmpd.conf|grep -v -e '^#'|grep -v -e '^$'🆑 syslocation BCP syscontact 管理者メールアドレス syslocation BCP sysservices 76 proc smbd disk /Volumes/RAID0_12TB 95% disk /Volumes/zeusHD 80% load 12 8 4 file /var/log/system.log 30000 $
$ cat /usr/share/snmp/snmpd.conf🆑
$ sudo /usr/bin/snmpconf -i🆑
まずは,サイド編集モードまで. ここから先は,メニューを順番に選んでいく.
Configuring: proc🈁
単純にプロセス名だけを指定する.
Name of the process you want to check on: smbd🆑 Maximum number of processes named 'smbd' that should be running [default = 0]:🆑 Minimum number of processes named 'smbd' that should be running [default = 0]:🆑 Finished Output: proc smbd
今回は,プロセス数をmaxもminも,何も指定しないで0(ゼロ)とした.こういう指定をすると,プロセスが1つ以上起動してないとエラーという設定となる.
今回は,例として/Volumes/RAID0_12TBというボリュームが95%を超えるかどうかを監視する.
select section: 2🆑 Configuring: disk🈁 Description: Check for disk space usage of a partition. The agent can check the amount of available disk space, and make sure it is above a set limit. disk PATH [MIN=100000] PATH: mount path to the disk in question. MIN: Disks with space below this value will have the Mib's errorFlag set. Can be a raw integer value (units of kB) or a percentage followed by the % symbol. Default value = 100000. The results are reported in the dskTable section of the UCD-SNMP-MIB tree Enter the mount point for the disk partion to be checked on: /Volumes/RAID0_12TB🆑 Enter the minimum amount of space that should be available on /Volumes/RAID0_12TB: 95%🆑 Finished Output: disk /Volumes/RAID0_12TB 95%🈁 Section: Monitor Various Aspects of the Running Host The following check up on various aspects of a host. Select from: 1: Check for processes that should be running. 2: Check for disk space usage of a partition. 3: Check for unreasonable load average values. 4: Check on the size of a file. Other options: finished, list Select section:
システムドライブを指定する場合は,70%くらいが良いのだと思う.大量にエラーがでたら急激に増えるものだしね.
一旦はこれで.
継続することで大きくなるファイルを監視する.ここではmacosなので,system.logとしている.Linuxだと/var/log/messagesになる. ここまでで一通り終了.
これまで設定した内容を確認するために,listコマンドを実行.
Select section: list🆑 proc smbd
問題ないので,finishedやquitで終了.
Select section: finished🆑 Other options: finished🈁 Select section: finished🆑 Other options: quit🈁 Select File: quit🆑 snmpd.conf installed in /usr/share/snmp🈁
設定ファイルが書き出された模様.
ここまでで設定されたsnmpd.confファイルを確認する.
$ cat /usr/share/snmp/snmpd.conf🆑 ########################################################################### # # snmpd.conf # # - created by the snmpconf configuration program # ########################################################################### # SECTION: Monitor Various Aspects of the Running Host # # The following check up on various aspects of a host. # proc: Check for processes that should be running. # proc NAME [MAX=0] [MIN=0] # # NAME: the name of the process to check for. It must match # exactly (ie, http will not find httpd processes). # MAX: the maximum number allowed to be running. Defaults to 0. # MIN: the minimum number to be running. Defaults to 0. # # The results are reported in the prTable section of the UCD-SNMP-MIB tree # Special Case: When the min and max numbers are both 0, it assumes # you want a max of infinity and a min of 1. proc smbd🈁 # disk: Check for disk space usage of a partition. # The agent can check the amount of available disk space, and make # sure it is above a set limit. # # disk PATH [MIN=100000] # # PATH: mount path to the disk in question. # MIN: Disks with space below this value will have the Mib's errorFlag set. # Can be a raw integer value (units of kB) or a percentage followed by the % # symbol. Default value = 100000. # # The results are reported in the dskTable section of the UCD-SNMP-MIB tree disk /Volumes/RAID0_12TB 95%🈁 # load: Check for unreasonable load average values. # Watch the load average levels on the machine. # # load [1MAX=12.0] [5MAX=12.0] [15MAX=12.0] # # 1MAX: If the 1 minute load average is above this limit at query # time, the errorFlag will be set. # 5MAX: Similar, but for 5 min average. # 15MAX: Similar, but for 15 min average. # # The results are reported in the laTable section of the UCD-SNMP-MIB tree load 12 8 4🈁 # file: Check on the size of a file. # Display a files size statistics. # If it grows to be too large, report an error about it. # # file /path/to/file [maxsize_in_kilobytes] # # if maxsize is not specified, assume only size reporting is needed. # # The results are reported in the fileTable section of the UCD-SNMP-MIB tree file /var/log/system.log 30000🈁 ########################################################################### # SECTION: System Information Setup # # This section defines some of the information reported in # the "system" mib group in the mibII tree. # syslocation: The [typically physical] location of the system. # Note that setting this value here means that when trying to # perform an snmp SET operation to the sysLocation.0 variable will make # the agent return the "notWritable" error code. IE, including # this token in the snmpd.conf file will disable write access to # the variable. # arguments: location_string syslocation BCP🈁 # syscontact: The contact information for the administrator # Note that setting this value here means that when trying to # perform an snmp SET operation to the sysContact.0 variable will make # the agent return the "notWritable" error code. IE, including # this token in the snmpd.conf file will disable write access to # the variable. # arguments: contact_string syscontact 管理者メールアドレス
# sysservices: The proper value for the sysServices object. # arguments: sysservices_number sysservices 76🈁 $
コメントとかが多い... シンプルに書き直す.
$ cat /usr/share/snmp/snmpd.conf syslocation BCP syscontact 管理者メールアドレス sysservices 76 proc smbd disk /Volumes/RAID0_12TB 95% disk /Volumes/zeusHD 80% load 12 8 4 file /var/log/system.log 30000 $
たくさん書いてきたけれど,これだけ.
今回設定した内容を反映させる. HUPシグナルをsnmpdプロセスに送ることで,反映させる.
$ ps -ef|grep snmpd🆑 0 66808🈁 1 0 17 519 ?? 3:22.25 /usr/libexec/snmpd -f 501 43526 42924 0 6:38PM ttys003 0:00.01 grep snmpd $ sudo kill -HUP 66808🆑 $ ps -ef|grep snmpd🆑 0 66808 1 0 17 519 ?? 3:22.27 /usr/libexec/snmpd -f 501 43533 42924 0 6:39PM ttys003 0:00.00 grep snmpd $
設定した内容が反映されているか確認.
$ snmpwalk -v 2c -c public localhost🆑 SNMPv2-MIB::sysContact.0 = STRING: 管理者メールアドレス SNMPv2-MIB::sysContact.0 = No more variables left in this MIB View (It is past the end of the MIB tree) $
メールアドレスが出てきたから,正しく設定された模様.ただし,最後にNo more variablesとでている.これはアクセス権限がないから.
com2secパラメータを設定して,アクセス制御を行う.
まずは,デフォルトのsnmpd.confを確認.(コメントを外して)
$ cat /etc/snmp/snmpd.conf|grep -v -e '^#'|grep -v -e '^$'🆑 com2sec local localhost COMMUNITY🈁 com2sec mynetwork NETWORK/24 COMMUNITY🈁 group MyRWGroup v1 local group MyRWGroup v2c local group MyRWGroup usm local group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork view all included .1 80 access MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none rwuser admin rocommunity public default .1.3.6.1.2.1.1.4🈁 syslocation Right here, right now. syscontact Administrator <postmaster@example.com> sysservices 76 proc httpd exec echotest /bin/echo hello world exec web_status /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin status web exec netboot /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin status netboot disk / 10000 $
macOSの場合,execの以降の部分がついている模様.Server.appをインストールしているか否かに依存しない. 今回は com2sec local にprivate,com2sec mynetworkにpublicを設定する. また,mibのノードは,.1.3.6.1.2.1.1.4となっているが,最上位を解放する. まずはオリジナルのファイルをバックアップ.
$ sudo cp -p /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.v00🆑 $
変更後の差分を確認.
$ diff /etc/snmp/snmpd.conf.v00 /etc/snmp/snmpd.conf🆑 61,62c61,62 < com2sec local localhost COMMUNITY < com2sec mynetwork NETWORK/24 COMMUNITY --- > com2sec local localhost private > com2sec mynetwork NETWORK/24 public 98c98,99 < rocommunity public default .1.3.6.1.2.1.1.4 --- > #rocommunity public default .1.3.6.1.2.1.1.4 > rocommunity public default .1 103c104 < #rwcommunity private --- > rwcommunity private $
rwcommunity,rwなので書き込みを,privateのコミュニティに許可をする. これで設定完了.
snmpd.confを変更したので,SNMPDを再起動して反映させる.
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist🆑 Password:🆑 $ ps -ef|grep snmpd🆑 501 62844 61321 0 8:02PM ttys003 0:00.00 grep snmpd $ sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist🆑 $ ps -ef|grep snmpd🆑 0 62848 1 0 8:03PM ?? 0:00.20 /usr/libexec/snmpd -f 501 62851 61321 0 8:03PM ttys003 0:00.00 grep snmpd $
情報が取得できるようになったか,確認する.
$ snmpwalk -v 2c -c public localhost|head -n 10🆑 SNMPv2-MIB::sysDescr.0 = STRING: Darwin zeus.local 17.7.0 Darwin Kernel Version 17.7.0: Wed Feb 27 00:43:23 PST 2019; root:xnu-4570.71.35~1/RELEASE_X86_64 x86_64 SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.255 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (9626) 0:01:36.26 SNMPv2-MIB::sysContact.0 = STRING: 管理者メールアドレス SNMPv2-MIB::sysName.0 = STRING: zeus.local SNMPv2-MIB::sysLocation.0 = STRING: BCP SNMPv2-MIB::sysServices.0 = INTEGER: 76 SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDMIBObjects.3.1.1 SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance $
データ取得ができた.
$ cat /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist🆑
Disabled担っているので,起動してないのかな. LaunchDaemonでSNMPDをroot権限で起動する.
$ /usr/bin/snmpconf -h🆑 'overwrite', 'skip', 'rename' or 'append'? : overwrite🆑 $ cat /usr/share/snmp/snmpd.conf🆑
任意のロケーション情報を入力する.ここでは,BCPセンタ用なのでBCPと入力.
$ cat /usr/share/snmp/snmpd.conf🆑 syscontact 管理者メールアドレス
$ sudo /usr/bin/snmpconf -i🆑 Password:🆑 The following installed configuration files were found: 1: /etc/snmp/snmpd.conf 2: /usr/share/snmp/snmpd.conf🈁 Would you like me to read them in? Their content will be merged with the output files created by this session. Valid answer examples: "all", "none","3","1,2,5" Read in which (default = all): 2🆑 I can create the following types of configuration files for you. Select the file type you wish to create: (you can create more than one as you run this program) 1: snmp.conf 2: snmptrapd.conf 3: snmpd.conf🈁 Other options: quit Select File: 3🆑 The configuration information which can be put into snmpd.conf is divided into sections. Select a configuration section for snmpd.conf that you wish to create: 1: Agent Operating Mode 2: Monitor Various Aspects of the Running Host🈁 3: Trap Destinations 4: System Information Setup 5: Extending the Agent 6: Access Control Setup Other options: finished Select section: 2🆑 Section: Monitor Various Aspects of the Running Host Description: The following check up on various aspects of a host. Select from: 1: Check for processes that should be running.🈁 2: Check for disk space usage of a partition. 3: Check for unreasonable load average values. 4: Check on the size of a file. Other options: finished, list Select section:
macOSをサーバとして運用するので,SNMPによって性能などの監視を行いたい.SNMPはSNMPDで情報を得ることができるが,macOSはデフォルトではSNMPDが起動してないので,その起動や,諸設定を行う. 今回は,macOS 10.13.6のHigh Sierraで動作確認した.
まずは,現在SNMPプロセスが起動してない事を確認.
$ ps -ef|grep snmp🆑 501 66796 65920 0 4:51PM ttys003 0:00.00 grep snmp $
プロセスは起動してない. macOSの場合はLaunchDaemonでサーバプロセスを管理しているが,その設定ファイルを確認する.
$ locate snmp|grep plist🆑 /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist $
確認できた設定ファイルの中身を表示.
$ cat /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist🆑 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <true/> <key>Label</key> <string>org.net-snmp.snmpd</string> <key>KeepAlive</key> <true/> <key>Program</key> <string>/usr/sbin/snmpd</string> <key>ProgramArguments</key> <array> <string>snmpd</string> <string>-f</string> </array> <key>ProcessType</key> <string>Background</string> </dict> </plist> $
Disabledになっているので,起動してないのかな. LaunchDaemonでSNMPDをroot権限で起動する.
$ sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist🆑 Password:🆑 $
プロセスを確認.
$ ps -ef|grep snmp🆑 0 66808 1 0 4:52PM ?? 0:00.23 /usr/libexec/snmpd -f🈁 501 66812 65920 0 4:52PM ttys003 0:00.00 grep snmp $
稼働確認できた.
SNMPDプロセスが起動したので,次はsnmpwalkコマンドを使って,SNMPで接続して情報を取得する. コマンドの場所を確認.
$ which snmpwalk🆑 /usr/bin/snmpwalk🈁 $
snmpwalkコマンドで接続してみる.
$ snmpwalk -v 2c -c public localhost🆑 SNMPv2-MIB::sysContact.0 = STRING: Administrator <postmaster@example.com> SNMPv2-MIB::sysContact.0 = No more variables left in this MIB View (It is past the end of the MIB tree) $
何の情報も出てないが,Timeoutとかのエラーになってないので,想定内と言える.
snmpconfコマンドを使うと,/usr/share/snmp/snmpd.confが作成されるが,現在存在しているか確認する.
$ ls -lat /usr/share/snmp🆑 total 60 drwxr-xr-x 47 root wheel 1504 4 3 2018 .. drwxr-xr-x 65 root wheel 2080 7 16 2017 mibs drwxr-xr-x 28 root wheel 896 7 16 2017 . -rw-r--r-- 1 root wheel 16218 7 16 2017 SensorDat.xml drwxr-xr-x 69 root wheel 2208 7 16 2017 mib2c-data -rw-r--r-- 1 root wheel 6531 7 16 2017 mib2c.access_functions.conf -rw-r--r-- 1 root wheel 2391 7 16 2017 mib2c.check_values_local.conf -rw-r--r-- 1 root wheel 28202 7 16 2017 mib2c.container.conf -rw-r--r-- 1 root wheel 8498 7 16 2017 mib2c.genhtml.conf -rw-r--r-- 1 root wheel 3088 7 16 2017 mib2c.int_watch.conf -rw-r--r-- 1 root wheel 2027 7 16 2017 mib2c.notify.conf -rw-r--r-- 1 root wheel 8777 7 16 2017 mib2c.perl.conf -rw-r--r-- 1 root wheel 19509 7 16 2017 mib2c.raw-table.conf -rw-r--r-- 1 root wheel 22905 7 16 2017 mib2c.table_data.conf drwxr-xr-x 5 root wheel 160 7 16 2017 snmpconf-data -rw-r--r-- 1 root wheel 37700 7 16 2017 mib2c.array-user.conf -rw-r--r-- 1 root wheel 4646 7 16 2017 mib2c.check_values.conf -rw-r--r-- 1 root wheel 330 7 16 2017 mib2c.column_defines.conf -rw-r--r-- 1 root wheel 602 7 16 2017 mib2c.column_enums.conf -rw-r--r-- 1 root wheel 728 7 16 2017 mib2c.column_storage.conf -rw-r--r-- 1 root wheel 11942 7 16 2017 mib2c.conf -rw-r--r-- 1 root wheel 3471 7 16 2017 mib2c.create-dataset.conf -rw-r--r-- 1 root wheel 22345 7 16 2017 mib2c.iterate.conf -rw-r--r-- 1 root wheel 15095 7 16 2017 mib2c.iterate_access.conf -rw-r--r-- 1 root wheel 948 7 16 2017 mib2c.mfd.conf -rw-r--r-- 1 root wheel 9182 7 16 2017 mib2c.old-api.conf -rw-r--r-- 1 root wheel 4455 7 16 2017 mib2c.scalar.conf -rw-r--r-- 1 root wheel 431 7 16 2017 snmp_perl_trapd.pl $
snmpd.confは存在しなかった.
sndmpdは,snmpd.confで設定を制御するが,まずは/usr/bin/snmpconfコマンドを使ってカスタマイズする. まずは,コマンドヘルプを.
$ /usr/bin/snmpconf -h🆑 /usr/bin/snmpconf [options] [FILETOCREATE...] options: -f overwrite existing files without prompting -i install created files into /usr/share/snmp. -p install created files into /Users/ujpadmin/.snmp. -I DIR install created files into DIR. -a Don't ask any questions, just read in current current .conf files and comment them -r all|none Read in all or none of the .conf files found. -R file,... Read in a particular list of .conf files. -g GROUP Ask a series of GROUPed questions. -G List known GROUPs. -c conf_dir use alternate configuration directory. -q run more quietly with less advice. -d turn on debugging output. -D turn on debugging dumper output. $
新しいファイルを/usr/share/snmp以下に作成するのでiオプションをつけて実行する.
$ sudo /usr/bin/snmpconf -i🆑 Password:🆑 The following installed configuration files were found: 1: ./snmpd.conf 2: /etc/snmp/snmpd.conf🈁 Would you like me to read them in? Their content will be merged with the output files created by this session. Valid answer examples: "all", "none","3","1,2,5" Read in which (default = all):🈁
他にsnmpd.confファイルが見つかったので,マージするか問い合わせされている. 今回はマージしないので,noneを選択.
Read in which (default = all): none🆑 I can create the following types of configuration files for you. Select the file type you wish to create: (you can create more than one as you run this program) 1: snmp.conf 2: snmptrapd.conf 3: snmpd.conf Other options: quit Select File:
ファイルタイプは,snmpd.confにしたいので,3を選択.
Select File: 3🆑 The configuration information which can be put into snmpd.conf is divided into sections. Select a configuration section for snmpd.conf that you wish to create: 1: Agent Operating Mode 2: Monitor Various Aspects of the Running Host 3: Trap Destinations 4: System Information Setup🈁 5: Extending the Agent 6: Access Control Setup Other options: finished🈁 Select section:
今回は,ここまでで一旦終了するので,finishedと入力.
Select section: finished🆑 I can create the following types of configuration files for you. Select the file type you wish to create: (you can create more than one as you run this program) 1: snmp.conf 2: snmptrapd.conf 3: snmpd.conf Other options: quit🈁 Select File:
終了するのでquitを入力.
Select File: quit🆑 Error: An snmpd.conf file already exists in this directory. 'overwrite', 'skip', 'rename' or 'append'? :
さっきファイルはなかったのに?overwriteを選択.
'overwrite', 'skip', 'rename' or 'append'? : overwrite🆑 The following files were created: snmpd.conf installed in /usr/share/snmp $
ファイルができたようなので,中身を確認.
$ cat /usr/share/snmp/snmpd.conf🆑 ########################################################################### # # snmpd.conf # # - created by the snmpconf configuration program # $
何も設定してないので,何もないね.
snmpconfを実行.
$ sudo /usr/bin/snmpconf -i🆑 Password:🆑 The following installed configuration files were found: 1: /etc/snmp/snmpd.conf 2: /usr/share/snmp/snmpd.conf Would you like me to read them in? Their content will be merged with the output files created by this session. Valid answer examples: "all", "none","3","1,2,5" Read in which (default = all):
2番の設定をマージするので2を選択.
Read in which (default = all): 2🆑 I can create the following types of configuration files for you. Select the file type you wish to create: (you can create more than one as you run this program) 1: snmptrapd.conf 2: snmp.conf 3: snmpd.conf Other options: quit Select File:
3番を選択.
Select File: 3🆑 The configuration information which can be put into snmpd.conf is divided into sections. Select a configuration section for snmpd.conf that you wish to create: 1: Agent Operating Mode 2: Monitor Various Aspects of the Running Host 3: Trap Destinations 4: System Information Setup🈁 5: Extending the Agent 6: Access Control Setup Other options: finished Select section:
今回のセットアップはシステム情報になるので,4を選択.
Select section: 4🆑 Section: System Information Setup Description: This section defines some of the information reported in the "system" mib group in the mibII tree. Select from: 1: The [typically physical] location of the system.🈁 2: The contact information for the administrator 3: The proper value for the sysServices object. Other options: finished, list Select section:
最初は,物理的な場所を設定するので,1を選択.
Select section: 1🆑 Configuring: syslocation Description: The [typically physical] location of the system. Note that setting this value here means that when trying to perform an snmp SET operation to the sysLocation.0 variable will make the agent return the "notWritable" error code. IE, including this token in the snmpd.conf file will disable write access to the variable. arguments: location_string The location of the system:
任意のロケーション情報を入力する.ここでは,BCPセンタ用なのでBCPと入力.
The location of the system: BCP🆑 Finished Output: syslocation BCP🈁 Section: System Information Setup Description: This section defines some of the information reported in the "system" mib group in the mibII tree. Select from: 1: The [typically physical] location of the system. 2: The contact information for the administrator🈁 3: The proper value for the sysServices object. Other options: finished, list Select section:
次に,管理者の連絡先を入力するために2を選択.
Select section: 2🆑 Configuring: syscontact Description: The contact information for the administrator Note that setting this value here means that when trying to perform an snmp SET operation to the sysContact.0 variable will make the agent return the "notWritable" error code. IE, including this token in the snmpd.conf file will disable write access to the variable. arguments: contact_string The contact information:
メールアドレスを設定.
The contact information: 管理者メールアドレス Finished Output: syscontact 管理者メールアドレス Section: System Information Setup Description: This section defines some of the information reported in the "system" mib group in the mibII tree. Select from: 1: The [typically physical] location of the system. 2: The contact information for the administrator 3: The proper value for the sysServices object.🈁 Other options: finished, list Select section:
sysServices Objectの設定を行うので,3を入力.
Select section: 3🆑 Configuring: sysservices Description: The proper value for the sysServices object. arguments: sysservices_number does this host offer physical services (eg, like a repeater) [answer 0 or 1]:🈁
Yesの場合1を,Noの場合0を入力.
does this host offer physical services (eg, like a repeater) [answer 0 or 1]: 0🈁 does this host offer datalink/subnetwork services (eg, like a bridge): 0🈁 does this host offer internet services (eg, supports IP): 1🈁 does this host offer end-to-end services (eg, supports TCP): 1🈁 does this host offer application services (eg, supports SMTP): 1🈁
このように答えると,sysservicesは76となる.
Finished Output: sysservices 76🈁 Section: System Information Setup Description: This section defines some of the information reported in the "system" mib group in the mibII tree. Select from: 1: The [typically physical] location of the system. 2: The contact information for the administrator 3: The proper value for the sysServices object. Other options: finished, list Select section:
これまで設定した内容を確認するのでlistと入力.
Select section: list🆑 Lines defined for section "System Information Setup" so far: syslocation BCP🈁 syscontact 管理者メールアドレス🈁 sysservices 76🈁 Section: System Information Setup Description: This section defines some of the information reported in the "system" mib group in the mibII tree. Select from: 1: The [typically physical] location of the system. 2: The contact information for the administrator 3: The proper value for the sysServices object. Other options: finished, list Select section:
ここまでの内容で保存するのでfinishedやquitを入力して終了する.
Select section: finished🆑 The configuration information which can be put into snmpd.conf is divided into sections. Select a configuration section for snmpd.conf that you wish to create: 1: Agent Operating Mode 2: Monitor Various Aspects of the Running Host 3: Trap Destinations 4: System Information Setup 5: Extending the Agent 6: Access Control Setup Other options: finished Select section: finished🆑 I can create the following types of configuration files for you. Select the file type you wish to create: (you can create more than one as you run this program) 1: snmptrapd.conf 2: snmpd.conf 3: snmp.conf Other options: quit🆑 Select File: quit The following files were created: snmpd.conf installed in /usr/share/snmp $
保存されたsnmpd.confファイルを確認する.
$ cat /usr/share/snmp/snmpd.conf🆑 ########################################################################### # # snmpd.conf # # - created by the snmpconf configuration program # ########################################################################### # SECTION: System Information Setup # # This section defines some of the information reported in # the "system" mib group in the mibII tree. # syslocation: The [typically physical] location of the system. # Note that setting this value here means that when trying to # perform an snmp SET operation to the sysLocation.0 variable will make # the agent return the "notWritable" error code. IE, including # this token in the snmpd.conf file will disable write access to # the variable. # arguments: location_string syslocation BCP # syscontact: The contact information for the administrator # Note that setting this value here means that when trying to # perform an snmp SET operation to the sysContact.0 variable will make # the agent return the "notWritable" error code. IE, including # this token in the snmpd.conf file will disable write access to # the variable. # arguments: contact_string syscontact 管理者メールアドレス # sysservices: The proper value for the sysServices object. # arguments: sysservices_number sysservices 76 $
設定が保存されていることを確認.
プロセス,ディスク容量,ロードアベレージ,ファイルサイズなどの監視を行う設定を行う. まずは,サイド編集モードまで.
$ sudo /usr/bin/snmpconf -i🆑 Password:🆑 The following installed configuration files were found: 1: /etc/snmp/snmpd.conf 2: /usr/share/snmp/snmpd.conf🈁 Would you like me to read them in? Their content will be merged with the output files created by this session. Valid answer examples: "all", "none","3","1,2,5" Read in which (default = all): 2🆑 I can create the following types of configuration files for you. Select the file type you wish to create: (you can create more than one as you run this program) 1: snmp.conf 2: snmptrapd.conf 3: snmpd.conf🈁 Other options: quit Select File: 3🆑 The configuration information which can be put into snmpd.conf is divided into sections. Select a configuration section for snmpd.conf that you wish to create: 1: Agent Operating Mode 2: Monitor Various Aspects of the Running Host🈁 3: Trap Destinations 4: System Information Setup 5: Extending the Agent 6: Access Control Setup Other options: finished Select section: 2🆑 Section: Monitor Various Aspects of the Running Host Description: The following check up on various aspects of a host. Select from: 1: Check for processes that should be running.🈁 2: Check for disk space usage of a partition. 3: Check for unreasonable load average values. 4: Check on the size of a file. Other options: finished, list Select section:
ここから先は,メニューを順番に選んでいく.
Check for processes that should be running.を選択する.
Select section: 1🆑 Configuring: proc🈁 Description: Check for processes that should be running. proc NAME [MAX=0] [MIN=0] NAME: the name of the process to check for. It must match exactly (ie, http will not find httpd processes). MAX: the maximum number allowed to be running. Defaults to 0. MIN: the minimum number to be running. Defaults to 0. The results are reported in the prTable section of the UCD-SNMP-MIB tree Special Case: When the min and max numbers are both 0, it assumes you want a max of infinity and a min of 1. Name of the process you want to check on:
ここでは,Sambaのプロセスを監視する.プロセス名はsmbd. 単純にプロセス名だけを指定する.
Name of the process you want to check on: smbd🆑 Maximum number of processes named 'smbd' that should be running [default = 0]:🆑 Minimum number of processes named 'smbd' that should be running [default = 0]:🆑 Finished Output: proc smbd Section: Monitor Various Aspects of the Running Host Description: The following check up on various aspects of a host. Select from: 1: Check for processes that should be running. 2: Check for disk space usage of a partition. 3: Check for unreasonable load average values. 4: Check on the size of a file. Other options: finished, list Select section:
今回は,プロセス数をmaxもminも,何も指定しないで0(ゼロ)とした.こういう指定をすると,プロセスが1つ以上起動してないとエラーという設定となる.
今回は,例として/Volumes/RAID0_12TBというボリュームが95%を超えるかどうかを監視する.
select section: 2🆑 Configuring: disk🈁 Description: Check for disk space usage of a partition. The agent can check the amount of available disk space, and make sure it is above a set limit. disk PATH [MIN=100000] PATH: mount path to the disk in question. MIN: Disks with space below this value will have the Mib's errorFlag set. Can be a raw integer value (units of kB) or a percentage followed by the % symbol. Default value = 100000. The results are reported in the dskTable section of the UCD-SNMP-MIB tree Enter the mount point for the disk partion to be checked on: /Volumes/RAID0_12TB🆑 Enter the minimum amount of space that should be available on /Volumes/RAID0_12TB: 95%🆑 Finished Output: disk /Volumes/RAID0_12TB 95%🈁 Section: Monitor Various Aspects of the Running Host Description: The following check up on various aspects of a host. Select from: 1: Check for processes that should be running. 2: Check for disk space usage of a partition. 3: Check for unreasonable load average values. 4: Check on the size of a file. Other options: finished, list Select section:
システムドライブを指定する場合は,70%くらいが良いのだと思う.大量にエラーがでたら急激に増えるものだしね.
ロードアベレージは,CPU1つがビジー状態だと1なので,今回は4coreマシンなので,4の倍数で値を設定した.
Select section: 3🆑 Configuring: load Description: Check for unreasonable load average values. Watch the load average levels on the machine. load [1MAX=12.0] [5MAX=12.0] [15MAX=12.0] 1MAX: If the 1 minute load average is above this limit at query time, the errorFlag will be set. 5MAX: Similar, but for 5 min average. 15MAX: Similar, but for 15 min average. The results are reported in the laTable section of the UCD-SNMP-MIB tree Enter the maximum allowable value for the 1 minute load average: 12🆑 Enter the maximum allowable value for the 5 minute load average: 8🆑 Enter the maximum allowable value for the 15 minute load average: 4🆑 Finished Output: load 12 8 4🈁 Section: Monitor Various Aspects of the Running Host Description: The following check up on various aspects of a host. Select from: 1: Check for processes that should be running. 2: Check for disk space usage of a partition. 3: Check for unreasonable load average values. 4: Check on the size of a file. Other options: finished, list Select section:
一旦はこれで.
継続することで大きくなるファイルを監視する.ここではmacosなので,system.logとしている.Linuxだと/var/log/messagesになる. ファイルサイズは30000KB(30Mbyte)とした.
Select section: 4🆑 Configuring: file Description: Check on the size of a file. Display a files size statistics. If it grows to be too large, report an error about it. file /path/to/file [maxsize_in_kilobytes] if maxsize is not specified, assume only size reporting is needed. The results are reported in the fileTable section of the UCD-SNMP-MIB tree Enter the path to the file you wish to monitor: /var/log/system.log🆑 Enter the maximum size (in kilobytes) allowable for /var/log/system.log: 30000🆑 Finished Output: file /var/log/system.log 30000 Section: Monitor Various Aspects of the Running Host Description: The following check up on various aspects of a host. Select from: 1: Check for processes that should be running. 2: Check for disk space usage of a partition. 3: Check for unreasonable load average values. 4: Check on the size of a file. Other options: finished, list Select section:
ここまでで一通り終了.
これまで設定した内容を確認するために,listコマンドを実行.
Select section: list🆑 Lines defined for section "Monitor Various Aspects of the Running Host" so far: proc smbd disk /Volumes/RAID0_12TB 95% load 12 8 4 file /var/log/system.log 30000 Section: Monitor Various Aspects of the Running Host Description: The following check up on various aspects of a host. Select from: 1: Check for processes that should be running. 2: Check for disk space usage of a partition. 3: Check for unreasonable load average values. 4: Check on the size of a file. Other options: finished, list
問題ないので,finishedやquitで終了.
Select section: finished🆑 The configuration information which can be put into snmpd.conf is divided into sections. Select a configuration section for snmpd.conf that you wish to create: 1: Agent Operating Mode 2: Monitor Various Aspects of the Running Host 3: Trap Destinations 4: System Information Setup 5: Extending the Agent 6: Access Control Setup Other options: finished🈁 Select section: finished🆑 I can create the following types of configuration files for you. Select the file type you wish to create: (you can create more than one as you run this program) 1: snmp.conf 2: snmptrapd.conf 3: snmpd.conf Other options: quit🈁 Select File: quit🆑 The following files were created: snmpd.conf installed in /usr/share/snmp🈁 $
設定ファイルが書き出された模様.
ここまでで設定されたsnmpd.confファイルを確認する.
$ cat /usr/share/snmp/snmpd.conf🆑 ########################################################################### # # snmpd.conf # # - created by the snmpconf configuration program # ########################################################################### # SECTION: Monitor Various Aspects of the Running Host # # The following check up on various aspects of a host. # proc: Check for processes that should be running. # proc NAME [MAX=0] [MIN=0] # # NAME: the name of the process to check for. It must match # exactly (ie, http will not find httpd processes). # MAX: the maximum number allowed to be running. Defaults to 0. # MIN: the minimum number to be running. Defaults to 0. # # The results are reported in the prTable section of the UCD-SNMP-MIB tree # Special Case: When the min and max numbers are both 0, it assumes # you want a max of infinity and a min of 1. proc smbd🈁 # disk: Check for disk space usage of a partition. # The agent can check the amount of available disk space, and make # sure it is above a set limit. # # disk PATH [MIN=100000] # # PATH: mount path to the disk in question. # MIN: Disks with space below this value will have the Mib's errorFlag set. # Can be a raw integer value (units of kB) or a percentage followed by the % # symbol. Default value = 100000. # # The results are reported in the dskTable section of the UCD-SNMP-MIB tree disk /Volumes/RAID0_12TB 95%🈁 # load: Check for unreasonable load average values. # Watch the load average levels on the machine. # # load [1MAX=12.0] [5MAX=12.0] [15MAX=12.0] # # 1MAX: If the 1 minute load average is above this limit at query # time, the errorFlag will be set. # 5MAX: Similar, but for 5 min average. # 15MAX: Similar, but for 15 min average. # # The results are reported in the laTable section of the UCD-SNMP-MIB tree load 12 8 4🈁 # file: Check on the size of a file. # Display a files size statistics. # If it grows to be too large, report an error about it. # # file /path/to/file [maxsize_in_kilobytes] # # if maxsize is not specified, assume only size reporting is needed. # # The results are reported in the fileTable section of the UCD-SNMP-MIB tree file /var/log/system.log 30000🈁 ########################################################################### # SECTION: System Information Setup # # This section defines some of the information reported in # the "system" mib group in the mibII tree. # syslocation: The [typically physical] location of the system. # Note that setting this value here means that when trying to # perform an snmp SET operation to the sysLocation.0 variable will make # the agent return the "notWritable" error code. IE, including # this token in the snmpd.conf file will disable write access to # the variable. # arguments: location_string syslocation BCP🈁 # syscontact: The contact information for the administrator # Note that setting this value here means that when trying to # perform an snmp SET operation to the sysContact.0 variable will make # the agent return the "notWritable" error code. IE, including # this token in the snmpd.conf file will disable write access to # the variable. # arguments: contact_string syscontact 管理者メールアドレス # sysservices: The proper value for the sysServices object. # arguments: sysservices_number sysservices 76🈁 $
コメントとかが多い... シンプルに書き直す.
$ cat /usr/share/snmp/snmpd.conf🆑 syslocation BCP syscontact 管理者メールアドレス sysservices 76 proc smbd disk /Volumes/RAID0_12TB 95% disk /Volumes/zeusHD 80% load 12 8 4 file /var/log/system.log 30000 $
たくさん書いてきたけれど,これだけ.
今回設定した内容を反映させる. HUPシグナルをsnmpdプロセスに送ることで,反映させる.
$ ps -ef|grep snmpd🆑 0 66808🈁 1 0 17 519 ?? 3:22.25 /usr/libexec/snmpd -f 501 43526 42924 0 6:38PM ttys003 0:00.01 grep snmpd $ sudo kill -HUP 66808🆑 $ ps -ef|grep snmpd🆑 0 66808 1 0 17 519 ?? 3:22.27 /usr/libexec/snmpd -f 501 43533 42924 0 6:39PM ttys003 0:00.00 grep snmpd $
設定した内容が反映されているか確認.
$ snmpwalk -v 2c -c public localhost🆑 SNMPv2-MIB::sysContact.0 = STRING: 管理者メールアドレス SNMPv2-MIB::sysContact.0 = No more variables left in this MIB View (It is past the end of the MIB tree) $
メールアドレスが出てきたから,正しく設定された模様.ただし,最後にNo more variablesとでている.これはアクセス権限がないから.
com2secパラメータを設定して,アクセス制御を行う.
まずは,デフォルトのsnmpd.confを確認.(コメントを外して)
$ cat /etc/snmp/snmpd.conf|grep -v -e '^#'|grep -v -e '^$'🆑 com2sec local localhost COMMUNITY🈁 com2sec mynetwork NETWORK/24 COMMUNITY🈁 group MyRWGroup v1 local group MyRWGroup v2c local group MyRWGroup usm local group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork view all included .1 80 access MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none rwuser admin rocommunity public default .1.3.6.1.2.1.1.4🈁 syslocation Right here, right now. syscontact Administrator <postmaster@example.com> sysservices 76 proc httpd exec echotest /bin/echo hello world exec web_status /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin status web exec netboot /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin status netboot disk / 10000 $
macOSの場合,execの以降の部分がついている模様.Server.appをインストールしているか否かに依存しない. 今回は com2sec local にprivate,com2sec mynetworkにpublicを設定する. また,mibのノードは,.1.3.6.1.2.1.1.4となっているが,最上位を解放する. まずはオリジナルのファイルをバックアップ.
$ sudo cp -p /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.v00🆑 $
変更後の差分を確認.
$ diff /etc/snmp/snmpd.conf.v00 /etc/snmp/snmpd.conf🆑 61,62c61,62 < com2sec local localhost COMMUNITY < com2sec mynetwork NETWORK/24 COMMUNITY --- > com2sec local localhost private > com2sec mynetwork NETWORK/24 public 98c98,99 < rocommunity public default .1.3.6.1.2.1.1.4 --- > #rocommunity public default .1.3.6.1.2.1.1.4 > rocommunity public default .1 103c104 < #rwcommunity private --- > rwcommunity private $
rwcommunity,rwなので書き込みを,privateのコミュニティに許可をする. これで設定完了.
snmpd.confを変更したので,SNMPDを再起動して反映させる.
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist🆑 Password:🆑 $ ps -ef|grep snmpd🆑 501 62844 61321 0 8:02PM ttys003 0:00.00 grep snmpd $ sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist🆑 $ ps -ef|grep snmpd🆑 0 62848 1 0 8:03PM ?? 0:00.20 /usr/libexec/snmpd -f 501 62851 61321 0 8:03PM ttys003 0:00.00 grep snmpd $
情報が取得できるようになったか,確認する.
$ snmpwalk -v 2c -c public localhost|head -n 10🆑 SNMPv2-MIB::sysDescr.0 = STRING: Darwin zeus.local 17.7.0 Darwin Kernel Version 17.7.0: Wed Feb 27 00:43:23 PST 2019; root:xnu-4570.71.35~1/RELEASE_X86_64 x86_64 SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.255 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (9626) 0:01:36.26 SNMPv2-MIB::sysContact.0 = STRING: 管理者メールアドレス SNMPv2-MIB::sysName.0 = STRING: zeus.local SNMPv2-MIB::sysLocation.0 = STRING: BCP SNMPv2-MIB::sysServices.0 = INTEGER: 76 SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDMIBObjects.3.1.1 SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance $
データ取得ができた.
今回,設定した内容を整理.
$ cat /etc/snmp/snmpd.conf|grep -v -e '^#'|grep -v -e '^$'🆑 com2sec local localhost private com2sec mynetwork NETWORK/24 public group MyRWGroup v1 local group MyRWGroup v2c local group MyRWGroup usm local group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork view all included .1 80 access MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none rwuser admin rocommunity public default .1 rwcommunity private syslocation Right here, right now. syscontact Administrator <postmaster@example.com> sysservices 76 proc httpd exec echotest /bin/echo hello world exec web_status /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin status web exec netboot /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin status netboot disk / 10000 $ $ cat /usr/share/snmp/snmpd.conf|grep -v -e '^#'|grep -v -e '^$'🆑 syslocation BCP syscontact 管理者メールアドレス syslocation BCP sysservices 76 proc smbd disk /Volumes/RAID0_12TB 95% disk /Volumes/zeusHD 80% load 12 8 4 file /var/log/system.log 30000 $
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7426&Netgear_Insight-03.jpg,center)
NETGEARのWi-Fi アクセスポイントのWA510の初期設定を,iPhoneアプリのInsightを使って実施した.
Insightを使うということは,NETGEARにアカウントを作る必要がある.また,
Insightアプリはクラウドと接続していて,WAC510とインターネット経由で通信して設定変更や状態把握などを行なっているそうなのだ.
Insightを使わずこのWAC510を設定しようとすると,Web管理画面があるようなのだけれど,これがログインできない.
ログインできない理由は,Insightを使っているからで,これを解除すればWeb管理画面でログインできるそうだ. ただし,その際には設定が全部消えてしまうというので,最初にローカルWeb管理画面を使うか,Insightクラウドにするかを選択する必要がある.
なお,Insightで管理できるのは2デバイスまでで,それ以上のデバイスを管理する場合には,有料となる模様.
このルータはPoEに対応しているので,デフォルトではACアダプタが付いてないから,買うときに一緒に注文することを忘れないように.
こんなエラーがでるとき.
$ mrtg mrtg.cfg Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 149. Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 604. 2020-08-11 00:55:54, Rateup WARNING: /usr/local/bin/rateup could not read the primary log file for gaia_lan 2020-08-11 00:55:54, Rateup WARNING: /usr/local/bin/rateup The backup log file for gaia_lan was invalid as well 2020-08-11 00:55:54, Rateup WARNING: /usr/local/bin/rateup Can't rename gaia_lan.log to gaia_lan.old updating log file $
vi /usr/bin/mrtgで開いて,次のように書き換える.
変更前:import Socket6 変更後:Socket6->import(qw(inet_pton getaddrinfo));
次に,vi /usr/local/bin/../lib/mrtg2/SNMP_Session.pm で
変更前:if (eval {local $SIG{__DIE__};require Socket6;} && 変更後:if (eval {local $SIG{__DIE__};Socket6->import(qw(inet_pton getaddrinfo));} &&
原因は,Perlのバージョンアップとのこと.
$ locate indexmaker🆑
cfgmakerコマンドを指定し,privateコミュニティの初期設定を行う. 自動作成された設定ファイルを確認.
もう一度. さらにもう一度.
$ /usr/local/bin/indexmaker -h🆑
MRTGとは,マルチルータトラフィックグラファーの略.ルータのIN/OUTトラフィックをグラフ化するツールで,古典的なもの.たくさんのサーバを管理するにはZabbixなどが良いのだろうけれど,今回もシンプルに構築するので,MRTGを選んだ.
インストールはHomeBrewでおこなった.特に問題もなかった.
$ brew info mrtg🆑 mrtg: stable 2.17.7 (bottled)🈁 Multi router traffic grapher https://oss.oetiker.ch/mrtg/ /usr/local/Cellar/mrtg/2.17.7 (110 files, 2.4MB) * Poured from bottle on 2019-05-07 at 00:48:32 From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mrtg.rb ==> Dependencies Required: gd ✔ ==> Analytics install: 30 (30 days), 76 (90 days), 458 (365 days) install_on_request: 26 (30 days), 69 (90 days), 381 (365 days) build_error: 0 (30 days) $
インストールされたか,コマンドの場所を確認. まずは,mrtgコマンド.
$ which mrtg🆑 /usr/local/bin/mrtg🈁 $
そして,設定ファイルを自動的に作成してくれる,cfgmakerの場所を確認.
$ which cfgmaker🆑 /usr/local/bin/cfgmaker🈁 $
まずは,SNMPD.CONFにあるコミュニティ名を確認.
$ grep com2sec /etc/snmp/snmpd.conf🆑 com2sec local localhost private🈁 com2sec mynetwork NETWORK/24 public $
"private"だとわかった. cfgmakerコマンドを指定し,privateコミュニティの初期設定を行う.
$ cfgmaker private@localhost > mrtg.cfg🆑 Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 149. Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 604. --base: Get Device Info on private@localhost: --base: Vendor Id: Unknown Vendor - 1.3.6.1.4.1.8072.3.2.255 --base: Populating confcache --base: Get Interface Info --base: Walking ifIndex --snpd: private@localhost: -> 1 -> ifIndex = 1 --snpd: private@localhost: -> 2 -> ifIndex = 2 --snpd: private@localhost: -> 3 -> ifIndex = 3 --snpd: private@localhost: -> 4 -> ifIndex = 4 --snpd: private@localhost: -> 5 -> ifIndex = 5 --snpd: private@localhost: -> 6 -> ifIndex = 6 --snpd: private@localhost: -> 7 -> ifIndex = 7 --snpd: private@localhost: -> 8 -> ifIndex = 8 --snpd: private@localhost: -> 9 -> ifIndex = 9 --snpd: private@localhost: -> 10 -> ifIndex = 10 --snpd: private@localhost: -> 11 -> ifIndex = 11 --snpd: private@localhost: -> 12 -> ifIndex = 12 --base: Walking ifType --snpd: private@localhost: -> 1 -> ifType = 24 --snpd: private@localhost: -> 2 -> ifType = 55 --snpd: private@localhost: -> 3 -> ifType = 57 --snpd: private@localhost: -> 4 -> ifType = 1 --snpd: private@localhost: -> 5 -> ifType = 1 --snpd: private@localhost: -> 6 -> ifType = 6 --snpd: private@localhost: -> 7 -> ifType = 6 --snpd: private@localhost: -> 8 -> ifType = 6 --snpd: private@localhost: -> 9 -> ifType = 6 --snpd: private@localhost: -> 10 -> ifType = 209 --snpd: private@localhost: -> 11 -> ifType = 1 --snpd: private@localhost: -> 12 -> ifType = 23 --base: Walking ifAdminStatus --snpd: private@localhost: -> 1 -> ifAdminStatus = 1 --snpd: private@localhost: -> 2 -> ifAdminStatus = 2 --snpd: private@localhost: -> 3 -> ifAdminStatus = 2 --snpd: private@localhost: -> 4 -> ifAdminStatus = 2 --snpd: private@localhost: -> 5 -> ifAdminStatus = 2 --snpd: private@localhost: -> 6 -> ifAdminStatus = 1 --snpd: private@localhost: -> 7 -> ifAdminStatus = 1 --snpd: private@localhost: -> 8 -> ifAdminStatus = 2 --snpd: private@localhost: -> 9 -> ifAdminStatus = 1 --snpd: private@localhost: -> 10 -> ifAdminStatus = 1 --snpd: private@localhost: -> 11 -> ifAdminStatus = 1 --snpd: private@localhost: -> 12 -> ifAdminStatus = 1 --base: Walking ifOperStatus --snpd: private@localhost: -> 1 -> ifOperStatus = 1 --snpd: private@localhost: -> 2 -> ifOperStatus = 2 --snpd: private@localhost: -> 3 -> ifOperStatus = 2 --snpd: private@localhost: -> 4 -> ifOperStatus = 2 --snpd: private@localhost: -> 5 -> ifOperStatus = 2 --snpd: private@localhost: -> 6 -> ifOperStatus = 1 --snpd: private@localhost: -> 7 -> ifOperStatus = 2 --snpd: private@localhost: -> 8 -> ifOperStatus = 2 --snpd: private@localhost: -> 9 -> ifOperStatus = 1 --snpd: private@localhost: -> 10 -> ifOperStatus = 1 --snpd: private@localhost: -> 11 -> ifOperStatus = 1 --snpd: private@localhost: -> 12 -> ifOperStatus = 1 --base: Walking ifMtu --snpd: private@localhost: -> 1 -> ifMtu = 16384 --snpd: private@localhost: -> 2 -> ifMtu = 1280 --snpd: private@localhost: -> 3 -> ifMtu = 1280 --snpd: private@localhost: -> 4 -> ifMtu = 0 --snpd: private@localhost: -> 5 -> ifMtu = 0 --snpd: private@localhost: -> 6 -> ifMtu = 1500 --snpd: private@localhost: -> 7 -> ifMtu = 1500 --snpd: private@localhost: -> 8 -> ifMtu = 2304 --snpd: private@localhost: -> 9 -> ifMtu = 1500 --snpd: private@localhost: -> 10 -> ifMtu = 1500 --snpd: private@localhost: -> 11 -> ifMtu = 2000 --snpd: private@localhost: -> 12 -> ifMtu = 1280 --base: Walking ifSpeed --snpd: private@localhost: -> 1 -> ifSpeed = 0 --snpd: private@localhost: -> 2 -> ifSpeed = 0 --snpd: private@localhost: -> 3 -> ifSpeed = 0 --snpd: private@localhost: -> 4 -> ifSpeed = 0 --snpd: private@localhost: -> 5 -> ifSpeed = 0 --snpd: private@localhost: -> 6 -> ifSpeed = 1000000000 --snpd: private@localhost: -> 7 -> ifSpeed = 0 --snpd: private@localhost: -> 8 -> ifSpeed = 10000000 --snpd: private@localhost: -> 9 -> ifSpeed = 0 --snpd: private@localhost: -> 10 -> ifSpeed = 0 --snpd: private@localhost: -> 11 -> ifSpeed = 0 --snpd: private@localhost: -> 12 -> ifSpeed = 100000000 $
自動作成された設定ファイルを確認.
$ cat mrtg.cfg🆑 # Created by # /usr/local/bin/cfgmaker private@localhost ### Global Config Options # for UNIX # WorkDir: /home/http/mrtg # or for NT # WorkDir: c:\mrtgdata ### Global Defaults # to get bits instead of bytes and graphs growing to the right # Options[_]: growright, bits EnableIPv6: no ###################################################################### # System: zeus.local # Description: Darwin zeus.local 17.7.0 Darwin Kernel Version 17.7.0: Wed Feb 27 00:43:23 PST 2019; root:xnu-4570.71.35~1/RELEASE_X86_64 x86_64 # Contact: サーバ管理者メールアドレス # Location: BCP ###################################################################### ### Interface 1 >> Descr: 'lo0' | Name: 'lo0' | Ip: '127.0.0.1' | Eth: 'No Ethernet Id' ### ### The following interface is commented out because: ### * it is a Software Loopback interface ### * has no ifSpeed property # # Target[localhost_1]: 1:private@localhost: # SetEnv[localhost_1]: MRTG_INT_IP="127.0.0.1" MRTG_INT_DESCR="lo0" # MaxBytes[localhost_1]: 0 # Title[localhost_1]: Traffic Analysis for 1 -- zeus.local # PageTop[localhost_1]: <h1>Traffic Analysis for 1 -- zeus.local</h1> # <div id="sysdetails"> # <table> # <tr> # <td>System:</td> # <td>zeus.local in BCP</td> # </tr> # <tr> # <td>Maintainer:</td> # <td>サーバ管理者メールアドレス</td> # </tr> # <tr> # <td>Description:</td> # <td>lo0 </td> # </tr> # <tr> # <td>ifType:</td> # <td>softwareLoopback (24)</td> # </tr> # <tr> # <td>ifName:</td> # <td>lo0</td> # </tr> # <tr> # <td>Max Speed:</td> # <td>0.0 Bytes/s</td> # </tr> # <tr> # <td>Ip:</td> # <td>127.0.0.1 (localhost)</td> # </tr> # </table> # </div> ### Interface 2 >> Descr: 'gif0' | Name: 'gif0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ### ### The following interface is commented out because: ### * it is administratively DOWN ### * it is operationally DOWN ### * has no ifSpeed property # # Target[localhost_2]: 2:private@localhost: # SetEnv[localhost_2]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="gif0" # MaxBytes[localhost_2]: 0 # Title[localhost_2]: Traffic Analysis for 2 -- zeus.local # PageTop[localhost_2]: <h1>Traffic Analysis for 2 -- zeus.local</h1> # <div id="sysdetails"> # <table> # <tr> # <td>System:</td> # <td>zeus.local in BCP</td> # </tr> # <tr> # <td>Maintainer:</td> # <td>server@ujp.jp</td> # </tr> # <tr> # <td>Description:</td> # <td>gif0 </td> # </tr> # <tr> # <td>ifType:</td> # <td>100BaseVG (55)</td> # </tr> # <tr> # <td>ifName:</td> # <td>gif0</td> # </tr> # <tr> # <td>Max Speed:</td> # <td>0.0 Bytes/s</td> # </tr> # <tr> # <td>Ip:</td> # <td>No Ip (No DNS name)</td> # </tr> # </table> # </div> ### Interface 3 >> Descr: 'stf0' | Name: 'stf0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ### ### The following interface is commented out because: ### * it is administratively DOWN ### * it is operationally DOWN ### * has no ifSpeed property # # Target[localhost_3]: 3:private@localhost: # SetEnv[localhost_3]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="stf0" # MaxBytes[localhost_3]: 0 # Title[localhost_3]: Traffic Analysis for 3 -- zeus.local # PageTop[localhost_3]: <h1>Traffic Analysis for 3 -- zeus.local</h1> # <div id="sysdetails"> # <table> # <tr> # <td>System:</td> # <td>zeus.local in BCP</td> # </tr> # <tr> # <td>Maintainer:</td> # <td>server@ujp.jp</td> # </tr> # <tr> # <td>Description:</td> # <td>stf0 </td> # </tr> # <tr> # <td>ifType:</td> # <td>HIPPI Interface (57)</td> # </tr> # <tr> # <td>ifName:</td> # <td>stf0</td> # </tr> # <tr> # <td>Max Speed:</td> # <td>0.0 Bytes/s</td> # </tr> # <tr> # <td>Ip:</td> # <td>No Ip (No DNS name)</td> # </tr> # </table> # </div> ### Interface 4 >> Descr: 'EHC253' | Name: 'EHC253' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ### ### The following interface is commented out because: ### * it is administratively DOWN ### * it is operationally DOWN ### * has no ifSpeed property # # Target[localhost_4]: 4:private@localhost: # SetEnv[localhost_4]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="EHC253" # MaxBytes[localhost_4]: 0 # Title[localhost_4]: Traffic Analysis for 4 -- zeus.local # PageTop[localhost_4]: <h1>Traffic Analysis for 4 -- zeus.local</h1> # <div id="sysdetails"> # <table> # <tr> # <td>System:</td> # <td>zeus.local in BCP</td> # </tr> # <tr> # <td>Maintainer:</td> # <td>server@ujp.jp</td> # </tr> # <tr> # <td>Description:</td> # <td>EHC253 </td> # </tr> # <tr> # <td>ifType:</td> # <td>Other (1)</td> # </tr> # <tr> # <td>ifName:</td> # <td>EHC253</td> # </tr> # <tr> # <td>Max Speed:</td> # <td>0.0 Bytes/s</td> # </tr> # <tr> # <td>Ip:</td> # <td>No Ip (No DNS name)</td> # </tr> # </table> # </div> ### Interface 5 >> Descr: 'EHC250' | Name: 'EHC250' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ### ### The following interface is commented out because: ### * it is administratively DOWN ### * it is operationally DOWN ### * has no ifSpeed property # # Target[localhost_5]: 5:private@localhost: # SetEnv[localhost_5]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="EHC250" # MaxBytes[localhost_5]: 0 # Title[localhost_5]: Traffic Analysis for 5 -- zeus.local # PageTop[localhost_5]: <h1>Traffic Analysis for 5 -- zeus.local</h1> # <div id="sysdetails"> # <table> # <tr> # <td>System:</td> # <td>zeus.local in BCP</td> # </tr> # <tr> # <td>Maintainer:</td> # <td>server@ujp.jp</td> # </tr> # <tr> # <td>Description:</td> # <td>EHC250 </td> # </tr> # <tr> # <td>ifType:</td> # <td>Other (1)</td> # </tr> # <tr> # <td>ifName:</td> # <td>EHC250</td> # </tr> # <tr> # <td>Max Speed:</td> # <td>0.0 Bytes/s</td> # </tr> # <tr> # <td>Ip:</td> # <td>No Ip (No DNS name)</td> # </tr> # </table> # </div> ### Interface 6 >> Descr: 'en3' | Name: 'en3' | Ip: '192.168.100.10' | Eth: '00-6c-8f-44-8a-32' ### Target[localhost_6]: 6:private@localhost: SetEnv[localhost_6]: MRTG_INT_IP="192.168.100.10" MRTG_INT_DESCR="en3" MaxBytes[localhost_6]: 125000000 Title[localhost_6]: Traffic Analysis for 6 -- zeus.local PageTop[localhost_6]: <h1>Traffic Analysis for 6 -- zeus.local</h1> <div id="sysdetails"> <table> <tr> <td>System:</td> <td>zeus.local in BCP</td> </tr> <tr> <td>Maintainer:</td> <td>server@ujp.jp</td> </tr> <tr> <td>Description:</td> <td>en3 </td> </tr> <tr> <td>ifType:</td> <td>ethernetCsmacd (6)</td> </tr> <tr> <td>ifName:</td> <td>en3</td> </tr> <tr> <td>Max Speed:</td> <td>125.0 MBytes/s</td> </tr> <tr> <td>Ip:</td> <td>192.168.100.10 (No DNS name)</td> </tr> </table> </div> ### Interface 7 >> Descr: 'en0' | Name: 'en0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ### ### The following interface is commented out because: ### * it is operationally DOWN ### * has no ifSpeed property # # Target[localhost_7]: 7:private@localhost: # SetEnv[localhost_7]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="en0" # MaxBytes[localhost_7]: 0 # Title[localhost_7]: Traffic Analysis for 7 -- zeus.local # PageTop[localhost_7]: <h1>Traffic Analysis for 7 -- zeus.local</h1> # <div id="sysdetails"> # <table> # <tr> # <td>System:</td> # <td>zeus.local in BCP</td> # </tr> # <tr> # <td>Maintainer:</td> # <td>server@ujp.jp</td> # </tr> # <tr> # <td>Description:</td> # <td>en0 </td> # </tr> # <tr> # <td>ifType:</td> # <td>ethernetCsmacd (6)</td> # </tr> # <tr> # <td>ifName:</td> # <td>en0</td> # </tr> # <tr> # <td>Max Speed:</td> # <td>0.0 Bytes/s</td> # </tr> # <tr> # <td>Ip:</td> # <td>No Ip (No DNS name)</td> # </tr> # </table> # </div> ### Interface 8 >> Descr: 'p2p0' | Name: 'p2p0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ### ### The following interface is commented out because: ### * it is administratively DOWN ### * it is operationally DOWN # # Target[localhost_8]: 8:private@localhost: # SetEnv[localhost_8]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="p2p0" # MaxBytes[localhost_8]: 1250000 # Title[localhost_8]: Traffic Analysis for 8 -- zeus.local # PageTop[localhost_8]: <h1>Traffic Analysis for 8 -- zeus.local</h1> # <div id="sysdetails"> # <table> # <tr> # <td>System:</td> # <td>zeus.local in BCP</td> # </tr> # <tr> # <td>Maintainer:</td> # <td>server@ujp.jp</td> # </tr> # <tr> # <td>Description:</td> # <td>p2p0 </td> # </tr> # <tr> # <td>ifType:</td> # <td>ethernetCsmacd (6)</td> # </tr> # <tr> # <td>ifName:</td> # <td>p2p0</td> # </tr> # <tr> # <td>Max Speed:</td> # <td>1250.0 kBytes/s</td> # </tr> # <tr> # <td>Ip:</td> # <td>No Ip (No DNS name)</td> # </tr> # </table> # </div> ### Interface 9 >> Descr: 'en1' | Name: 'en1' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ### ### The following interface is commented out because: ### * has no ifSpeed property # # Target[localhost_9]: 9:private@localhost: # SetEnv[localhost_9]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="en1" # MaxBytes[localhost_9]: 0 # Title[localhost_9]: Traffic Analysis for 9 -- zeus.local # PageTop[localhost_9]: <h1>Traffic Analysis for 9 -- zeus.local</h1> # <div id="sysdetails"> # <table> # <tr> # <td>System:</td> # <td>zeus.local in BCP</td> # </tr> # <tr> # <td>Maintainer:</td> # <td>server@ujp.jp</td> # </tr> # <tr> # <td>Description:</td> # <td>en1 </td> # </tr> # <tr> # <td>ifType:</td> # <td>ethernetCsmacd (6)</td> # </tr> # <tr> # <td>ifName:</td> # <td>en1</td> # </tr> # <tr> # <td>Max Speed:</td> # <td>0.0 Bytes/s</td> # </tr> # <tr> # <td>Ip:</td> # <td>No Ip (No DNS name)</td> # </tr> # </table> # </div> ### Interface 10 >> Descr: 'bridge0' | Name: 'bridge0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ### ### The following interface is commented out because: ### * has no ifSpeed property # # Target[localhost_10]: 10:private@localhost: # SetEnv[localhost_10]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="bridge0" # MaxBytes[localhost_10]: 0 # Title[localhost_10]: Traffic Analysis for 10 -- zeus.local # PageTop[localhost_10]: <h1>Traffic Analysis for 10 -- zeus.local</h1> # <div id="sysdetails"> # <table> # <tr> # <td>System:</td> # <td>zeus.local in BCP</td> # </tr> # <tr> # <td>Maintainer:</td> # <td>server@ujp.jp</td> # </tr> # <tr> # <td>Description:</td> # <td>bridge0 </td> # </tr> # <tr> # <td>ifType:</td> # <td>Uknown Interface Type (209)</td> # </tr> # <tr> # <td>ifName:</td> # <td>bridge0</td> # </tr> # <tr> # <td>Max Speed:</td> # <td>0.0 Bytes/s</td> # </tr> # <tr> # <td>Ip:</td> # <td>No Ip (No DNS name)</td> # </tr> # </table> # </div> ### Interface 11 >> Descr: 'utun0' | Name: 'utun0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ### ### The following interface is commented out because: ### * has no ifSpeed property # # Target[localhost_11]: 11:private@localhost: # SetEnv[localhost_11]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="utun0" # MaxBytes[localhost_11]: 0 # Title[localhost_11]: Traffic Analysis for 11 -- zeus.local # PageTop[localhost_11]: <h1>Traffic Analysis for 11 -- zeus.local</h1> # <div id="sysdetails"> # <table> # <tr> # <td>System:</td> # <td>zeus.local in BCP</td> # </tr> # <tr> # <td>Maintainer:</td> # <td>server@ujp.jp</td> # </tr> # <tr> # <td>Description:</td> # <td>utun0 </td> # </tr> # <tr> # <td>ifType:</td> # <td>Other (1)</td> # </tr> # <tr> # <td>ifName:</td> # <td>utun0</td> # </tr> # <tr> # <td>Max Speed:</td> # <td>0.0 Bytes/s</td> # </tr> # <tr> # <td>Ip:</td> # <td>No Ip (No DNS name)</td> # </tr> # </table> # </div> ### Interface 12 >> Descr: 'ppp0' | Name: 'ppp0' | Ip: '192.168.20.231' | Eth: 'No Ethernet Id' ### Target[localhost_12]: 12:private@localhost: SetEnv[localhost_12]: MRTG_INT_IP="192.168.20.231" MRTG_INT_DESCR="ppp0" MaxBytes[localhost_12]: 12500000 Title[localhost_12]: Traffic Analysis for 12 -- zeus.local PageTop[localhost_12]: <h1>Traffic Analysis for 12 -- zeus.local</h1> <div id="sysdetails"> <table> <tr> <td>System:</td> <td>zeus.local in BCP</td> </tr> <tr> <td>Maintainer:</td> <td>server@ujp.jp</td> </tr> <tr> <td>Description:</td> <td>ppp0 </td> </tr> <tr> <td>ifType:</td> <td>ppp (23)</td> </tr> <tr> <td>ifName:</td> <td>ppp0</td> </tr> <tr> <td>Max Speed:</td> <td>12.5 MBytes/s</td> </tr> <tr> <td>Ip:</td> <td>192.168.20.231 (No DNS name)</td> </tr> </table> </div> $
コメントアウトされている部分は,今回利用しないのでざっと削除. 今回利用するのは次のように設定.
$ cat mrtg.cfg🆑 ### Global Config Options # for UNIX WorkDir: /Users/ujpadmin/mrtg🈁 ### Global Defaults # to get bits instead of bytes and graphs growing to the right Options[_]: growright, bits EnableIPv6: no ###################################################################### # System: zeus.local # Contact: 管理者のメールアドレス # Location: BCP ###################################################################### ###################################################################### #Thunderbolt LAN ###################################################################### ### Interface 6 >> Descr: 'en3' | Name: 'en3' | Ip: '192.168.100.10' | Eth: '00-6c-8f-44-8a-32' ### Target[ThunderboltLAN]: 6:private@localhost: SetEnv[ThunderboltLAN]: MRTG_INT_IP="192.168.100.10" MRTG_INT_DESCR="en3" MaxBytes[ThunderboltLAN]: 125000000 Title[ThunderboltLAN]: Traffic Analysis for LAN -- zeus.local PageTop[ThunderboltLAN]: <h1>Traffic Analysis for LAN -- zeus.local</h1> <div id="sysdetails"> <table> <tr> <td>System:</td> <td>zeus.local in BCP</td> </tr> <tr> <td>Maintainer:</td> <td>管理者メールアドレス</td> </tr> <tr> <td>Description:</td> <td>en3 </td> </tr> <tr> <td>ifType:</td> <td>ethernetCsmacd (6)</td> </tr> <tr> <td>ifName:</td> <td>en3</td> </tr> <tr> <td>Max Speed:</td> <td>125.0 MBytes/s</td> </tr> <tr> <td>Ip:</td> <td>192.168.100.10 (No DNS name)</td> </tr> </table> </div> ###################################################################### #VPN ###################################################################### ### Interface 12 >> Descr: 'ppp0' | Name: 'ppp0' | Ip: '192.168.20.231' | Eth: 'No Ethernet Id' ### Target[VPN]: 12:private@localhost: SetEnv[VPN]: MRTG_INT_IP="192.168.20.231" MRTG_INT_DESCR="ppp0" MaxBytes[VPN]: 12500000 Title[VPN]: Traffic Analysis for VPN -- zeus.local PageTop[VPN]: <h1>Traffic Analysis for VPN -- zeus.local</h1> <div id="sysdetails"> <table> <tr> <td>System:</td> <td>zeus.local in BCP</td> </tr> <tr> <td>Maintainer:</td> <td>管理者メールアドレス</td> </tr> <tr> <td>Description:</td> <td>ppp0 </td> </tr> <tr> <td>ifType:</td> <td>ppp (23)</td> </tr> <tr> <td>ifName:</td> <td>ppp0</td> </tr> <tr> <td>Max Speed:</td> <td>12.5 MBytes/s</td> </tr> <tr> <td>Ip:</td> <td>192.168.20.231 (No DNS name)</td> </tr> </table> </div> $
これで問題ないと思う.
mrtg.cfgファイルを読み込ませながら,mrtgコマンドを実行する.
$ mrtg mrtg.cfg🆑 ----------------------------------------------------------------------- ERROR: Mrtg will most likely not work properly when the environment variable LANG is set to UTF-8. Please run mrtg in an environment where this is not the case. Try the following command to start: env LANG=C /usr/local/bin/mrtg mrtg.cfg🈁 ----------------------------------------------------------------------- $
環境変数がCである必要がある. 指定して3回実行.
$ mrtg mrtg.cfg🆑 Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 149. Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 604. 2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup could not read the primary log file for thunderboltlan 2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup The backup log file for thunderboltlan was invalid as well 2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup Can't rename thunderboltlan.log to thunderboltlan.old updating log file 2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup could not read the primary log file for vpn 2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup The backup log file for vpn was invalid as well 2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup Can't rename vpn.log to vpn.old updating log file $
もう一度.
$ mrtg mrtg.cfg🆑 Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 149. Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 604. $
さらにもう一度.
$ mrtg mrtg.cfg🆑 Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 149. Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 604. $
3回実行する理由は,初回はファイルが無いのでエラーがでるのだが,ここでは別のエラーがでている...
このエラーは,Perlのバージョンが新しい場合に出る模様. コードを書き換えれば修正される.次のように.バックアップを取った後に修正する.
$ cp -p /usr/local/bin/mrtg /usr/local/bin/mrtg.v00🆑 $ diff /usr/local/bin/mrtg.v00 /usr/local/bin/mrtg🆑 305c305 < import Socket6; --- > Socket6->import(qw(inet_pton getaddrinfo));🈁 $
もう1つ.
$ cp -p /usr/local/Cellar/mrtg/2.17.7/lib/mrtg2/SNMP_Session.pm /usr/local/Cellar/mrtg/2.17.7/lib/mrtg2/SNMP_Session.pm.v00🆑 $ diff /usr/local/Cellar/mrtg/2.17.7/lib/mrtg2/SNMP_Session.pm.v00 /usr/local/Cellar/mrtg/2.17.7/lib/mrtg2/SNMP_Session.pm🆑 149c149 < Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo)); --- > Socket6->import(qw(inet_pton getaddrinfo));🈁 604c604 < Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo)); --- > Socket6->import(qw(inet_pton getaddrinfo));🈁 $
再度実行してみる.
$ mrtg mrtg.cfg $
エラーは出なかった.ファイルを確認.
$ pwd🆑 /Users/ujpadmin/mrtg $ ls -la🆑 total 288 drwxr-xr-x 22 ujpadmin staff 704 May 29 17:56 . drwxr-xr-x+ 26 ujpadmin staff 832 May 29 17:29 .. -rw-r--r-- 1 ujpadmin staff 538 May 29 12:53 mrtg-l.png -rw-r--r-- 1 ujpadmin staff 414 May 29 12:53 mrtg-m.png -rw-r--r-- 1 ujpadmin staff 1759 May 29 12:53 mrtg-r.png -rw-r--r-- 1 ujpadmin staff 2542 May 29 17:00 mrtg.cfg -rw-r--r-- 1 ujpadmin staff 13435 May 29 12:44 mrtg.cfg.org -rw-r--r-- 1 ujpadmin staff 0 May 29 17:56 mrtg.ok -rw-r--r-- 1 ujpadmin staff 1798 May 29 17:56 thunderboltlan-day.png -rw-r--r-- 1 ujpadmin staff 1544 May 29 17:18 thunderboltlan-month.png -rw-r--r-- 1 ujpadmin staff 1688 May 29 17:56 thunderboltlan-week.png -rw-r--r-- 1 ujpadmin staff 1748 May 29 12:53 thunderboltlan-year.png -rw-r--r-- 1 ujpadmin staff 6362 May 29 17:56 thunderboltlan.html -rw-r--r-- 1 ujpadmin staff 49224 May 29 17:56 thunderboltlan.log -rw-r--r-- 1 ujpadmin staff 49206 May 29 17:29 thunderboltlan.old -rw-r--r-- 1 ujpadmin staff 1761 May 29 17:56 vpn-day.png -rw-r--r-- 1 ujpadmin staff 1514 May 29 17:18 vpn-month.png -rw-r--r-- 1 ujpadmin staff 1629 May 29 17:56 vpn-week.png -rw-r--r-- 1 ujpadmin staff 1748 May 29 12:53 vpn-year.png -rw-r--r-- 1 ujpadmin staff 6309 May 29 17:56 vpn.html -rw-r--r-- 1 ujpadmin staff 49223 May 29 17:56 vpn.log -rw-r--r-- 1 ujpadmin staff 49204 May 29 17:29 vpn.old $
ファイルができていることが確認できた.
MRTGのグラフをWebブラウザで参照するための,インデックスページを自動的に作成してくれる. これは最初に1回実行すれば良いが,定義を追加した際に,毎回実行すれば良い.
インデックス作成用のindexmakerコマンドを探す.
$ locate indexmaker🆑 /usr/local/Cellar/mrtg/2.17.7/bin/indexmaker /usr/local/Cellar/mrtg/2.17.7/share/doc/mrtg2/indexmaker.1 /usr/local/Cellar/mrtg/2.17.7/share/doc/mrtg2/indexmaker.pod /usr/local/Cellar/mrtg/2.17.7/share/doc/mrtg2/indexmaker.txt /usr/local/Cellar/mrtg/2.17.7/share/man/man1/indexmaker.1 /usr/local/bin/indexmaker /usr/local/share/man/man1/indexmaker.1 $
コマンドヘルプを確認.
$ /usr/local/bin/indexmaker -h🆑 Option h is ambiguous (headeradd, headeradd-file, headlevel, height, help) Usage: indexmaker [options] mrtg.cfg [other.cfg ...] Options: --output=filename set output filename (default: stdout) --filter title=~regexp select targets by matching regexp against titles --filter pagetop=~regexp select targets by matching regexp against pagetop --filter name=~regexp select targets by matchin regexp against name --addhead=text insert this text between </TITLE> and </HEAD> --title=text set title of generated index file --subtitle=text add a subtitle to the generated index file --bodyopt=text set body tag options --headlevel=number use <Hnumber> at top of page (default: 1) --pagetop=text insert this text between <BODY> and <H1>...</H1> --pageend=text insert this text after the main body --pagetopend=text use this text for pagetop or pageend if undefined --nolegend do not add the Mrtg legend at the end of the page --columns=number show graphs in a table with x columns (default: 2) --perhost show graphs of the same host on a row --compact try to make a vertically more compact page --optlog log the used command line in the page (default: log) --sort=title sort graphs by title --sort=name sort graphs by their name --sort=descr sort graphs by their description --sort=original leave as is (default) --enumerate add a sequence number to the title of each graph --picfirst place pictures before text (default: text first) --width=number set width of graphs (default: not set) --height=number --sidebyside place text / pictures side by side (default: above/below) --bold use bold text (default: bold) --clicktext make the text link to the inner page (like the image) --show=day pick which graph to show in the index (default) --show=week --show=month --show=year --show=none --section=h1 h1 tag from pagetop as section heading (default) --section=title title as section headings for graphs --section=name graph name as section heading --section=descr graph description as section heading --section=ifname interface name (ifName) as section heading --section=portname port name entry in pagetop as section heading --sectionhost Try to prepend the host to the section heading if missing --rrdviewer=path path to rrdviewer (default: /cgi-bin/14all.cgi) --icondir=path path to icondir --prefix=path path from the location of the index.html to the graphs --headeradd=string add string to the html page header --autoprefix try to set prefix automatically --<opt>-file=file read string argument for option <opt> from file $
今回は,パラメータを指定せずに,デフォルトで実行. 実行結果は標準出力にでてくるので,ファイルへリダイレクトする.
$ indexmaker mrtg.cfg > index.html🆑 $ ls -la index.html🆑 -rw-r--r-- 1 ujpadmin staff 2644 May 29 18:28 index.html🈁 $
あとは,作成されたHTMLをWebブラウザで表示させる.
こんなエラーがでるとき.
$ mrtg mrtg.cfg Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 149. Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66. at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 604. 2020-08-11 00:55:54, Rateup WARNING: /usr/local/bin/rateup could not read the primary log file for gaia_lan 2020-08-11 00:55:54, Rateup WARNING: /usr/local/bin/rateup The backup log file for gaia_lan was invalid as well 2020-08-11 00:55:54, Rateup WARNING: /usr/local/bin/rateup Can't rename gaia_lan.log to gaia_lan.old updating log file $
vi /usr/bin/mrtgで開いて,次のように書き換える.
変更前:import Socket6 変更後:Socket6->import(qw(inet_pton getaddrinfo));
次に,vi /usr/local/bin/../lib/mrtg2/SNMP_Session.pm で
変更前:if (eval {local $SIG{__DIE__};require Socket6;} && 変更後:if (eval {local $SIG{__DIE__};Socket6->import(qw(inet_pton getaddrinfo));} &&
原因は,Perlのバージョンアップとのこと.
次のURLからダウンロードする.
Microsoft Network Monitor 3.4 (archive)
https://www.microsoft.com/en-us/download/details.aspx?id=4865
ダウンロードする際には,アーキテクチャを選択する.
今回は,Intel 64bitなのでNM34_x64.exeを選択.
ダウンロードしたファイルはそのままでは実行できないので,セキュリティの許可を行う.
[許可する]をチェックしてOKで閉じて,そのあと実行.
今回来たフィッシングメール. 楽天市場カスタマーを騙っているが,返信先のinforというのは正当なメールアドレスなのだろうか. 日本語もおかしい.「これは、カードが期限切れになったか。請求先住所が変更されたなど」とある.句読点に違和感があるので,わかりやすい.
そして電話番号も記載されている点が,最近受け取ったフィッシングメールの中にない特徴.
まずメールヘッダを確認.ご丁寧に,該当のメールアドレスはmyspaceから流出したものなので,それが記載されている. そのほかは,メールサーバのIPアドレスなどが見て取れる. 本文には,フィッシング先のURLが記載. 楽天のURLに見せかけて,結局.xyzになっているよくあるパターン.スマホのブラウザでみると,先頭の文字しか表示されなかったりすることを利用した詐欺.
もう1つURLが存在しているが,これはユーザ識別のためと思われるパラメータがついているので,メール配信サービスを利用しているのかと想像.
まずは仕入れたIPアドレスからAbuseIPDBで確認.
半数以上は,問題のあるIPアドレスだとされている. メールを配信したサーバにアクセスして見たけれど,ここは404で何も用意されてない模様. 今回はRobotexというサイトを使ってFQDNを調査.実際に割り当てられているIPアドレスが確認できた. また,これも今回初めてaguseというサイトを利用. ドメインがまだ取得されてから1ヶ月程度であることがわかるけれど,それ以上の情報は今回は取れなかった.
Maltegoを使って,VirusTotalでチェックを実行すると,IPアドレスに対して複数のハッシュ値が. それらを展開すると,見るも無残に... そして電話番号をGoogleで検索すると,なりすまし詐欺メールという情報が次々と出てきます.この電話番号は使われてないのだろうなぁ.
いつも可視化の訓練のために使っている迷惑メールだけれど,今回はこれまでと違い次のような要素が.
過去の体験から,迷惑メール発見から数時間程度するとフィッシング先のサイトは閉じられていることが多いけれど,今回はサンプリングできるのかな?と期待してみる.
¶#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7331&spam20200619_01_mail.png,center,mw:600,mh:600)
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7330&spam20200619_02_mail_header.png,center,mw:600,mh:600)
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7329&spam20200619_03_mail_body.png,center,mw:600,mh:600)
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7328&spam20200619_04_mail_body.png,center,mw:600,mh:600)
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7326&spam20200619_05_abuseipdb.png,center,mw:600,mh:600)
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7327&spam20200619_05_webAccess.png,center,mw:600,mh:600)
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7325&spam20200619_06_robotex.png,center,mw:600,mh:600)
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7324&spam20200619_07_aguse.png,center,mw:600,mh:600)
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7323&spam20200619_08_IPaddress_virustotal.png,center,mw:600,mh:600)
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7322&spam20200619_09_Hash_virustotal.png,center,mw:600,mh:600)
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7321&spam20200619_10_TelephoneNumber_google.png,center,mw:600,mh:600)
いつも可視化の訓練のために使っている迷惑メールだけれど,今回はこれまでと違い次のような要素が.
過去の体験から,迷惑メール発見から数時間程度するとフィッシング先のサイトは閉じられていることが多いけれど,今回はサンプリングできるのかな?と期待してみる.
今回来たフィッシングメール.
楽天市場カスタマーを騙っているが,返信先のinforというのは正当なメールアドレスなのだろうか.
日本語もおかしい.「これは、カードが期限切れになったか。請求先住所が変更されたなど」とある.句読点に違和感があるので,わかりやすい.
そして電話番号も記載されている点が,最近受け取ったフィッシングメールの中にない特徴.
まずメールヘッダを確認.ご丁寧に,該当のメールアドレスはmyspaceから流出したものなので,それが記載されている.
そのほかは,メールサーバのIPアドレスなどが見て取れる.
本文には,フィッシング先のURLが記載.
楽天のURLに見せかけて,結局.xyzになっているよくあるパターン.スマホのブラウザでみると,先頭の文字しか表示されなかったりすることを利用した詐欺.
もう1つURLが存在しているが,これはユーザ識別のためと思われるパラメータがついているので,メール配信サービスを利用しているのかと想像.
まずは仕入れたIPアドレスからAbuseIPDBで確認.
半数以上は,問題のあるIPアドレスだとされている.
メールを配信したサーバにアクセスして見たけれど,ここは404で何も用意されてない模様.
今回はRobotexというサイトを使ってFQDNを調査.実際に割り当てられているIPアドレスが確認できた.
また,これも今回初めてaguseというサイトを利用.
ドメインがまだ取得されてから1ヶ月程度であることがわかるけれど,それ以上の情報は今回は取れなかった.
Maltegoを使って,VirusTotalでチェックを実行すると,IPアドレスに対して複数のハッシュ値が.
それらを展開すると,見るも無残に...
そして電話番号をGoogleで検索すると,なりすまし詐欺メールという情報が次々と出てきます.この電話番号は使われてないのだろうなぁ.
今回の最初の調査対象は,誘導先のメールアドレスと,メールアドレス. このメールアドレスの途中に+があるのは,特徴出来だな.(Googleのサブメールアドレス取得の手法) そしてこのメールの文章は,何を示しているのかDeepLで翻訳.ちょっと何言っているのか,わかりません. まずは,メールの返信先のMXレコードを調査.Google[.]comなのでGmailを使っている模様. 誘導先のWebサイト.該当のIPアドレスには,複数のドメインが割り当てられていて,その一部にマルウェアがあると表示されている. ハッシュ値を調べると,いくつかのセキュリティベンダでの評価が. 詳細を確認するために,VirusTotalのサイトを確認したが,73分の5なので,悪いと言い切れないか. 通信先(C2サーバか,リフレクション攻撃先か)にあたるIPアドレスが出ていたので,調査. これもGoogleでした.172で始まるのでついつい,プライベートアドレスかな?って誤認識してしまう. 次にメールヘッダを確認してみたが,これもGmailで利用されているメールサーバなので,怪しいわけではない. そして誘導先のサイトに行ってみた. フランス語で,ノーコメントと書かれているけれど,すぐ転送されちゃうね.Googleの検索ページに.これは封鎖されているからと考えている.
¶#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7315&spam20200618_01.png,center,mw:600,mh:600) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7313&spam20200618_02.png,center,mw:600,mh:600) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7314&spam20200618_03_mx_record.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7312&spam20200618_04_WebSite.png,center,mw:600,mh:600) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7311&spam20200618_05_hash.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7310&spam20200618_06_hash_VirusTotal1.png,center,mw:600,mh:600) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7309&spam20200618_07_hash_VirusTotal2.png,center,mw:600,mh:600) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7308&spam20200618_08_Google.png,center,mw:600,mh:600) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7307&spam20200618_09_MailHeader.png,center,mw:600,mh:600) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7306&spam20200618_10_website.png,center,mw:600,mh:600) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7305&spam20200618_11_website_comment.png,center,mw:600,mh:600)
最近は,Amazonをかたる迷惑メールばかりで,面白くないのだけれど,なんだかわからないメールが来たので,可視化してみた.
まぁ,これもちょっと気づくのが遅かったので,フィッシングサイトか偽ブランドショッピングサイトと思われるものは,既に無くなっていた.
やはり調査もスピード命だね.
逆にいうと,怪しいメールが来たら,数日寝かせておくと,本当に怪しいサイトだったら潰されているし,その逆もあるということじゃないかな.
今回の最初の調査対象は,誘導先のメールアドレスと,メールアドレス. このメールアドレスの途中に+があるのは,特徴出来だな.(Googleのサブメールアドレス取得の手法)
そしてこのメールの文章は,何を示しているのかDeepLで翻訳.ちょっと何言っているのか,わかりません.
まずは,メールの返信先のMXレコードを調査.Google[.]comなのでGmailを使っている模様.
誘導先のWebサイト.該当のIPアドレスには,複数のドメインが割り当てられていて,その一部にマルウェアがあると表示されている.
ハッシュ値を調べると,いくつかのセキュリティベンダでの評価が.
詳細を確認するために,VirusTotalのサイトを確認したが,73分の5なので,悪いと言い切れないか.
通信先(C2サーバか,リフレクション攻撃先か)にあたるIPアドレスが出ていたので,調査.
これもGoogleでした.172で始まるのでついつい,プライベートアドレスかな?って誤認識してしまう.
次にメールヘッダを確認してみたが,これもGmailで利用されているメールサーバなので,怪しいわけではない.
そして誘導先のサイトに行ってみた.
フランス語で,ノーコメントと書かれているけれど,すぐ転送されちゃうね.Googleの検索ページに.これは封鎖されているからと考えている.
ネットワークアナライザーツールといえば最近はこのWiresharkを使うことが多い模様.昔は,Snifferやtcpdumpを使っていたけれど,このWiresharkはGUI部分で,データのキャプチャはその他のツールを使う. このドキュメントを作っている時点で,このツールについては詳しくないのだけれど,Wiresharkだけではデータの取りこぼしもあるので,ネットワークキャプチャは,それぞれまた別のツールを選択することもある模様. 今回の手順では,NpcapとUSBPcapのインストールも行う.
アプリは,公式サイトからダウンロードできる.
WindowsやmacOSも選べる. インストールしたい対象のOSをクリックするとダウンロードできる.
入手したインストーラを実行するだけでよい.
TSharkというのは,コマンドライン版だということ. Plugins & Extensionsに何があるか確認する. Toolsの中身を確認. AndroiddumpとかSshdumpなどはちょっと興味があるが,今回は気にしない. Npcapはインストールする. USBPcapもインストールする. ファイルのコピーが始まる. まずは,Npcapのライセンスの確認. WiFiのキャプチャをしたいので,これを選択. 成功. Npcapのインストールは完了. 次は,USBPcapのインストール. USBPcapのインストールも完了. Wiresharkのインストールは完了. OSのリブートが必要.
OSを再起動後,Wiresharkがインストールされて正常に動作するか確認.
スタートメニューにアイコンの追加を確認. 問題なく起動した.
#ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7274&20200616_011024wireshark.png,center,mw:600,mh:600) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7275&20200616_011940.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7276&20200616_012009.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7277&20200616_012042.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7278&20200616_012126.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7279&20200616_012155.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7280&20200616_012238.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7281&20200616_012303.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7282&20200616_012333.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7283&20200616_012406.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7284&20200616_012432.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7285&20200616_012453.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7286&20200616_012543.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7287&20200616_012615.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7288&20200616_012650.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7289&20200616_012753.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7290&20200616_012911.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7291&20200616_012935.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7292&20200616_013003.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7293&20200616_013044.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7294&20200616_013108.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7295&20200616_013148.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7296&20200616_013226.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7297&20200616_013255.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7298&20200616_013317.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7299&20200616_013419.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7300&20200616_013441.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7301&20200616_014831.png,center) #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7302&20200616_014938.png,center,mw:600,mh:600)
ネットワークアナライザーツールといえば最近はこのWiresharkを使うことが多い模様.昔は,Snifferやtcpdumpを使っていたけれど,このWiresharkはGUI部分で,データのキャプチャはその他のツールを使う.
このドキュメントを作っている時点で,このツールについては詳しくないのだけれど,Wiresharkだけではデータの取りこぼしもあるので,ネットワークキャプチャは,それぞれまた別のツールを選択することもある模様. 今回の手順では,NpcapとUSBPcapのインストールも行う.
入手したインストーラを実行するだけでよい.
TSharkというのは,コマンドライン版だということ.
Plugins & Extensionsに何があるか確認する.
Toolsの中身を確認.
AndroiddumpとかSshdumpなどはちょっと興味があるが,今回は気にしない.
Npcapはインストールする.
USBPcapもインストールする.
ファイルのコピーが始まる.
まずは,Npcapのライセンスの確認.
WiFiのキャプチャをしたいので,これを選択.
成功.
Npcapのインストールは完了.
次は,USBPcapのインストール.
USBPcapのインストールも完了.
Wiresharkのインストールは完了.
OSのリブートが必要.
数あるドメインのうちで,1つを適当にピックアップしてWebサイトがあることを確認.
検出されたFQDNは,ベトナムのセキュリティベンチャー会社CyRadarから疑わしいサイトとして評価されている模様.
迷惑メール到着ほやほやなので,フィッシングサイトにアクセスしてみた. よくある典型的なログインサイトを模したものになっている.
存在しなさそうな適当なメールアドレスを入力. パスワードも適当に入力. ログインできました.
そして個人情報を投入しろという画面になる.
よくみると,お届け先がアメリカになっている... 今回はChromiumを使っているのだけれど,サイトのソースコードを表示. #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7260&MeiwakuMail20200606_13.png,center) アマゾンのロゴのファイルが登録されている.これは本物を登用したに違いない.
back.pngという画像を確認.
ログイン画面の後ろに表示されているものが1枚の画像になっている.
この画像も日本向け. 気になったのがこのURL. このs.amazon-adsystem.comを調査すると,アマゾンの正式な広告サイトの模様.
この広告IDを調査すれば,犯人のたどり着けるかもしれない...ただの偽装かもしれないが,つまりフィッシングサイトを見るだけで犯人に広告収入が入る可能性があるのかと.
迷惑メールが到着して数時間経過していると,分析しようにもサイトが閉鎖されていることが多い.それはそれで対応者は優秀だと思うのだけれど,分析の訓練をしている私にとっては,ちょっと残念.
そう思っていた矢先,とうとう迷惑メールが到着して数分で気付いたので,さっそく可視化をしてみた.
基本的には,メールヘッダの中にあるメールサーバのIPアドレス,ドメインと,フィッシングサイトなので誘導用のサイトのURLがあるので,そのホスト名,ドメイン名の情報を収集する.
今回はアマゾンを語るフィッシングサイト.
まずはメールヘッダ.Amazonじゃなくてアーゾンになっている.
メールサーバのFQDNをゲット.
それぞれのFQDNからIPアドレスを調査.香港の模様.
フィッシングサイトが使っているIPアドレスに割り当てられている別のドメインを調査.
見た目でこれは危ないというようなドメインが散見される.
数あるドメインのうちで,1つを適当にピックアップしてWebサイトがあることを確認.
検出されたFQDNは,ベトナムのセキュリティベンチャー会社CyRadarから疑わしいサイトとして評価されている模様.
迷惑メール到着ほやほやなので,フィッシングサイトにアクセスしてみた.
よくある典型的なログインサイトを模したものになっている.
存在しなさそうな適当なメールアドレスを入力.
パスワードも適当に入力.
ログインできました.
そして個人情報を投入しろという画面になる.
よくみると,お届け先がアメリカになっている...
今回はChromiumを使っているのだけれど,サイトのソースコードを表示.
アマゾンのロゴのファイルが登録されている.これは本物を登用したに違いない.
back.pngという画像を確認.
ログイン画面の後ろに表示されているものが1枚の画像になっている.
この画像も日本向け.
気になったのがこのURL.
このs.amazon-adsystem.comを調査すると,アマゾンの正式な広告サイトの模様.
この広告IDを調査すれば,犯人のたどり着けるかもしれない...ただの偽装かもしれないが,つまりフィッシングサイトを見るだけで犯人に広告収入が入る可能性があるのかと.
試しに,VirusTotalのサイトでハッシュ値を検索. 該当の危ないサイトを確認してみる. #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7245&MaltegoVirustotal12.png,center,mw:600,mh:600) よくある,目的が微妙な比較サイト.
少し不自然なのは,AdSenseなどの広告などがついていなかったり,プライバシーポリシー等の記載もない.
改めて,ドメインからわかる情報を可視化.
GMOインターネットでドメインを取得したことはわかる. 2019年12月3日には,このIPアドレスを使っていることもわかる. #ref(http://www.ujp.jp/modules/xelfinder/index.php?page=view&file=7244&MaltegoVirustotal15.png,center,mw:600,mh:600) IPアドレスから調べると,アメリカのさくらインターネットのような格安ホスティング業者のlinodeが出てきた.
表面上,問題ないサイトに見えて,そのサイトはもしかして重要なものを隠蔽して飄々としている仮面サイトかもしれないし,普通に脆弱性の問題によって乗っ取られているだけかもしれない.
今回の場合,Webで見ることのできる情報にあるべきものが一つもなくて何のために構築されたサイトかもわからないので,裏で何か不穏なものが稼働している気配があるので,これは悪性サイトなのだろうと判断できる.
ということで,初めてアクセスするサイトは,VirusTotalでチェックすべき.できないか.
Maltegoはセキュリティツールの中でも可視化ツールと言われていて,攻撃者が残した足跡,例えばログの中にあるIPアドレスだとか誘導サイトのURL,送り込んできたファイルのハッシュ値などを元に,その情報から関連情報を簡単に取り出し,危険かそうでないか判断するために用いるツール.
そのMaltegoには,「トランスフォーム」という機能拡張機能があって,情報提供サイトがそれぞれに用意するAPIなどを用いて,多方面から関連情報を表示させるツールがある.
今回は,MaltegoにVirusTotalのトランスフォームを追加して,怪しいサイトのURLをつかって可視化していく.
トランスフォームは,デフォルトのメニューの中に存在している.
利用は無料.
このトランスフォームは,Malformitylabs[.]comというサイトが提供している.
インストールする際には,別途VirusTotalで無料のアカウントを取得し,そのアカウント用に発行されているAPIキーを登録する必要がある.
このトランスフォームの提供先のMalformitylabsについて,信頼できるかは自分で確認しておく.
15種類のトランスフォームがある模様.
ちょっと危険だと警告のあったURLを入手したので,試してみる.
まずは,ドメインの追加.
追加して右クリックすると,VirusTotalのトランスフォーム([VTPUB]とあるもの)が選択可能になる.
今回は,Communicating Samplesを選択.
たくさんのハッシュ値が出てきた.
次に,そのハッシュ値を選択して,Check Hash Reportを選択.
いろいろ出てきた.怖すぎる.
試しに,VirusTotalのサイトでハッシュ値を検索.
45サイト中42サイトが危ないと警告が出ている...
該当の危ないサイトを確認してみる.
よくある,目的が微妙な比較サイト.
少し不自然なのは,AdSenseなどの広告などがついていなかったり,プライバシーポリシー等の記載もない.
改めて,ドメインからわかる情報を可視化.
GMOインターネットでドメインを取得したことはわかる.
2019年12月3日には,このIPアドレスを使っていることもわかる.
IPアドレスから調べると,アメリカのさくらインターネットのような格安ホスティング業者のlinodeが出てきた.
先日と同じ,ルイ・ヴィトンの安売りの迷惑メールが来た.前回はメール到着後,半日程度経って気づいていたので,分析を始めたらサイトが止められていて,そこまでだったので,今回はもっと速く分析してみようとチャレンジしてみた.
こんなメール.
以前分析したものと文面も商品も同じ. サブジェクトとメアドと誘導されるメールアドレスも同じ.DKIMとDomainKeyが設定されていることも確認.
商品の価格も一緒だったけれど,リンク先のドメインが異なることを確認.ちなみに,前回とは違うメアドに来たのだけれど,URLパラメータは一部異なっていた.個体判定なのかもしれない.
まず,メールを送信して来たメアドについて流出したものかどうかを確認.
流出の事実はないので,乗っ取られたことでもないようだ. その他の属性を確認.蹴っ翌サイトは404エラーになっているし,数値で適当に取られたドメインで,GoDaddyやdomainbyorixyなど,同じ手口であることが判明.
扱っている素材がルイ・ヴィトンだからか,ロックダウンまでの時間がとても短く素早く対応されていることがわかる.
先日と同じ,ルイ・ヴィトンの安売りの迷惑メールが来た.前回はメール到着後,半日程度経って気づいていたので,分析を始めたらサイトが止められていて,そこまでだったので,今回はもっと速く分析してみようとチャレンジしてみた.