Showing posts with label Operating system. Show all posts
Showing posts with label Operating system. Show all posts

Friday, May 20, 2011

Nagios监控报警安装

一.Nagios简介



Nagios是一款遵循GPLv2的开源网络监控软件,可用来监控指定的多种系统的主机、服务,并可在它们的工作状态发生变化时通知管理员。

  1. 监控网络服务(HTTP、POP3、SMTP、PING、MySQL等)

  2. 监控主机资源(磁盘空间利用率、内存利用率、CPU负载等)

  3. 简洁的插件设计接口,使得用户可以轻松开发所需的检测脚本

  4. 并行服务模式

  5. 轻松描述网络结构,并且能够区辨“宕机”和“主机不可达”

  6. 通过邮件或用户自定义的方式将主机或服务的工作状态变化情况通知给管理员6)当服务或主机问题产生与解决时将告警发送给联系人(通过EMail、短信、用户定义方式) ?可以通过飞信,等方式实现时,既可传递给管理员,可高效的保证服务器的维护。

  7. 自动日志滚动

  8. 支持以冗余方式进行主机监控

  9. 可以通过web方式直观的查看当前网络状态、通知和问题历史、日志文件等等,此组件为可选



Tuesday, September 21, 2010

Monday, June 7, 2010

永久转向

[cc lang='apache' line_numbers='false']
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*) http://fred.oracle1.com/$1 [R=301,L][/cc]

Tuesday, May 11, 2010

用 GPG 加密文件

在 Linux 下,用 gpg 命令就可以实现文件的加密和解密,而且 gpg 基本上每个发行版都会预装。
假如你要加密的文件名为 xxx.txt ,只需输入:
[cc lang="bash"]gpg -c xxx.txt[/cc]
经过两次输入密码确定,就会在目录下生成 xxx.txt.gpg,这个就是加密后的文件,不要忘记把原文件删掉哦~
解密的话,输入:
[cc lang="bash"]gpg diary.txt.gpg[/cc]
输入正确的密码,diary.txt 就会在当前目录下重新生成。

Tuesday, April 20, 2010

A new munin node client for windows

[caption id="attachment_1452" align="aligncenter" width="305" caption="Munin Monitor"]Munin Monitor[/caption]I fork a new munin node client for windows this week. everyone can download source, post bug report and download release binary at google code.

Changelogs


  • add CIDR network address access (192.168.0.0/24)

  • don't send logevent when munin master connect

  • add logError function to service.cpp

  • add master ipaddress config

  • add wether log connections config

  • don't rewrite new config file


Monday, March 1, 2010

cpulimit - 限制进程的 CPU 占用率




[caption id="attachment_1358" align="aligncenter" width="413" caption="cpulimit"][/caption]

cpulimit 是一个简单而有用的小程序,通过它你可以限制一个进程的 CPU 占用率。如果善加利用,必将成为系统管理员的得力助手。

cpulimit 的用法也很简单,如上图所示,通过 -e 选项指定需控制的进程名(或 -p 选项指定 pid),-l 选项指定 CPU 的占用百分比即可。这里,我将 Chrome 的 CPU 占用率限制到 25%。

cpulimit 可从其项目主页下载,或通过你所用的 Linux 发行版包管理器安装。

Thursday, February 25, 2010

Bash Shell Keyboard shortcuts

The following shortcuts work when using default (Emacs) key bindings. Vi-bindings can be enabled by running [cci]set -o vi[/cci].

