pencat

从明天起,关心粮食和蔬菜。我有一所房子,面朝大海,春暖花开

生命不熄 败家不止

我对电子产品向来没什么抵抗力. 今天败了htc p4550和sony prs 505. 等货到手这段时间是最心焦的. p4550还好, 是天津过来的. 505得从美国过来. 估计得个10天半月

我等 我等

Centos5.2 下的 vsftpd 虚拟用户

安装步骤基本和Ubuntu下差不多, 只不过需要多装一个pam_userdb, 我是yum装的 yum install db4-utils

ubuntu下参考之前的文章: http://blog.bigcomic.com/post/241.html

有一点不同的是ubuntu下的pam日志在 /var/log/auth.log.  而centos5.2是在 /var/log/secure

 

EOF

侧边栏工具 TopWords

基本功能写出来了, 没有时间优化, 凑合着用先...

下载TopWords

Nagios学习笔记 (1)

NRPE

NRPE is an addon that allows you to execute plugins on remote Linux/Unix hosts. This is useful if you need to monitor local resources/attributes like disk usage, CPU load, memory usage, etc. on a remote host. Similiar functionality can be accomplished by using the check_by_ssh plugin, although it can impose a higher CPU load on the monitoring machine - especially if you are monitoring hundreds or thousands of hosts.

nrpe

 

NSCA

NSCA is an addon that allows you to send passive check results from remote Linux/Unix hosts to the Nagios daemon running on the monitoring server. This is very useful in distributed and redundant/failover monitoring setups.

nsca

 

NSClient++

Monitoring private services or attributes of a Windows machine requires that you install an agent on it. This agent acts as a proxy between the Nagios plugin that does the monitoring and the actual service or attribute of the Windows machine. Without installing an agent on the Windows box, Nagios would be unable to monitor private services or attributes of the Windows box.

monitoring-windows

 

NDOUtils

NDOUtils is an addon that allows you to store all status information from Nagios in a MySQL database. Multiple instances of Nagios can all store their information in a central database for centralized reporting. This will likely serve as the basis for a new PHP-based web interface for Nagios in the future.

ndoutils

Wall E

wall_e_1

wall_e_2

 

侧边栏开发计划

整天在电脑前工作却很少有时间去看新闻, 搞到不闻不问天下事. 久而久之孤陋寡闻.  拥有最先进的新闻渠道, 却也是什么都不知道.

Vista推出一个很有意思的东西Sidebar. 可以在桌面显示一些小工具.  

这周计划制作一个工具, 可以显示当前最热门的关键词.

 

参考地址:

http://msdn.microsoft.com/en-us/library/aa974179.aspx#rightui

http://msdn.microsoft.com/en-us/library/bb456468(VS.85).aspx#_sidebar_basic_example

 

EOF

解决/dev/fb0无法打开的问题

    最近要在Linux做基于frame Buffer的图形显示,不论我在独立分区的Linux FC6系统中,还是在装有Red hat9的VPC中,都无法打开/dev/fb0。从网上找了很多资料,都没能解决。经过几天的的郁闷之后,终于解决了这个问题。先记录如下:
    1、首先确认对Frame Buffer的支持是否编译到Linux的内核中。在安装的Linux中,默认都会把这个支持打开编译到内核中。但是如果自己重新编译了内核,或者升级内核,得确认把Frame Buffer的支持编入内核,并且还要把Console display driver support编译到内核中,还要把Logo configuration编译到内核中。这些选项都在Device drivers下的graphics support选项下。
    2、在启动项中打开对Frame Buffer的支持。由于虽然把对Frame Buffer的支持编译到内核中了,但是默认下是没有打开的。故要修改/boot/grub/menu.lst文件。在该文件的kernel那一行后面加上vga=0xXXX,0xXXX表示的是屏幕的分辨率和色彩数。
    其中vga=0x后面的数值可以从下表中查出。
