サーバー調査まとめ

2016.6.9 (木)
  • OSの確認(Linuxディストリビューション)
  • CPUスペックの確認
  • メモリ容量の確認
  • HDD容量確認
  • Apacheの設定確認(設定情報、文字コード、モジュール)
  • SSHの確認
  • MTAの確認
  • MySQLの確認
  • Perlのバージョン確認(Perlモジュールの確認(インクルードパスを調べる))
  • PHPのバージョン確認
  • ログインシェルの確認

OS確認

Debian GNU/Linux

$ cat /etc/debian_version
4.0
Ubuntu

あるいは、

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.1"

CentOS / RedHat Enterprise Linux

$ cat /etc/redhat-release
CentOS release 5.2 (Final)

Fedora

$ cat /etc/fedora-release
Fedora release 9 (Sulphur)
SUSE Linux

Linux Enterprise

$ cat /etc/SuSE-release

SUSE Linux Enterprise Server 10 (x86_64)
VERSION=10
PATCHLEVEL=1

CPU

# cat /proc/cpuinfo

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Duo CPU E7300 @ 2.66GHz
stepping : 6
cpu MHz : 1600.000
cache size : 3072 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm
bogomips : 5320.66
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Duo CPU E7300 @ 2.66GHz
stepping : 6
cpu MHz : 1600.000
cache size : 3072 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 1
initial apicid : 1
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm
bogomips : 5320.36
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:

メモリ

# cat /proc/meminfo

MemTotal: 2059704 kB
MemFree: 53636 kB
Buffers: 181100 kB
Cached: 1727444 kB
SwapCached: 4552 kB
Active: 224268 kB
Inactive: 1717504 kB
Active(anon): 20400 kB
Inactive(anon): 23776 kB
Active(file): 203868 kB
Inactive(file): 1693728 kB
Unevictable: 0 kB
Mlocked: 0 kB
HighTotal: 1184200 kB
HighFree: 15908 kB
LowTotal: 875504 kB
LowFree: 37728 kB
SwapTotal: 1951736 kB
SwapFree: 1917992 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 29992 kB
Mapped: 14772 kB
Shmem: 10948 kB
Slab: 49068 kB
SReclaimable: 42660 kB
SUnreclaim: 6408 kB
KernelStack: 1448 kB
PageTables: 1708 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 2981588 kB
Committed_AS: 370784 kB
VmallocTotal: 122880 kB
VmallocUsed: 4320 kB
VmallocChunk: 114816 kB
HardwareCorrupted: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 8184 kB
DirectMap2M: 903168 kB

HDD

# df -h

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 457G 11G 423G 3% /
none 1002M 188K 1002M 1% /dev
none 1006M 0 1006M 0% /dev/shm
none 1006M 64K 1006M 1% /var/run
none 1006M 0 1006M 0% /var/lock
none 1006M 0 1006M 0% /lib/init/rw
none 457G 11G 423G 3% /var/lib/ureadahead/debugfs

または、

#fdisk -l

Disk /dev/sda: 500.0 GB, 499989348352 bytes
255 heads, 63 sectors/track, 60786 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dd220
Device Boot Start End Blocks Id System
/dev/sda1 * 1 60544 486316032 83 Linux
/dev/sda2 60544 60787 1951745 5 Extended
/dev/sda5 60544 60787 1951744 82 Linux swap / Solaris

Apache

# apache2 -v [ubuntu/debian]

Server version: Apache/2.2.14 (Ubuntu)
Server built: Sep 1 2011 09:45:41

または、

# httpd -v [CentOSなど]

Server version: Apache/2.2.15 (Unix)
Server built: Feb 13 2012 22:31:42
httpd.conf (またはapache2.conf)の設定
基本的にはUTF8(文字コードが混在する場合は設定を変更)
[設定例1] AddDefaultCharset utf-8 文字コードを明示的に記述する
[設定例2] #AddDefaultCharset 文字コードがデフォルトでutf-8になる
[設定例3] AddDefaultCharset none 文字コードが混在する場合(HTMLのmetaデータを読む)
httpd.conf内の調査(有効モジュール/無効モジュール)
# a2enmod (有効モジュール 最後はキャンセル)

Your choices are: actions alias asis auth_basic auth_digest authn_alias authn_anon authn_dbd authn_dbm authn_default authn_file authnz_ldap authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cern_meta cgi cgid charset_lite dav dav_fs dav_lock dbd deflate dir disk_cache dump_io env expires ext_filter file_cache filter headers ident imagemap include info ldap log_forensic mem_cache mime mime_magic negotiation php5 proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http proxy_scgi reqtimeout rewrite ruby setenvif speling ssl status substitute suexec unique_id userdir usertrack version vhost_alias
Which module(s) do you want to enable (wildcards ok)?
# a2dismod (無効モジュール)