[cci]Tab ⇆[/cci] : Autocompletes from the cursor position.
[cci]Ctrl+a[/cci] : moves the cursor at the beginning of the line (equivalent to the key [cci]Home[/cci]).
[cci]Ctrl+e[/cci] : (end) moves the cursor at the line end (equivalent to the key [cci]End[/cci]).
[cci]Ctrl+p[/cci] : (previous) recalls the previous command (equivalent to the key [cci]↑[/cci]).
[cci]Ctrl+n[/cci] : (next) recalls the next command (equivalent to the key [cci]↓[/cci]).
[cci]Ctrl+r[/cci] : (research) recalls the last command including the specified character(s). A second [cci]Ctrl+r[/cci] recalls the next anterior command which corresponds to the research
[cci]Ctrl+s[/cci] : Go back to the next more recent command of the research (beware to not execute it from a terminal because this command also launches its XOFF). If you changed that XOFF setting, use [cci]Ctrl+q[/cci] to return.
[cci]Ctrl+o[/cci] : executes the found command from research.
[cci]Ctrl+l[/cci] : clears the screen content (equivalent to the command clear).
[cci]Ctrl+u[/cci] : clears the line content before the cursor and copy it in the clipboard.
[cci]Ctrl+k[/cci] : clears the line content after the cursor and copy it in the clipboard.
[cci]Ctrl+w[/cci] : clears the word before the cursor and copy it in the clipboard.
[cci]Ctrl+y[/cci] : (yank) adds the clipboard content from the cursor position.
[cci]Ctrl+d[/cci] : sends an EOF marker, which (unless disabled by an option) closes the current shell (equivalent to the command exit).
[cci]Ctrl+c[/cci] : sends the signal SIGINT to the current task, which aborts and closes it.
[cci]Ctrl+z[/cci] : sends the signal SIGTSTP to the current task, which suspends it. To return to it later one can enter fg 'process name' (foreground).
[cci]Ctrl+x Ctrl+x[/cci] : (because x has a crossing shape) alternates the cursor with its old position.
[cci]Ctrl+x Ctrl+e[/cci] : (editor because it takes the $EDITOR shell variable) edits the current line in vi.
[cci]Alt+f[/cci] : (forward) moves forward the cursor of one word.
[cci]Alt+b[/cci] : (backward) moves backward the cursor of one word.
[cci]Alt+Del[/cci] : cuts the word before the cursor.
[cci]Alt+d[/cci] : cuts the word after the cursor.
[cci]Alt+u[/cci] : capitalizes every character from the cursor's position to the end of the current word.
[cci]Alt+l[/cci] : lowers the case of every character from the cursor's position to the end of the current word.
[cci]Alt+c[/cci] : capitalizes the character under the cursor and moves to the end of the word.
[cci]Alt+r[/cci] : cancels the changes and put back the line as it was in the history.

Tuesday, February 9, 2010

Thursday, July 24, 2008

header include path

where exactly is clanlib on your system?

as for picking up headers in non-standard locations, the CFLAGS environment variable takes care of that (and setting compiler optimizations and such) so for example if the header is in /usr/local/include/ClanLib-0.7/ClanLib you could:

export CFLAGS="-I/usr/local/include/ClanLib-0.7/ClanLib"

and it should pick up that directory

for the libs in nonstandard directories LDFLAGS or LD_LIBRARY_PATH will do (I like the latter better)
so for example if clanlib was installed in /usr/local/lib/clanlib you could:

export LD_LIBRARY_PATH=/usr/local/lib/clanlib:$LD_LIBRARY_PATH

which will set /usr/local/lib/clanlib as the first directory searched by the linker.

Tuesday, July 22, 2008

upgrade to kernel 2.6.26

[caption id="attachment_837" align="aligncenter" width="499" caption="Linux 2.6.26 内核"]Linux 2.6.26 内核[/caption]

升级到了最新的内核版本,据说内核版本号规则要换了……

Sunday, July 20, 2008

Kernel Daemons

If you issue the ps aux command, you will see something like the following:
USER PID %CPU %MEM SIZE RSS TTY STAT START TIME COMMAND
root 1 0.1 8.0 1284 536 ? S 07:37 0:04 init [2]
root 2 0.0 0.0 0 0 ? SW 07:37 0:00 (kflushd)
root 3 0.0 0.0 0 0 ? SW 07:37 0:00 (kupdate)
root 4 0.0 0.0 0 0 ? SW 07:37 0:00 (kpiod)
root 5 0.0 0.0 0 0 ? SW 07:37 0:00 (kswapd)
root 52 0.0 10.7 1552 716 ? S 07:38 0:01 syslogd -m 0
root 54 0.0 7.1 1276 480 ? S 07:38 0:00 klogd
root 56 0.3 17.3 2232 1156 1 S 07:38 0:13 -bash
root 57 0.0 7.1 1272 480 2 S 07:38 0:01 /sbin/agetty 38400 tt
root 64 0.1 7.2 1272 484 S1 S 08:16 0:01 /sbin/agetty -L ttyS1
root 70 0.0 10.6 1472 708 1 R Sep 11 0:01 ps aux