色彩数 640 X 480 800X600 1024X768 1280X1024
256 0x301 0x303 0x305 0x307
32k 0x310 0x313 0x316 0x319
64k 0x311 0x314 0x317 0x31A
16M 0x312 0x315 0x318 0x31B
    我原先的/boot/grub/menu.lst文件如下:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: 
You have a /boot partition.  This means that
         all kernel and initrd paths are relative to /boot/, eg.
         root (hd0,0)
         kernel /vmlinuz-version ro root=/dev/hda3
         initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.6.18)
 
root (hd0,0)
 
kernel /vmlinuz-2.6.18 ro root=LABEL=/ 
 
initrd /initrd-2.6.18.img
title Red Hat Linux (2.4.20-8)
 
root (hd0,0)
 
kernel /vmlinuz-2.4.20-8 ro root=LABEL=/ 
 
initrd /initrd-2.4.20-8.img
    因为我对red hat9升级了一个2.6.18的内核,故有两个启动项。修改后,如下:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: 
You have a /boot partition.  This means that
         all kernel and initrd paths are relative to /boot/, eg.
         root (hd0,0)
         kernel /vmlinuz-version ro root=/dev/hda3
        
initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.6.18)
 
root (hd0,0)
 
kernel /vmlinuz-2.6.18 ro root=LABEL=/ vga=0x311
 
initrd /initrd-2.6.18.img
title Red Hat Linux (2.4.20-8)
 
root (hd0,0)
 
kernel /vmlinuz-2.4.20-8 ro root=LABEL=/ vga=0x311
 
initrd /initrd-2.4.20-8.img
 
    3、重启系统。然后运行cat /dev/fb0,如果发现有一堆乱码输出在屏幕上,则表示找到了/dev/fb0这个设备。如果没有,则可能是你的显卡不支持。
    通过上述操作以后,我的虚拟机中的Linux和独立分区装的Linux都可以打开/dev/fb0了。最后还说一句,打开/dev/fb0是在控制台下打开,在XWindow界面下能打开,但是操作屏幕缓存区画图的时候,会不正确。

django的数据库操作

过滤器组合:
Q(id__ge=10),Q(pid__ge=10)  (id > 10) AND (pid > 10)
Q(id__ge=10)|Q(pid__ge=10)  (id > 10) OR (pid > 10)

条件搜索:
order_by()    排序
distinct()    消除重复结果
id__gt=10    id >  10
id__gte=10    id >= 10
id__lt=10    id <  10
id__lte=10    id <= 10
id__startswith='xx'   id like 'xx%'
id__istartswith='xx'   id ILIKE 'xx%'
id__endswith='xx'   id LIKE '%xx'
id__iendswith='xx'   id ILIKE '%xx'
id__exact='xx'    id LIKE 'xx'
id__iexact='xx'    id ILIKE 'xx'
id__contains='xx'   id LIKE '%xx%'
id__icontains='xx'   id ILIKE '%xx%'
id__in=[1, 3, 4]   id IN (1, 3, 4)
id__exact=14    id = 14
id__exact=None    id IS NULL
id__isnull=Ture    id IS NULL
start_date = datetime.date(2005, 1, 1)
end_date = datetime.date(2005, 3, 31)
id__range=(start_date, end_date) id BETWEEN '2005-01-01' and '2005-03-31';
id__year=2009    EXTRACT('year' FROM id) = '2009'
id__iregex=r'^(an?|the) +'  id REGEXP '^(an?|the) +'


返回结果数量限制:
Entry.objects.all()[:5]   LIMIT 5
Entry.objects.all()[5:10]  OFFSET 5 LIMIT 5
Entry.objects.all()[:10:2]  step 2
Entry.objects.order_by('headline')[0] LIMIT 1


数据操作:
.delete()    删除
.save()     更新
.count()    结果数量

 

容错处理:

from django.core.exceptions import ObjectDoesNotExist
try:
 e = Entry.objects.get(id=3)
