SNMPマネージャ (snmp) MIBデータ↑↓snmpget SNMPエージェント (snmpd) ↑ MIB --- Apache ↑公開 HTML文書「ディレクトリ」 格納↑ 「グラフ化」 MRTG「HTML 文書生成」 MIBデータ↑↓snmpget SNMPエージェント (snmpd) ↑ MIB --- NET-SNMP+MRTG 使用するパッケージがインストールされているかの確認 # rpm -q net-snmp net-snmp-5.2.1-12 # rpm -q mrtg mrtg-2.11.1-3 --- NET-SNMP MRTG の設定を行う。 *Step1 NET-SNMPの設定 [root@localhost ~]# vi /etc/snmp/snmpd.conf 1. コミュニティの設定 #### # First, map the community name "public" into a "security name" # sec.name source community com2sec notConfigUser default public ↓ com2sec local localhost private com2sec mynetwork 192.168.1.0/24 public 2. セキュリティグループの設定 #### # Second, map the security name into a group name: # groupName securityModel securityName group notConfigGroup v1 notConfigUser group notConfigGroup v2c notConfigUser ↓ group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork 3. ビューの設定 #### # Third, create a view for us to let the group have rights to: # Make at least snmpwalk -v 1 localhost -c public system fast again. # name incl/excl subtree mask(optional) view systemview included .1.3.6.1.2.1.1 view systemview included .1.3.6.1.2.1.25.1.1 ↓ view all included .1 80 4. アクセス権限の設定 #### # Finally, grant the group read-only access to the systemview view. # group context sec.model sec.level prefix read write notif access notConfigGroup "" any noauth exact systemview none none ↓ access MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none 5. システム情報の設定 ############################################################################### # System contact information # # It is also possible to set the sysContact and sysLocation system # variables through the snmpd.conf file: syslocation Unknown (edit /etc/snmp/snmpd.conf) syscontact Root (configure /etc/snmp/snmp.local.conf) 6. ディスクの情報取得の設定 ############################################################################### # disk checks # # The agent can check the amount of available disk space, and make # sure it is above a set limit. # Check the / partition and make sure it contains at least 10 megs. #disk / 10000 ↓ disk / 10000 7. CPU負荷の情報取得の設定 ############################################################################### # load average checks # # Check for loads: #load 12 14 14 8. ??? # For specific usage information, see the man/snmpd.conf.5 manual page # as well as the local/passtest script used in the above example. # Added for support of bcm5820 cards. pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat *Step2 NET-SNMPの起動 [root@localhost ~]# /etc/rc.d/init.d/snmpd start snmpd を起動中: [ OK ] [root@localhost ~]# chkconfig snmpd on [root@localhost ~]# chkconfig --list snmpd snmpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off *Step3 MRTG設定ファイルの作成 [root@localhost ~]# cd /etc/mrtg [root@localhost mrtg]# mv mrtg.cfg mrtg.cfg.old [root@localhost mrtg]# cfgmaker --ifref=descr --ifdesc=descr public@192.168.1.11 > mrtg.cfg # cfgmaker --ifref=descr --ifdesc=descr --output=mrtg.cfg public@192.168.1.11 *Step4 MRTG設定ファイルの編集 [root@localhost mrtg]# vi mrtg.cfg 1. WorkDir の設定。 # for UNIX # WorkDir: /home/http/mrtg ↓ WorkDir: /var/www/mrtg 2. Options[_] の設定。 # to get bits instead of bytes and graphs growing to the right # Options[_]: growright, bits ↓ Options[_]: growright, noinfo 3. IPアドレスの除去 Target[192.168.1.11_eth0]: \eth0:public@192.168.1.11: SetEnv[192.168.1.11_eth0]: MRTG_INT_IP="192.168.1.11" MRTG_INT_DESCR="eth0" MaxBytes[192.168.1.11_eth0]: 1250000 Title[192.168.1.11_eth0]: eth0 -- localhost.localdomain PageTop[192.168.1.11_eth0]:

eth0 -- localhost.localdomain

↓ Target[eth0]: \eth0:public@192.168.1.11: SetEnv[eth0]: MRTG_INT_IP="192.168.1.11" MRTG_INT_DESCR="eth0" MaxBytes[eth0]: 12500000 Title[eth0]: Traffic eth0 PageTop[eth0]:

Traffic eth0

*Step5 各種設定 1. CPU # CPU Load Average Target[cpu]: 1.3.6.1.4.1.2021.10.1.5.1&1.3.6.1.4.1.2021.10.1.5.2:public@192.168.1.11 MaxBytes[cpu]: 100 Unscaled[cpu]: dwmy Options[cpu]: gauge,nopercent Title[cpu]: CPU Load Average PageTop[cpu]:

CPU Load Average

YLegend[cpu]: load average (%) ShortLegend[cpu]: % LegendI[cpu]: 1min LegendO[cpu]: 5min Target[cpu]: 1.3.6.1.4.1.2021.10.1.5.2&1.3.6.1.4.1.2021.10.1.5.3:コミュニティ名@IPアドレス MaxBytes[cpu]: 2000 Title[cpu]: CPU Load Avalage PageTop[cpu]:

CPU Load Avalage

Options[cpu]: nopercent, integer, gauge, absolute, withzeroes YLegend[cpu]: CPU Load Avalage ShortLegend[cpu]: percent Legend1[cpu]: 5 min CPU Load Avalage Legend2[cpu]: 15 min CPU Load Avalage LegendI[cpu]: 5min LegendO[cpu] 15min ### CPU Load Average ### Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:public@192.168.0.2 MaxBytes[cpu]: 100 Unscaled[cpu]: dwmy Options[cpu]: gauge, absolute, growright, noinfo, nopercent YLegend[cpu]: CPU Load(%) ShortLegend[cpu]: (%) LegendI[cpu]: 1分間平均 LegendO[cpu]: 5分間平均 Legend1[cpu]: 1分間平均(%) Legend2[cpu]: 5分間平均(%) Title[cpu]: CPU使用率 PageTop[cpu]:

CPU使用率

Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:hoge@localhost MaxBytes[cpu]: 100 Unscaled[cpu]: dwmy Options[cpu]: gauge,absolute,nopercent,noinfo YLegend[cpu]: CPU Load(%) ShortLegend[cpu]: (%) LegendI[cpu]: 1分間平均 LegendO[cpu]: 5分間平均 Legend1[cpu]: 1分間平均(%) Legend2[cpu]: 5分間平均(%) Title[cpu]: CPU Load PageTop[cpu]:

CPU Load

2. Memory # free Mem: 物理メモリMAX値 Swap: スワップメモリMAX値 # Memory Usage Target[mem]: 1.3.6.1.4.1.2021.4.4.0&1.3.6.1.4.1.2021.4.6.0:public@192.168.1.11 MaxBytes1[mem]: 522104 MaxBytes2[mem]: 254924 Unscaled[mem]: dwmy Options[mem]: gauge,absolute,integer,unknaszero Title[mem]: Memory Usage PageTop[mem]:

Memory Usage

YLegend[mem]: Available Memory ShortLegend[mem]: Bytes LegendI[mem]: Swap available LegendO[mem]: Real available kilo[mem]: 1024 kMG[mem]: k,M,G,T,P Target[mem]: 1.3.6.1.4.1.2021.4.6.0&1.3.6.1.4.1.2021.4.4.0:コミュニティ名@IPアドレス MaxBytes1[mem]: 128000 MaxBytes2[mem]: 256000 Title[mem]: Memory Used PageTop[mem]:

Memory Used