Your choices are: alias auth_basic authn_file authz_default authz_groupfile authz_host authz_user autoindex cgi deflate dir env mime negotiation php5 reqtimeout rewrite ruby setenvif status userdir
Which module(s) do you want to disable (wildcards ok)?
またはhttpd.confなどを直接見る(150行目辺り)
150 LoadModule auth_basic_module modules/mod_auth_basic.so
151 LoadModule auth_digest_module modules/mod_auth_digest.so
152 LoadModule authn_file_module modules/mod_authn_file.so
153 LoadModule authn_alias_module modules/mod_authn_alias.so
154 LoadModule authn_anon_module modules/mod_authn_anon.so
155 LoadModule authn_dbm_module modules/mod_authn_dbm.so
156 LoadModule authn_default_module modules/mod_authn_default.so
157 LoadModule authz_host_module modules/mod_authz_host.so
158 LoadModule authz_user_module modules/mod_authz_user.so
159 LoadModule authz_owner_module modules/mod_authz_owner.so
160 LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
161 LoadModule authz_dbm_module modules/mod_authz_dbm.so
162 LoadModule authz_default_module modules/mod_authz_default.so
163 LoadModule ldap_module modules/mod_ldap.so
164 LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
165 LoadModule include_module modules/mod_include.so
166 LoadModule log_config_module modules/mod_log_config.so
167 LoadModule logio_module modules/mod_logio.so
168 LoadModule env_module modules/mod_env.so
169 LoadModule ext_filter_module modules/mod_ext_filter.so
170 LoadModule mime_magic_module modules/mod_mime_magic.so
171 LoadModule expires_module modules/mod_expires.so
172 LoadModule deflate_module modules/mod_deflate.so
173 LoadModule headers_module modules/mod_headers.so
174 LoadModule usertrack_module modules/mod_usertrack.so
175 LoadModule setenvif_module modules/mod_setenvif.so
176 LoadModule mime_module modules/mod_mime.so
177 LoadModule dav_module modules/mod_dav.so
178 LoadModule status_module modules/mod_status.so
179 LoadModule autoindex_module modules/mod_autoindex.so
180 LoadModule info_module modules/mod_info.so
181 LoadModule dav_fs_module modules/mod_dav_fs.so
182 LoadModule vhost_alias_module modules/mod_vhost_alias.so
183 LoadModule negotiation_module modules/mod_negotiation.so
184 LoadModule dir_module modules/mod_dir.so
185 LoadModule actions_module modules/mod_actions.so
186 LoadModule speling_module modules/mod_speling.so
187 LoadModule userdir_module modules/mod_userdir.so
188 LoadModule alias_module modules/mod_alias.so
189 LoadModule substitute_module modules/mod_substitute.so
190 LoadModule rewrite_module modules/mod_rewrite.so
191 LoadModule proxy_module modules/mod_proxy.so
192 LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
193 LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
194 LoadModule proxy_http_module modules/mod_proxy_http.so
195 LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
196 LoadModule proxy_connect_module modules/mod_proxy_connect.so
197 LoadModule cache_module modules/mod_cache.so
198 LoadModule suexec_module modules/mod_suexec.so
199 LoadModule disk_cache_module modules/mod_disk_cache.so
200 LoadModule cgi_module modules/mod_cgi.so
201 LoadModule version_module modules/mod_version.so

MTA

シンボリックリンクでMTAを確認(Postfixを使用中)

# cd /etc/alternatives/
# ll

total 0
lrwxrwxrwx 1 root root 26 Sep 19 22:41 mta -> /usr/sbin/sendmail.postfix
lrwxrwxrwx 1 root root 40 Sep 19 22:41 mta-aliasesman -> /usr/share/man/man5/aliases.postfix.5.gz
lrwxrwxrwx 1 root root 22 Sep 19 22:41 mta-mailq -> /usr/bin/mailq.postfix
lrwxrwxrwx 1 root root 38 Sep 19 22:41 mta-mailqman -> /usr/share/man/man1/mailq.postfix.1.gz
lrwxrwxrwx 1 root root 27 Sep 19 22:41 mta-newaliases -> /usr/bin/newaliases.postfix
lrwxrwxrwx 1 root root 43 Sep 19 22:41 mta-newaliasesman -> /usr/share/man/man1/newaliases.postfix.1.gz
lrwxrwxrwx 1 root root 23 Sep 19 22:41 mta-pam -> /etc/pam.d/smtp.postfix
lrwxrwxrwx 1 root root 22 Sep 19 22:41 mta-rmail -> /usr/bin/rmail.postfix
lrwxrwxrwx 1 root root 25 Sep 19 22:41 mta-sendmail -> /usr/lib/sendmail.postfix
lrwxrwxrwx 1 root root 41 Sep 19 22:41 mta-sendmailman -> /usr/share/man/man1/sendmail.postfix.1.gz

psで確認

# ps aux | grep postfix