except ObjectDoesNotExist:
 print "Either the entry doesn't exist."


try:
    obj = Person.objects.get(first_name='John', last_name='Lennon')
except Person.DoesNotExist:
    obj = Person(first_name='John', last_name='Lennon', birthday=date(1940, 10, 9))
    obj.save()
 

centos5.2下编译安装lighttpd,python2.5,django1.0.2,mysql5.2

mysql
# tar zxvf mysql-5.1.30.tar.gz
# cd mysql-5.1.30
# ./configure --prefix=/usr/local/mysql --enable-thread-safe --enable-assembler --enable-shared --with-charset=utf8 --with-

collation=utf8_general_ci --with-mysqld-ldflags=-all-static --without-debug
# make && make install
# cp /usr/src/mysql-5.1.30/support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
# cp support-files/my-medium.cnf /etc/my.cnf
# vi /etc/my.cnf
  - skip-federated
  + #skip-federated
# ./scripts/mysql_install_db
# cd /usr/local
# groupadd database
# adduser mysql -G database
# vi /etc/passwd
  - mysql:x:500:501::/home/mysql:/bin/bash
  + mysql:x:500:501::/home/mysql:/sbin/nologin
# chmod 750 mysql -R
# chgrp database mysql -R
# chown mysql mysql/var -R
# ln -s /usr/local/mysql/bin/mysql /sbin/mysql
# ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin
# ln -s /usr/local/mysql/bin/mysql_config /sbin/mysql_config
# service mysqld start

 


Python
# tar zxvf Python-2.5.2.tgz
# cd Python-2.5.2
# ./configure --prefix=/usr/local/python
# make && make install
# ln -s /usr/local/python/bin/python /usr/bin/python
# ln -s /usr/local/python/lib/python2.5 /usr/lib/python2.5

MySQL-python
# tar zxvf MySQL-python-1.2.2.tar.gz
# cd MySQL-python-1.2.2
# python setup.py install
# ln -s /usr/local/mysql/lib/mysql/libmysqlclient_r.so.16 /usr/lib/libmysqlclient_r.so.16
# python
>>> import MySQLdb /检验mysql-python安装是否正确
 


Django
# tar xzvf Django-1.0.2-final.tar.gz
# cd Django-1.0.2-final
# python setup.py install

 


pcre
# tar zxvf pcre-7.8.tar.gz
# cd pcre-7.8
# ./configure
# make && make install

lighttpd
# tar xzvf lighttpd-1.4.20.tar.gz
# cd lighttpd-1.4.20
# ./configure --prefix=/usr/local/lighttpd --disable-ipv6 --with-linux-aio  --without-bzip2
# make && make install
# mkdir /usr/local/lighttpd/conf
# mkdir /usr/local/lighttpd/logs
# cp doc/lighttpd.conf /usr/local/lighttpd/conf/
# vi /usr/local/lighttpd/conf/lighttpd.conf
  @ server.document-root
  @ server.errorlog
  @ index-file.names
  @ accesslog.filename
# cp doc/rc.lighttpd.redhat /etc/rc.d/init.d/lighttpd
# chmod 755 /etc/rc.d/init.d/lighttpd
# vi /etc/rc.d/init.d/lighttpd
  - LIGHTTPD_CONF_PATH="/etc/lighttpd/lighttpd.conf"
  + LIGHTTPD_CONF_PATH="/usr/local/lighttpd/conf/lighttpd.conf"
# chkconfig --add lighttpd
# chkconfig --level 345 lighttpd on

 
python-flup
# tar zxvf flup-1.0.1.tar.gz
# cd flup-1.0.1
# python ez_setup.py
# python setup.py install

 

#  
# vi settings.py
  + FORCE_SCRIPT_NAME = ""