Options[mem]: gauge, absolute YLegend[mem]: Mem Free[kBytes] ShortLegend[mem]: kBytes Legend1[mem]: Real Memory Legend2[mem]: Swap Memory LegendI[mem]: Real LegendO[mem]: Swap Target[mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:public@192.168.0.2 MaxBytes1[mem]: 385724 <= 物理メモリのMAX値 MaxBytes2[mem]: 2097144 <= スワップメモリのMAX値 Unscaled[mem]: dwmy Options[mem]: gauge, absolute, growright, noinfo YLegend[mem]: Mem Free(Bytes) ShortLegend[mem]: Bytes kilo[mem]: 1024 kMG[mem]: k,M,G,T,P LegendI[mem]: Real LegendO[mem]: Swap Legend1[mem]: 空き物理メモリ[MBytes] Legend2[mem]: 空きスワップメモリ[MBytes] Title[mem]: 空きメモリ量 PageTop[mem]:

空きメモリ量

MaxBytes2[mem]: 257032 Unscaled[mem]: dwmy Options[mem]: gauge,absolute,noinfo YLegend[mem]: Mem Free(Bytes) ShortLegend[mem]: Bytes kilo[mem]: 1024 kMG[mem]: k,M,G,T,P LegendI[mem]: Real LegendO[mem]: Swap Legend1[mem]: 空き物理メモリ[MBytes] Legend2[mem]: 空きスワップメモリ[MBytes] Title[mem]: Memory Free PageTop[mem]:

Memory Free

3. Disk Target[disk]: .1.3.6.1.4.1.2021.9.1.9.1&.1.3.6.1.4.1.2021.9.1.9.2:hoge@localhost MaxBytes[disk]: 100 Unscaled[disk]: dwmy Options[disk]: gauge,absolute,nopercent,noinfo YLegend[disk]: Disk Used(%) ShortLegend[disk]: (%) LegendI[disk]: /home Disk used LegendO[disk]: /var Disk Used Legend1[disk]: /home Disk used Legend2[disk]: /var Disk used Title[disk]: Disk Used PageTop[disk]:

Disk Used

# Disk Usage Target[disk]: .1.3.6.1.4.1.2021.9.1.9.1&.1.3.6.1.4.1.2021.9.1.9.1:public@192.168.1.11 MaxBytes[disk]: 100 Unscaled[disk]: dwmy Options[disk]: gauge, absolute, growright, nopercent, noinfo YLegend[disk]: Disk Used(%) ShortLegend[disk]: (%) LegendI[disk]: / Disk used LegendO[disk]: / Disk used Legend1[disk]: / Disk used Legend2[disk]: / Disk used Title[disk]: Disk Usage PageTop[disk]:

Disk Usage

*Step6 MRTG設定ファイルの文字コード変換 [root@localhost mrtg]# mv mrtg.cfg mrtg.cfg.tmp [root@localhost mrtg]# nkf -e mrtg.cfg.tmp > mrtg.cfg *Step7 インデックス生成 # indexmaker --columns=1 /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html *Step8 vi /etc/httpd/conf.d/mrtg.conf LANG=C mrtg /etc/mrtg/mrtg.cfg __END__ --- *Step1 既存のファイルをリネームする。 # cd /etc/snmp # mv snmpd.conf snmpd.conf.bak # cp /opt/archives/snmpd.conf . *Step2 snmpd.confファイルを新規に作成する。 # rouser: a SNMPv3 read-only user # arguments: user [noauth|auth|priv] [restriction_oid] rouser guest # rocommunity: a SNMPv1/SNMPv2c read-only access community name # arguments: community [default|hostname|network/bits] [oid] rocommunity public 127.0.0.1 disk /home 15% ローカル・マシン(127.0.0.1)からコミュニティ名に 「public」を指定してMIBデータの読み出しを許可する設定 【MIB】Management Information Baseの略。 ネットワークに接続される機器の管理情報を格納するデータベース。 *Step3 # chkconfig snmpd on # service snmpd start # snmpwalk -v 2c -c public localhost -vオプション 利用するSNMPプロトコルのバージョン -cオプション SNMPv1/v2cで使用するコミュニティ名(エージェントを呼び出すときの名前) *Step4 /etc/snmp/snmp.conf defVersion 2c snmpgetコマンドが利用するプロトコルをSNMPv2cに変更する *Step5 /etc/mrtg/localhost.cfg *Step6 # LANG=C mrtg /etc/mrtg/localhost.cfg mrtgコマンドは文字コード設定が「UTF-8」だとエラーになる。 そのため先頭に「LANG=C」(C言語で使える文字コード)を設定して実行する。 最初の2回の実行は過去の情報がないため、ワーニング・メッセージが出力されるが無視して構わない。 *Step7 5分間隔で実行するように設定する。 # crontab -e で編集画面を表示して、 */5 * * * * LANG=C /usr/bin/mrtg /etc/mrtg/localhost.cfg を追加する。 *Step8 /etc/httpd/conf.d/mrtg.conf allow from... __END__ --- Postfix for SMTP Auth SASL(Simple Authentication and Security Layer) Cyrus-SASL の設定を行う。 # vi /usr/lib/sasl2/smtpd.conf pwcheck_method: saslauthd パスワード・チェックを「saslauthd」というデーモン・プロセスが実施することを示している。 システム・アカウントを利用して認証する場合は次の二つが扱える。 ・PLAIN 平文による認証 ・LOGIN 認証方式をPLAINとLOGINに限定する。 pwcheck_method: saslauth mech_list: plain login # /etc/init.d/saslauthd start # chkconfig --level 35 saslauth on Postfix に SMTP Auth の設定を行う # vi /etc/postfix/main.cf # SMTP Auth を有効にする smtpd_sasl_auth_enable = yes # OutlookなどのためにLOGIN認証を使用する broken_sasl_auth_client = yes # リレー制限の設定 smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authentiacted, reject_unauth_destination 「permit_mynetworks」はmynetworksパラメータに設定されたアドレス帯からのメールの中継を許可する設定。 「permit_sasl_authenticated」はSASLによる認証をパスしたユーザによるメールの中継を許可する設定。 「reject_unauth_destination」は上記以外からのメールの中継を拒否する設定。 SMTP Authのテスト $ perl -MMIME::Base64 -e 'print encode_base("d1\0d1\0bkc005");' $ telnet localhost 25 HELO localhost AUTH PLAIN password 235 Authentication successful mynetworks_style = host メール・サーバー以外のホストはメール送信時に常にSMTP Authによる認証を求められる --- ACL(Access Control List) ACLを設定する。 ACLの内容はgetfaclコマンドで表示 ACLの設定はsetfaclコマンド /etc/fstab LABEL=/ / ext3 defaults 1 1 LAVEL=/ / ext3 defaults,acl 1 1 mount /dev/sda2 on / type ext3 (rw,acl) none on /proc type proc (rw) none on /sys type sysfs (rw) none on /dev/pts type devpts (rw,gid=5,mode=620) usbdevfs on /proc/bus/usb type usbdevfs (rw) /dev/sdal on /boot type ext3 (rw) none on /dev/shm type tmpfs (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) ・ユーザー「takahara」にアクセス権「rwx」を付与する。 $ setfacl -m u:takahara:rwx testfile ・グループ「FW」にアクセス権「rw-」を付与する。 $ setfacl -m g:FW:rw testfile ・既に設定済みのユーザー「nakamura」に対するアクセス権を解除する。 $ setfacl -x u:nakamura testfile ・ACLを全消去する。 $ setfacl -b testfile getfacl testfile > backup_acl setfacl -b testfile setfacl --restore=backup_acl --- Exe-Shield # cat /proc/`pidof testpgm`/maps /proc/sys/kernel/exec-shield 有効・無効を設定するためのもの /proc/sys/kernel/exec-shield-randomize セグメント配置位置のランダム化の有効/無効を設定するためのもの execstacl [オプション] 実行ファイル -c:有効にする -s:無効にする -q:設定内容を表示する -V:バージョン情報の表示 -?:ヘルプの表示 -は有効 Xは無効 execstack -s testpgm 設定を無効にする execstack -q testpgm 設定内容を表示する --- iptables /etc/sysconfig/iptables --- ・root宛メールを転送する [root@localhost ~]# vi /etc/aliases # Person who should get root's mail #root: marc root: d1 [root@localhost ~]# newaliases --- ・プリントサーバの停止 [root@localhost ~]# /etc/rc.d/init.d/cups stop cups を停止中: [ OK ] [root@localhost ~]# chkconfig cups off [root@localhost ~]# chkconfig --list cups cups 0:off 1:off 2:off 3:off 4:off 5:off 6:off --- 1. SELinux を有効にする。 Step1 ファイルシステムの拡張属性にTEのタイプを書き込み。 # fixfiles relabel Step2 /etc/sysconfig/selinux ファイルを編集 - SELINUX=disabled + SELINUX=enforcing Step3 システムをリブートさせる。 # reboot 2. ファイルタイプを付与し直す。 Step1 sysadm_rで管理作業を行う。 # newrole -r sysadm_r Step2 全ファイルに正しいタイプを付与する。 # fixfiles relabel Step3 システムをリブートさせる。 # reboot --- SELinux *** Warning -- SELinux relabel is required. *** *** Disabling security enforcement. *** *** Relabeling could take a very long time, *** *** depending on file system size. ***