Category Archives: Source

CentOS 5.4 にVimをインストール

方法1

[root@localhost ~]# yum install vim-*

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.ta139.com
* base: mirrors.ta139.com
* extras: mirrors.ta139.com
* updates: mirrors.ta139.com
addons | 1.9 kB 00:00
base | 1.1 kB 00:00
extras | 2.1 kB 00:00
updates | 1.9 kB 00:00
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package vim-X11.i386 2:7.0.109-7.2.el5 set to be updated
—> Package vim-common.i386 2:7.0.109-7.2.el5 set to be updated
—> Package vim-enhanced.i386 2:7.0.109-7.2.el5 set to be updated
—> Package vim-minimal.i386 2:7.0.109-7.2.el5 set to be updated
–> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
vim-X11 i386 2:7.0.109-7.2.el5 base 1.4 M
vim-common i386 2:7.0.109-7.2.el5 base 6.4 M
vim-enhanced i386 2:7.0.109-7.2.el5 base 1.2 M
Updating:
vim-minimal i386 2:7.0.109-7.2.el5 base 310 k

Transaction Summary
===============================================================================
Install 3 Package(s)
Update 1 Package(s)
Remove 0 Package(s)
Total download size: 9.4 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): vim-minimal-7.0.109-7.2.el5.i386.rpm | 310 kB 00:00
(2/4): vim-enhanced-7.0.109-7.2.el5.i386.rpm | 1.2 MB 00:06
(3/4): vim-X11-7.0.109-7.2.el5.i386.rpm | 1.4 MB 00:09
(4/4): vim-common-7.0.109-7.2.el5.i386.rpm | 6.4 MB 00:56
——————————————————————————-
Total 130 kB/s | 9.4 MB 01:13
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vim-common 1/5
Installing : vim-X11 2/5
Installing : vim-enhanced 3/5
Updating : vim-minimal 4/5
Cleanup : vim-minimal 5/5
Installed:
vim-X11.i386 2:7.0.109-7.2.el5 vim-common.i386 2:7.0.109-7.2.el5 vim-enhanced.i386 2:7.0.109-7.2.el5
Updated:
vim-minimal.i386 2:7.0.109-7.2.el5
Complete!
[root@localhost ~]# which vi
/bin/vi
[root@localhost ~]# which vim
/usr/bin/vim
[root@localhost ~]# rm /bin/vi
rm: remove regular file `/bin/vi’? y
[root@localhost ~]# ln -s /usr/bin/vim /bin/vi
[root@localhost ~]# which vi
/bin/vi
[root@localhost ~]# ls -l /bin/vi
lrwxrwxrwx 1 root root 12 Jan 18 01:22 /bin/vi -> /usr/bin/vim

方法2

yum

FreeBSDファイアーウォールおよびSSHサービス起動の方法

1.FreeBSDファイアーウォールの設定

(1).

ee /etc/rc.conf #

(2).
firewall_enable=”yes” #ファイアーウォール有効
net.inet.ip.fw.verbose=1 #ファイアーウォールログ有効
net.inet.ip.fw.verbose_limit=5 #同上
natd_enable=”YES” # ファイアーウォールNAT機能有効
natd_interface=”rl0″
natd_flags=”-dynamic -m”
firewall_script=”/etc/ipfw.rules” #ファイアーウォールのルールパス
(3).ESCを押し、Enter,aキーを押して保存

2.ファイアーウォールのルールの追加
(1).ee /etc/ipfw.rules
(2).下記コードを追加
#!/bin/sh
################ Start of IPFW rules file ######################
# Flush out the list before we begin.
ipfw -q -f flush

# Set rules command prefix
cmd=”ipfw -q add”
skip=”skipto 800″
pif=”rl0″ # public interface name of NIC
# facing the public Internet

#################################################################
# No restrictions on Inside LAN Interface for private network
# Change xl0 to your LAN NIC interface name
#################################################################
$cmd 005 allow all from any to any via xl0

#################################################################
# No restrictions on Loopback Interface
#################################################################
$cmd 010 allow all from any to any via lo0

#################################################################
# check if packet is inbound and nat address if it is
#################################################################
$cmd 014 divert natd ip from any to any in via $pif

#################################################################
# Allow the packet through if it has previous been added to the
# the “dynamic” rules table by a allow keep-state statement.
#################################################################
$cmd 015 check-state

#################################################################
# Interface facing Public Internet (Outbound Section)
# Check session start requests originating from behind the
# firewall on the private network or from this gateway server
# destined for the public Internet.
#################################################################

# Allow out access to my ISP’s Domain name server.
# x.x.x.x must be the IP address of your ISP’s DNS
# Dup these lines if your ISP has more than one DNS server
# Get the IP addresses from /etc/resolv.conf file
$cmd 020 $skip tcp from any to x.x.x.x 53 out via $pif setup keep-state
# Allow out access to my ISP’s DHCP server for cable/DSL configurations.
$cmd 030 $skip udp from any to x.x.x.x 67 out via $pif keep-state

# Allow out non-secure standard www function
$cmd 040 $skip tcp from any to any 80 out via $pif setup keep-state

# Allow out secure www function https over TLS SSL
$cmd 050 $skip tcp from any to any 443 out via $pif setup keep-state

# Allow out send & get email function
$cmd 060 $skip tcp from any to any 25 out via $pif setup keep-state
$cmd 061 $skip tcp from any to any 110 out via $pif setup keep-state

# Allow out FreeBSD (make install & CVSUP) functions
# Basically give user root “GOD” privileges.
$cmd 070 $skip tcp from me to any out via $pif setup keep-state uid root

# Allow out ping
$cmd 080 $skip icmp from any to any out via $pif keep-state

# Allow out Time
$cmd 090 $skip tcp from any to any 37 out via $pif setup keep-state

# Allow out nntp news (i.e. news groups)
$cmd 100 $skip tcp from any to any 119 out via $pif setup keep-state

# Allow out secure FTP, Telnet, and SCP
# This function is using SSH (secure shell)
$cmd 110 $skip tcp from any to any 22 out via $pif setup keep-state

# Allow out whois
$cmd 120 $skip tcp from any to any 43 out via $pif setup keep-state

# Allow ntp time server
$cmd 130 $skip udp from any to any 123 out via $pif keep-state

#################################################################
# Interface facing Public Internet (Inbound Section)
# Check packets originating from the public Internet
# destined for this gateway server or the private network.
#################################################################

# Deny all inbound traffic from non-routable reserved address spaces
#$cmd 300 deny all from 192.168.0.0/16 to any in via $pif #RFC 1918 private IP
$cmd 301 deny all from 172.16.0.0/12 to any in via $pif #RFC 1918 private IP
$cmd 302 deny all from 10.0.0.0/8 to any in via $pif #RFC 1918 private IP
$cmd 303 deny all from 127.0.0.0/8 to any in via $pif #loopback
$cmd 304 deny all from 0.0.0.0/8 to any in via $pif #loopback
$cmd 305 deny all from 169.254.0.0/16 to any in via $pif #DHCP auto-config
$cmd 306 deny all from 192.0.2.0/24 to any in via $pif #reserved for docs
$cmd 307 deny all from 204.152.64.0/23 to any in via $pif #Sun cluster
$cmd 308 deny all from 224.0.0.0/3 to any in via $pif #Class D & E multicast

# Deny ident
$cmd 315 deny tcp from any to any 113 in via $pif

# Deny all Netbios service. 137=name, 138=datagram, 139=session
# Netbios is MS/Windows sharing services.
# Block MS/Windows hosts2 name server requests 81
$cmd 320 deny tcp from any to any 137 in via $pif
$cmd 321 deny tcp from any to any 138 in via $pif
$cmd 322 deny tcp from any to any 139 in via $pif
$cmd 323 deny tcp from any to any 81 in via $pif

# Deny any late arriving packets
$cmd 330 deny all from any to any frag in via $pif

# Deny ACK packets that did not match the dynamic rule table
$cmd 332 deny tcp from any to any established in via $pif

# Allow traffic in from ISP’s DHCP server. This rule must contain
# the IP address of your ISP’s DHCP server as it’s the only
# authorized source to send this packet type.
# Only necessary for cable or DSL configurations.
# This rule is not needed for ‘user ppp’ type connection to
# the public Internet. This is the same IP address you captured
# and used in the outbound section.
$cmd 360 allow udp from x.x.x.x to any 68 in via $pif keep-state

# Allow in standard www function because I have Apache server
$cmd 370 allow tcp from any to me 80 in via $pif setup limit src-addr 2

# Allow in secure FTP, Telnet, and SCP from public Internet
$cmd 380 allow tcp from any to me 22 in via $pif setup limit src-addr 2

# Allow in non-secure Telnet session from public Internet
# labeled non-secure because ID & PW are passed over public
# Internet as clear text.
# Delete this sample group if you do not have telnet server enabled.
$cmd 390 allow tcp from any to me 23 in via $pif setup limit src-addr 2

# Reject & Log all unauthorized incoming connections from the public Internet
$cmd 400 deny log all from any to any in via $pif

# Reject & Log all unauthorized out going connections to the public Internet
$cmd 450 deny log all from any to any out via $pif

# This is skipto location for outbound stateful rules
$cmd 800 divert natd ip from any to any out via $pif
$cmd 801 allow ip from any to any

# Everything else is denied by default
# deny and log all packets that fell through to see what they are
$cmd 999 deny log all from any to any
################ End of IPFW rules file ###############################
3.ファイアウォールが有効になるようにネットワークサービスを再起動
/etc/netstart #ネットワークサービスを再起動
/etc/rc.d/ipfw start #ファイアウォールを起動
ipfw disable firewall #ファイアウォールを停止
ipfw enable firewall #ファイアウォール有効
/etc/rc.d/ipfw restart #ファイアウォールが再起動
sh /etc/ipfw.rules #ファイアウォールのルール有効

4.SSHサービスが再起動
(1).ee /etc/inetd.xonf #sshdの先頭#を削除
ssh stream tcp nowait root /usr/sbin/sshd sshd -i -4
(2).ee /etc/rc.conf #最後に下記行目が追加される
sshd_enable=”yes”
(3).ee /etc/ssh/sshd_config #構成ファイルを編集
PermitRootLogin yes #rootログインを許可
PasswordAuthentication yes #パスワード認証を使用
PermitEmptyPasswords no #空のパスワードを許可しない
/etc/rc.d/sshd start #sshサービスが起動
/etc/rc.d/sshd restart #sshが再起動

 

Ubuntuでパスワードを忘れた場合の対策

1.システムが再起動

u1
2.Shiftを長押すると、次のメニューが表示まで、「recovery mode」を選択

u2
3.「Drop to root shell prompt 」を選択して、root権限を取得

u3
4.cat /etc/shadow ユーザ名の確認

u4

5.passwd “ユーザ名” ,パスワードを2回入力

u5
6.システムが再起動

Oracleをシャットダウン方法

1.正常シャットダウン
sql>shutdown normal;

2.緊急シャットダウン
sql>shutdown immediate;

3.異常シャットダウン
sql>shutdown abort;

PHPでOracle を使う、データをクエリ

<?php
$db_server = “localhost”;
$db_user = “TPARK”;
$db_pass = “startnew24”;
$db_sid = “atyu30″;
$dbconn=oci_connect($db_user,$db_pass,”(DEscriptION=(ADDRESS=(PROTOCOL =TCP)(HOST=127.0.0.1)(PORT = 1521))(CONNECT_DATA =(SID=$db_sid)))”);
?>

<?php
include_once(“config.php”);
/*
if($dbconn!=false)
{
echo “接続”;
echo “DBサーバ:”.$db_server;
echo “ユーザ名:”.$db_user;
echo “パスワード:”.$db_pass;
echo “SID:”.$db_sid;
echo “成功\n”;

if(OCILogOff($dbconn)==true)
{
echo “接続を閉じる!”;
}
}
else
{
echo “接続失敗”;
}
*/

$sql = “select * from editor”;
$oci_rs = oci_parse($dbconn,$sql);
oci_execute($oci_rs,OCI_DEFAULT);
while($row=oci_fetch_array($oci_rs,OCI_ASSOC)) {
print_r($row);
}
?>

LinuxでUDPパケット送信処理スクリプト

 

#/bin/bash
#Createdby http://www.arkgame.com
#DROP UDP Flood
list=grep nameserver /etc/resolv.conf |awk '{print $NF}'
for i in $list
do
iptables -A OUTPUT -p udp -d $i –dport 53 -j ACCEPT
done
iptables -A OUTPUT -p udp -j DROP
service iptables save

Linux+nginx+tomcatロードバランシング,セッションを同期

tom

1.nginxのインストール
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
# ‘$status $body_bytes_sent “$http_referer” ‘
# ‘”$http_user_agent” “$http_x_forwarded_for”‘;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream mogfs_cluster {
server 172.16.249.128:7001;
server 172.16.249.129:7001;
}
upstream jsp_server {
server 172.16.249.100:8080;
server 172.16.249.101:8080;
}
server {
listen 80;
# server_name localhost;
# location / {
# root html;
# index index.html index.htm;
# }

location ~* ^(/images/.*)$ {
mogilefs_tracker mogfs_cluster;
mogilefs_domain images;
mogilefs_noverify on;
mogilefs_pass $1 {
proxy_pass $mogilefs_path;
proxy_hide_header Content-Type;
proxy_buffering off;
}
}
location ~* ^(/text/.*)$ {
mogilefs_tracker mogfs_cluster;
mogilefs_domain text;
mogilefs_noverify on;
mogilefs_pass $1 {
proxy_pass $mogilefs_path;
proxy_hide_header Content-Type;
proxy_buffering off;
}
}
location ~* (\.jsp|do)$ {
proxy_pass http://jsp_server;

}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}

2.JDKとTomcatのインストール
tomcat1の構成ファイル下記(server.xml
<?xml version=’1.0′ encoding=’utf-8′?>
<!–
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the “License”); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
–>
<!– Note: A “Server” is not itself a “Container”, so you may not
define subcomponents such as “Valves” at this level.
Documentation at /docs/config/server.html
–>
<Server port=”8005″ shutdown=”SHUTDOWN”>
<!– Security listener. Documentation at /docs/config/listeners.html
<Listener className=”org.apache.catalina.security.SecurityListener” />
–>
<!–APR library loader. Documentation at /docs/apr.html –>
<Listener className=”org.apache.catalina.core.AprLifecycleListener” SSLEngine=”on” />
<!–Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html –>
<Listener className=”org.apache.catalina.core.JasperListener” />
<!– Prevent memory leaks due to use of particular java/javax APIs–>
<Listener className=”org.apache.catalina.core.JreMemoryLeakPreventionListener” />
<Listener className=”org.apache.catalina.mbeans.GlobalResourcesLifecycleListener” />
<Listener className=”org.apache.catalina.core.ThreadLocalLeakPreventionListener” />
<!– Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
–>
<GlobalNamingResources>
<!– Editable user database that can also be used by
UserDatabaseRealm to authenticate users
–>
<Resource name=”UserDatabase” auth=”Container”
type=”org.apache.catalina.UserDatabase”
description=”User database that can be updated and saved”
factory=”org.apache.catalina.users.MemoryUserDatabaseFactory”
pathname=”conf/tomcat-users.xml” />
</GlobalNamingResources>
<!– A “Service” is a collection of one or more “Connectors” that share
a single “Container” Note: A “Service” is not itself a “Container”,
so you may not define subcomponents such as “Valves” at this level.
Documentation at /docs/config/service.html
–>
<Service name=”Catalina”>
<!–The connectors can use a shared executor, you can define one or more named thread pools–>
<!–
<Executor name=”tomcatThreadPool” namePrefix=”catalina-exec-”
maxThreads=”150″ minSpareThreads=”4″/>
–>
<!– A “Connector” represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
–>
<Connector port=”8080″ protocol=”HTTP/1.1″
connectionTimeout=”20000″
redirectPort=”8443″ />
<!– A “Connector” using the shared thread pool–>
<!–
<Connector executor=”tomcatThreadPool”
port=”8080″ protocol=”HTTP/1.1″
connectionTimeout=”20000″
redirectPort=”8443″ />
–>
<!– Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation –>
<!–
<Connector port=”8443″ protocol=”HTTP/1.1″ SSLEnabled=”true”
maxThreads=”150″ scheme=”https” secure=”true”
clientAuth=”false” sslProtocol=”TLS” />
–>
<!– Define an AJP 1.3 Connector on port 8009 –>
<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ />
<!– An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html –>
<!– You should set jvmRoute to support load-balancing via AJP ie :
<Engine name=”Catalina” defaultHost=”localhost” jvmRoute=”jvm1″>
–>
<Engine name=”Catalina” defaultHost=”localhost”>
<!–For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) –>
<!–
<Cluster className=”org.apache.catalina.ha.tcp.SimpleTcpCluster”/>
–>
<!– Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack –>
<Realm className=”org.apache.catalina.realm.LockOutRealm”>
<!– This Realm uses the UserDatabase configured in the global JNDI
resources under the key “UserDatabase”. Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. –>
<Realm className=”org.apache.catalina.realm.UserDatabaseRealm”
resourceName=”UserDatabase”/>
</Realm>
<Host name=”www.essun.org” appBase=”webapps”
unpackWARs=”true” autoDeploy=”true”>
<Context path=”” docBase=”essun” />
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs”
prefix=”essun_access_log.” suffix=”.txt”
pattern=”%h %l %u %t &quot;%r&quot; %s %b” />
</Host>
<Host name=”localhost” appBase=”webapps”
unpackWARs=”true” autoDeploy=”true”>
<!– SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html –>
<!–
<Valve className=”org.apache.catalina.authenticator.SingleSignOn” />
–>
<!– Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern=”common” –>
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs”
prefix=”localhost_access_log.” suffix=”.txt”
pattern=”%h %l %u %t &quot;%r&quot; %s %b” />
</Host>
</Engine>
</Service>
</Server>)

サイトのディレクトリファイル下記:
[root@essun tomcat]# cd webapps/essun/
[root@essun essun]# ls
index.jsp WEB-INF
[root@essun essun]# ll WEB-INF/
total 8
drwxr-xr-x 2 root root 4096 May 2 11:07 classes
drwxr-xr-x 2 root root 4096 May 2 11:07 lib
[root@essun essun]# cat index.jsp
<%@ page language=”java” %>
<html>
<head><title>arkgame.com essun.node2</title></head>
<body> <h1><font color=”red”>essun.node2.org</font></h1>
<table align=”centre” border=”1″>
<tr>
<td>Session ID</td>
<% session.setAttribute(“essun.org”,”essun.org”); %>
<td><%= session.getId() %></td>
</tr>
<tr>
<td>Created on</td>
<td><%= session.getCreationTime() %></td>
</tr>
</table>
<p>
<a href=”http://172.16.249.210/images/4.jpg”>”Picture”</a></p>
<% out.println(“<img src=’http://172.16.249.210/images/3.jpg’>”); %>
</body>
</html>

tomcat2の設定、index.jspだけ異なる

[root@essun essun]# cat index.jsp
<%@ page language=”java” %>
<html>
<head><title>essun.node1</title></head>
<body> <h1><font color=”blue”>essun.node1.org</font></h1>
<table align=”centre” border=”1″>
<tr>
<td>Session ID</td>
<% session.setAttribute(“essun.org”,”essun.org”); %>
<td><%= session.getId() %></td>
</tr>
<tr>
<td>Created on</td>
<td><%= session.getCreationTime() %></td>
</tr>
</table>
<p>
<a href=”http://172.16.249.210/images/4.jpg”>”picture”</a></p>
<% out.println(“<img src=’http://172.16.249.210/images/3.jpg’>”); %>
</body>
</html>

 

 

Zabbixの分散監視

1.zabbix-serverのインストール、設定

i)下記ファイルをダウンロード
zabbix-2.0.8-3.el6.x86_64.rpm
zabbix-get-2.0.8-3.el6.x86_64.rpm
zabbix-server-2.0.8-3.el6.x86_64.rpm
zabbix-server-mysql-2.0.8-3.el6.x86_64.rpm
zabbix-web-2.0.8-3.el6.noarch.rpm
zabbix-web-mysql-2.0.8-3.el6.noarch.rpm
mariadb-10.0.10-linux-x86_64.tar.gz
php-5.4.26.tar.bz2
httpd-2.2
#
#
ii)インストール
yum -y install *.rpm
# zabbixデータベースとアカウントを作成
mysql -e “create database zabbix;”
mysql -e “grant all on *.* to ‘zabbix’@’172.16.%.%’ identified by ‘zabbix’;”
mysql -e “flush privileges;”
# zabbix webの必要なテーブルをインポート
mysql -h172.16.43.6 -uzabbix -p -D zabbix < /usr/share/doc/zabbix-server-mysql-2.0.8/create/schema.sql
mysql -h172.16.43.6 -uzabbix -p -D zabbix < /usr/share/doc/zabbix-server-mysql-2.0.8/create/images.sql
mysql -h172.16.43.6 -uzabbix -p -D zabbix < /usr/share/doc/zabbix-server-mysql-2.0.8/create/data.sql
# 構成ファイルを編集
vim /etc/zabbix/zabbix_server.conf
DBHost=172.16.43.6 (#81)
DBName=zabbix (#90)
DBUser=zabbix (#107)
DBPassword=zabbix (#115)
DBSocket=/tmp/mysql.sock (#124)
# zabbix,httpdが起動
service zabbix-server start
service httpd start
2.プロキシサーバーのインストールと構成
i) 下記ファイルをダウンロード
zabbix-2.0.8-3.el6.x86_64.rpm
zabbix-proxy-2.0.8-3.el6.x86_64.rpm
zabbix-proxy-mysql-2.0.8-3.el6.x86_64.rpm
mariadb-10.0.10-linux-x86_64.tar.gz
#
#
ii) インストール設定
yum -y install *.rpm
# zabbixデータベースとアカウントを作成
mysql -e “create database zabbixproxy;”
mysql -e “grant all on *.* to ‘zabbixproxy’@’172.16.%.%’ identified by ‘zabbixproxy’;”
mysql -e “flush privileges;”
# zabbix webの必要なテーブルをインポート
mysql -h172.16.43.5 -uroot -p -D zabbixproxy < /usr/share/doc/zabbix-proxy-mysql-2.0.8/create/schema.sql
mysql -h172.16.43.5 -uroot -p -D zabbixproxy < /usr/share/doc/zabbix-proxy-mysql-2.0.8/create/images.sql
mysql -h172.16.43.5 -uroot -p -D zabbixproxy < /usr/share/doc/zabbix-proxy-mysql-2.0.8/create/data.sql
# 構成ファイルを編集
vim /etc/zabbix/zabbix_proxy.conf
Server=172.16.43.6 (#25)
Hostname=proxy.king.com (#44)
DBHost=172.16.43.5 (#119)
DBName=zabbixproxy (#130)
DBUser=zabbixproxy (#145)
DBPassword=zabbixproxy (#153)
# zabbix-proxyが起動
service zabbix-proxy start

3.クライアント設定
i) 下記ファイルをダウンロード
zabbix-2.0.8-3.el6.x86_64.rpm
zabbix-agent-2.0.8-3.el6.x86_64.rpm
zabbix-sender-2.0.8-3.el6.x86_64.rpm
#
#
ii)インストール
yum -y install zabbix-2.0.8-3.el6.x86_64.rpm zabbix-agent-2.0.8-3.el6.x86_64.rpm zabbix-sender-2.0.8-3.el6.x86_64.rpm
# 構成ファイルを編集
vim /etc/zabbix/zabbix_agentd.conf
Server=172.16.43.5 (#86)
ServerActive=172.16.43.5 (#127)
Hostname=slave4.king.com (#138)
# zabbix-agentが再起動
service zabbix-agent start

4.カスタム関数を利用して、nginx、varnish、mysql等の監視サービスを完了
# mysql監視サービスの設定
vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
#
#nginxのnginxのアクティブ数、訪問数、処理の数など
vim /etc/zabbix/zabbix_agentd.d/nginx.conf
UserParameter=Nginx.active[*], /usr/bin/curl -s “http://$1:$2/status” | awk ‘/^Active/ {print $NF}’
UserParameter=Nginx.accepted[*], /usr/bin/curl -s “http://$1:$2/status” | awk ‘/^[ \t]+[0-9]+[ \t]+[0-9]+[ \t]+[0-9]+/ {print $$1}’
UserParameter=Nginx.handled[*], /usr/bin/curl -s “http://$1:$2/status” | awk ‘/^[ \t]+[0-9]+[ \t]+[0-9]+[ \t]+[0-9]+/ {print $$2}’
#
# varnishの接続数、ヒット数、ヒット率
vim /etc/zabbix/zabbix_agentd.d/varnish.conf
UserParameter=varnish.conn,/usr/bin/varnishstat -1 | grep “client_conn” | awk ‘{print $2}’
UserParameter=varnish.hit,/usr/bin/varnishstat -1 | grep “cache_hit” | awk ‘{print $2}’
#

mkdir ディレクトリを作成

コード:

「Android」SearchViewを使用してListviewのアイテムにフィルターをかける

サンプルコード 下記:

package org.load.searchView;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.text.TextUtils;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ListView;
import android.widget.SearchView;
import android.widget.Toast;
import android.widget.SearchView.OnQueryTextListener;
import android.widget.TextView;

public class MainActivity extends Activity {

private List<String> mData = new ArrayList<String>(); // このデータは変更される
private List<String> mBackData; // 初期データ

private ListView mListView;
private SearchView mSearchView;

private MyAdapter mAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mListView = (ListView) super.findViewById(R.id.list);
mListView.setTextFilterEnabled(true);
mListView.setOnItemClickListener(new ItemClick());

initData();

mAdapter = new MyAdapter();
mListView.setAdapter(mAdapter);
}

// Filterableインタフェースを実装
private class MyAdapter extends BaseAdapter implements Filterable {
private MyFilter mFilter;

@Override
public int getCount() {
return mData.size();
}

@Override
public Object getItem(int position) {
return mData.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (null == convertView) {
convertView = View.inflate(MainActivity.this, R.layout.item,
null);
}

TextView show = (TextView) convertView.findViewById(R.id.show);

show.setText(mData.get(position));

return convertView;
}

@Override
public Filter getFilter() {
if (null == mFilter) {
mFilter = new MyFilter();
}
return mFilter;
}

// カスタマFilterクラス
class MyFilter extends Filter {
@Override
// 子スレッドでの実行方法
// カスタマフィルタルール
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();

List<String> newValues = new ArrayList<String>();
String filterString = constraint.toString().trim()
.toLowerCase();

// 検索ボックス内容は空の場合、元のデータを復元
if (TextUtils.isEmpty(filterString)) {
newValues = mBackData;
} else {
// 新しいデータをフィルタリング
for (String str : mBackData) {
if (-1 != str.toLowerCase().indexOf(filterString)) {
newValues.add(str);
}
}
}

results.values = newValues;
results.count = newValues.size();

return results;
}

@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
mData = (List<String>) results.values;

if (results.count > 0) {
mAdapter.notifyDataSetChanged(); // 通知データが変更される
} else {
mAdapter.notifyDataSetInvalidated(); // 通知データ無効
}
}
}
}

// 検索テキストリスナー
private class QueryListener implements OnQueryTextListener {
// コンテンツ提出された
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}

// 検索ボックスのコンテンツの変更を実行
@Override
public boolean onQueryTextChange(String newText) {
if (TextUtils.isEmpty(newText)) {
mListView.clearTextFilter(); // ListViewフィルタのクリアアップ
} else {
mListView.setFilterText(newText); // ListViewのフィルタリングキーワードの設定
}
return true;
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);

// メニューのsearchViewコンポーネントを取得
mSearchView = (SearchView) MenuItemCompat.getActionView(menu
.findItem(R.id.search));

// リスナーの設定
mSearchView.setOnQueryTextListener(new QueryListener());
return true;
}

private void initData() {
for (int i = 0; i < 50; i++) {
mData.add(“hello android ” + i);
}
mBackData = mData;
}

private class ItemClick implements OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
Toast.makeText(MainActivity.this, mData.get(position),
Toast.LENGTH_SHORT).show();
}
}
}