# vi /usr/local/lighttpd/conf/lighttpd.conf
  - # mod_rewrite
  + mod_rewrite
  - # mod_fastcgi
  + mod_fastcgi
  + fastcgi.server = ( "/mysite.fcgi" =>
  +                   ( "main" =>
  +                       ( "socket" => "/tmp/fcgi.sock",
  +                         "check-local" => "disable",
  +                       )
  +                   )
  + ) 
  + url.rewrite = (
  +      "^(/media.*)$" => "$1",
  +      "^(/.*)$" => "/mysite.fcgi$1",
  + )


# service lighttpd restart

 

 

#server.document-root        = "/home/radio/htdocs/"
server.document-root = "/home/radio/workspace/pywork/bigcomic/"

     "^(/media.*)$" => "$1",
     "^(/.*)$" => "/mysite.fcgi$1"

svn 1.50 编译安装

下载subversion-1.5.0.tar和subversion-deps-1.5.0.tar
# tar xvf subversion-1.5.0.tar 
# tar xvf subversion-deps-1.5.0.tar //会解到一个subversion-1.5.0目录下
# cd subversion-1.5.0
# ./configure -prefix=/usr/local/svn
# make
# make install
# mkdir /home/svndata //建立项目的存储库
# vi svn_service
#!/bin/sh

#
# chkconfig: - 91 35
# description: Starts and stops the Subversion service
# subversion options

OPTIONS="-d -r /home/svndata"

prog=_subversion
RETVAL=0
_subversion=/usr/bin/svnserve

# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

start() {
        KIND="SubVersion"
    echo -n $"Starting $KIND services: "
    daemon $_subversion $OPTIONS
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/subversion || \
     RETVAL=1
    return $RETVAL
}   

stop() {
        KIND="SubVersion"
    echo -n $"Shutting down $KIND services: "
    killproc $_subversion
    RETVAL=$?
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/subversion
    echo ""
    return $RETVAL
}   

restart() {
    stop
    start
}   

case "$1" in
  start)
      start
    ;;
  stop)
      stop
    ;;
  restart|reload)
      restart
    ;;
  status)
        status $dc_server
    RETVAL=$?
    ;;
  condrestart)
      [ -f /var/lock/subsys/subversion ] && restart || :
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"
    exit 1
esac

exit $?

# chmod 755 svn_service
# cp svn_service /etc/rc.d/init.d/svn
# chkconfig --add svn
# chkconfig --level 345 svn on
# netstat -an|grep 3690  //查看svn的端口是否已经开启,没记错的话应该就是3690端口
可以使用绿毛龟(svn客户端)来查看项目情况,使用svn://ip:port/test来查看项目源码

 

配置
#cd /home/svndata/test/conf
#vi authz
 [groups]对组进行配置
 # harry_and_sally = harry,sally

 # [/foo/bar]按目录进行用户读写配置
 # harry = rw
 # * =

 [repository:/test]对svn库的路径进行配置
 # @harry_and_sally = rw
 # * = r
 radio=rw
 pencat=rw
 koala=rw
 soul=rw
#vi passwd
 [users]
 # harry = harryssecret
 # sally = sallyssecret
 radio=123456
 都是明文的
#vi svnserv.conf
password-db = passwd将这行的注释去掉,就会要求用户验证

svn换端口
#./svnserve --help 可以看到命令,里面有个参数--listen-port
不过我没有使用过


因为ssl关系出现认证失败的解决办法
1、停掉ssl
2、# authz-db = authz这行的#保留

#去掉#[general]前面的#号
[general]
#匿名访问的权限,可以是read,write,none,默认为read
anon-access = none
#认证用户的权限,可以是read,write,none,默认为write
auth-access = write
#密码数据库的路径,去掉前面的#
password-db = passwd

分页:[«]3[4][5][6][7][8][9][10][11][12][13][14][15][16][17][»]

Powered By Z-Blog 1.8 Devo Build 80201

Copyright © 1998-2007 bigcomic.com All rights reserved.