This is a list of the processes running on the system. The information comes from the /proc filesystem that I mentioned in the codevious section. Note that init is process number one. Processes 2, 3, 4 and 5 are kflushd, kupdate, kpiod and kswapd. There is something strange here though: notice that in both the virtual storage size (SIZE) and the Real Storage Size (RSS) columns, these processes have zeroes. How can a process use no memory?

关于/etc/inputrc的说明

Inputrc 用来处理键盘映射表。这个文件在启动的时候被bash(或其他shell)使用的库readline调用。

阅读info bash -- 小节: Readline Init file 和info readline可以获得更多信息。这个rc文件可以作很多事情。

接下来的是一个基本的/etc/inputrc,其中有对各个配置参数的解释。

请注意这些注释不能和inputrc中的命令处作在同一行。

# /etc/inputrc 的开始

# 确认我们不会在同一行中输出所有的东西。
set horizontal-scroll-mode Off

# 开启8比特输入
set meta-flag On
set input-meta On

# 禁止对第8个比特过滤
set convert-meta Off

# 在显示时保存第8个比特
set output-meta On

# 关闭可视和声音提示
set bell-style none

# 下面的内容给出了在readline
# 函数第一部分中包括的换码符序列的值

"\eOd": backward-word
"\eOc": forward-word

# 在控制台使用
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert

# xterm使用
"\eOH": beginning-of-line
"\eOF": end-of-line

# /etc/inputrc结束


全局的设定值包含在 /etc/inputrc中。每个用户自己的值设定于~/.inputrc。

~/.inputrc
若存在,则会忽略全局设定值。前面bash设定中缺省调用 /etc/inputrc

如果你想让系统同时使用两个设定,可以把一个 .inputrc放到/etc/skel 中给每一个新建立的用户使用。

Saturday, July 19, 2008

一键清理系统垃圾文件脚本

在很多同事的桌面上都有clean.bat这个一键清理脚本。我也用过几次,clean.bat就是一个通过清理操作系统c盘临时文件和优化启动缓存来加速系统的工具。发现有时候这个脚本运行起来会比较慢,重新整理了一下脚本次序,并且将清空cookie和清空打开文件历史之类比较得不偿失的操作注释掉了。你一般如何评估系统启动的速度呢? 我是看XP登录前那个横向滚动条的滚动次数,一般首次清理以后,能减少40%左右的启动时间。代码附后:
@echo off

echo 清空IE临时文件目录...
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"

echo 正在清除系统临时文件 *.tmp *._tmp *.log *.chk *.old ,请稍等...
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old

echo 清空垃圾箱,备份文件和预缓存脚本...
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\codefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp

rem cooke和最近历史还是保留吧...
rem del /f /q %userprofile%\COOKIES s\*.*
rem del /f /q %userprofile%\recent\*.*

echo 清理系统盘无用文件...
%windir%\system32\sfc.exe /purgecache

echo 优化预读信息...
%windir%\system32\defrag.exe %systemdrive% -b

echo 清除系统完成!

echo. & pause

http://www.chedong.com/blog/archives/001362.html

Tuesday, April 8, 2008

awk url

http://www.grymoire.com/Unix/Awk.html

用grep 的时候可能很慢,是因为使用了utf-8系统环境语言变量,换成C或者en_US就好了,在gzip的使用也可能会遇到类似问题~

Tuesday, December 11, 2007

RHEL AS5 通过yum update自动升级

1.下载并安装yum-2.4.0-1.centos4.noarch.rpm文件,下载地址为:
ftp://ftp.pbone.net/mirror/ftp.centos.org/5.0/os/i386/CentOS/yum-cron-0.1-1.el5.centos.noarch.rpm

2.修改或建立/etc/yum.repos.d/rhel-debuginfo.repo为如下内容:
[base]
name=Red Hat Enterprise Linux $releasever -Base
baseurl=http://ftp.riken.jp/Linux/caos/centos/5.0/os/$basearch/
gpgcheck=1
[update]
name=Red Hat Enterprise Linux $releasever -Updates
baseurl=http://ftp.riken.jp/Linux/caos/centos/5.0/updates/$basearch/
gpgcheck=1
[extras]
name=Red Hat Enterprise Linux $releasever -Extras
baseurl=http://ftp.riken.jp/Linux/caos/centos/5.0/extras/$basearch/
gpgcheck=1
[addons]
name=Red Hat Enterprise Linux $releasever -Addons
baseurl=http://ftp.riken.jp/Linux/caos/centos/5.0/addons/$basearch/
gpgcheck=1