root 1076 0.0 0.0 5812 480 ? Ss 2012 0:33 /usr/lib/postfix/master
postfix 1099 0.0 0.0 5872 712 ? S 2012 0:05 qmgr -l -t fifo -u
postfix 2212 0.0 0.0 6372 936 ? S 2012 0:04 tlsmgr -l -t unix -u -c
postfix 30229 0.0 0.0 5828 1704 ? S 15:33 0:00 pickup -l -t fifo -u -c
root 30238 0.0 0.0 1864 712 pts/0 S+ 15:34 0:00 grep --color=auto postfix
# ps aux | grep sendmail

root 30245 0.0 0.0 1860 608 pts/0 S+ 15:34 0:00 grep --color=auto sendmail
root@ubuntu:/etc/alternatives

SSH

# ssh -V

OpenSSH_5.3p1 Debian-3ubuntu6, OpenSSL 0.9.8k 25 Mar 2009
# rpm -qa|grep ^openssh

openssh-server-5.3p1-81.el6_3.x86_64
openssh-clients-5.3p1-81.el6_3.x86_64
openssh-5.3p1-81.el6_3.x86_64

MySQL

MariaDBとかMySQLのパッケージから確認する場合はこっち。

rpm -qa | grep -i mariadb

または

rpm -qa | grep -i mysql

ログインして確認する場合はこっち。

# mysqladmin -u root -p version

Enter password:
mysqladmin Ver 8.42 Distrib 5.1.41, for debian-linux-gnu on i486
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 5.1.41-3ubuntu12.10
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 212 days 17 min 20 sec
Threads: 1 Questions: 23149 Slow queries: 0 Opens: 1943 Flush tables: 1 Open tables: 64 Queries per second avg: 0.1
# mysqladmin -u username -p version

Enter password:
mysqladmin Ver 8.42 Distrib 5.1.66, for redhat-linux-gnu on x86_64
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 5.1.66
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 45 days 11 hours 52 min 16 sec
Threads: 1 Questions: 2 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables: 8 Queries per second avg: 0.0

Perl

# perl -v

This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
Copyright 1987-2009, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
# perl -v

This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi
Copyright 1987-2009, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Perlモジュールの確認(インクルードパスを調べる)

# find `perl -e 'print "@INC"'` -name '*.pm' -print

/etc/perl/CPAN/Config.pm
/usr/local/lib/perl/5.10.1/DBI/Profile.pm
/usr/local/lib/perl/5.10.1/DBI/DBD.pm
/usr/local/lib/perl/5.10.1/DBI/ProfileDumper.pm
/usr/local/lib/perl/5.10.1/DBI/Gofer/Request.pm
/usr/local/lib/perl/5.10.1/DBI/Gofer/Transport/Base.pm
/usr/local/lib/perl/5.10.1/DBI/Gofer/Transport/pipeone.pm
/usr/local/lib/perl/5.10.1/DBI/Gofer/Transport/stream.pm
/usr/local/lib/perl/5.10.1/DBD/Gofer/Policy/Base.pm
/usr/local/lib/perl/5.10.1/DBD/Gofer/Policy/pedantic.pm
/usr/local/lib/perl/5.10.1/DBD/Gofer/Policy/rush.pm
/usr/local/lib/perl/5.10.1/DBD/DBM.pm
/usr/local/lib/perl/5.10.1/DBD/NullP.pm
/usr/local/lib/perl/5.10.1/DBD/Proxy.pm
(中略)
/usr/share/perl5/XML/SAX/PurePerl/Reader/Stream.pm
/usr/share/perl5/XML/SAX/PurePerl/Reader/UnicodeExt.pm
/usr/share/perl5/XML/SAX/PurePerl/DTDDecls.pm
/usr/share/perl5/XML/SAX/PurePerl/Reader.pm
/usr/share/perl5/XML/SAX/PurePerl/EncodingDetect.pm
/usr/share/perl5/XML/SAX/PurePerl/UnicodeExt.pm
/usr/share/perl5/XML/SAX/PurePerl/DebugHandler.pm
/usr/share/perl5/XML/SAX/PurePerl/DocType.pm
/usr/share/perl5/XML/SAX/PurePerl/Productions.pm
/usr/share/perl5/XML/SAX/Debian.pm
/usr/share/perl5/XML/SAX/Expat.pm
/usr/share/perl5/XML/SAX/ParserFactory.pm
/usr/share/perl5/XML/SAX/Base.pm
/usr/share/perl5/XML/SAX/DocumentLocator.pm
/usr/share/perl5/XML/SAX/PurePerl.pm
/usr/share/perl5/XML/NamespaceSupport.pm

SHELL

ログインシェルの確認

# echo $SHELL
/bin/bash

PHP

# rpm -q php
php-5.3.3-14.el6_3.x86_64

または

<?php phpinfo(); ?>