3.修改或建立/etc/yum.repos.d/dag.repo为如下内容:

[dag]
name=Dag RPM Repository for RHEL5
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/
enabled=1
gpgcheck=1
gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt



4.运行update:

yum update

5.升级:
yum upgrade

6.安装其它软件,例如:
yum install mplayer

Wednesday, November 21, 2007

Centos libstdc++.so.5

CentOS libstdc++.so.5 可以这样安装:
sudo yum install compat-libstdc++-33.i386

Tuesday, November 20, 2007

Oracle Startup Script


#!/bin/sh
#
# dbora This scripts starts and shuts down the
# oracle database
#
# chkconfig: 345 99 10
# description: This script calls the dbstart script
# to start Oracle
# and dbshut to stop it
# processname: oracle*
# config: /etc/oratab
#
# Set ORACLE_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORACLE_HOME.
export ORACLE_BASE=/opt/oracle10
export ORACLE_HOME=/opt/oracle10
export ORACLE_SID=DSSDB
ORACLE_HOME=/opt/oracle10
ORA_OWNER=oracle
if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
su $ORA_OWNER -c $ORACLE_HOME/bin/dbstart &
su $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start" &
;;
'stop')
su $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop " &
su $ORA_OWNER -c $ORACLE_HOME/bin/dbshut &
;;
'restart')
su $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop " &
su $ORA_OWNER -c $ORACLE_HOME/bin/dbshut &
sleep 15
su $ORA_OWNER -c $ORACLE_HOME/bin/dbstart &
su $ORA_OWNER -c "$ORACLE_HOME/bin/lsnrctl start " &
;;
esac

Saturday, July 21, 2007

A good win32 apache module binary download site

I found a very good win32 apache module binary download site, English site. You can download many binary module there. such as:

  • mod_perl

  • mod_fcgid

  • mod_macro



and this site is very cool for apache users! ;)

Friday, July 20, 2007

Using Telnet with a POP3 Mail Server

It is possible, with many ISPs, to use a Telnet program to do maintenance on your mailbox on the POP3 mail server. This allows you to look at, and possibly delete, any problem causing message (e.g. too large to download, improperly formatted message, etc.)

The instructions below are based on the Win95 TELNET.EXE program. See here for some other Telnet programs and operating systems.

From the Win95 task bar, select: Start, Run..., and enter the following:

telnet pop-server-name port#
(Note: if you start Telnet from the browser, rather than the Win95 Start Run command, the syntax is telnet://pop-server-name:port# - However, MSIE 3 has a bug and you must leave out the // on the address line and use telnet:pop-server-name:port#)

Check your mail settings for the pop-server-name and port#. Most POP3 servers use port 110.

For example:
- For CNZX Internet: telnet mail.cnzx.info 110
- For AT&T Worldnet: telnet postoffice.worldnet.att.net 110
- For Netcom: telnet popd.ix.netcom.com 110
- For SpryNet: telnet m#.sprynet.com 110
(# is 1 to 5 and varies by user)


This will connect to the mail server. If you fail to get a successful connection message, check the following:
You must include the correct port number, usually 110. The default Telnet port number won't work.
The syntax varies by how you start the Telnet program. On the Start, Run, you separate the server name and the port number with a Space. In the browser, you separate the server name and the port number with a Colon.
If starting from the browser, the browser must be configured to know about your Telnet program. The Win95 version of MSIE normally does this automatically on install. For Netscape, and the Win3.1 version of MSIE you usually need to do this manually. See your browser documentation. However, it is not necessary to start the program from the browser. You can start it directly.
MSIE 3 may not start the Telnet program from its address line if you use the "//" in the URL. Just remove the "//".
You will want to enable Local Echo so you can see what you type. In the Win95 Telnet program this is under Terminal, Preferences. Also, you may want to turn on logging to capture messages to a text file. In the Win95 Telnet program this is under Terminal, Start Logging

For the connection, and each command that you enter, the mail server will respond:

Saturday, June 30, 2007

取消某个目录的PHP运行权限

RemoveHandler .cgi
RemoveHandler .php
RemoveHandler .pl
RemoveHandler .py


在 .htaccess 中或者是 httpd.conf 配置中设定就可以了。