Skip to content


as4 升级默认python-2.3.4-14.4到2.6.2

RHEL 4 自带的Python有点旧了,为python-2.3.4-14.4版本的,所以决定升级到最新版本2.6.2。

rpm -qa |grep python

gnome-python2-2.6.0-3 mod_python-3.1.3-5 python-devel-2.3.4-14 libxml2-python-2.6.16-6 rpm-python-4.3.3-7_nonptl gnome-python2-bonobo-2.6.0-3 dbus-python-0.22-11.EL python-ldap-2.0.1-2 python-2.3.4-14 gnome-python2-canvas-2.6.0-3 MySQL-python-1.0.0-1.RHEL4.1

如果用

rpm -e python-2.3.4-14.4

是删除不了的,因为有程序依赖性的问题。

  1. 下载最新源代码包
wget http://www.python.org/ftp/python/2.6.2/Python-2.6.2.tar.bz2 tar jxvf Python-2.6.2.tar.bz2 cd Python-2.6.2
  1. 安装 (原始目录为/usr,以前的ptyhon可能有依赖关系,安装在新目录)
./configure –prefix=/usr/local make make install
  1. 创建链接
mv /usr/bin/python /usr/bin/python_bak (保存原来的版本) ln -s /usr/local/bin/python /usr/bin
  1. 测试效果
python

Python 2.6.2 (r262:71600, May 13 2009, 14:52:27) [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2 Type “help”, “copyright”, “credits” or “license” for more information.

参考: http://bbs2.chinaunix.net/archiver/tid-1266412.html

Posted in linux 维护优化, 技术.

Tagged with .


Nagios 通过snmp检查网卡流量

google一下snmp的漏洞,避免下载到未打补丁的版本

Net-SNMP远程绕过认证漏洞 受影响系统: Net-SNMP net-snmp 5.4.x Net-SNMP net-snmp 5.3.x Net-SNMP net-snmp 5.2.x

不受影响系统: Net-SNMP net-snmp 5.4.1.1 Net-SNMP net-snmp 5.3.2.1 Net-SNMP net-snmp 5.2.4.1

检查有无安装snmp

rpm -qa|grep snmp

下载net-snmp http://www.net-snmp.org/download.html http://nchc.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-5.4.2.1-1.f9.i386.rpm http://nchc.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-devel-5.4.2.1-1.f9.i386.rpm http://nchc.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-perlmods-5.4.2.1-1.f9.i386.rpm

安装snmp

rpm -ivh net-snmp-*.rpm

error: Failed dependencies: libc.so.6(GLIBC_2.4) is needed by net-snmp-5.4.2.1-1.i386 libc.so.6(GLIBC_2.7) is needed by net-snmp-5.4.2.1-1.i386 librpm-4.4.so is needed by net-snmp-5.4.2.1-1.i386 librpmio-4.4.so is needed by net-snmp-5.4.2.1-1.i386

检查glib版本

rpm -qa | grep glibc

glibc-2.3.4-2 glibc-common-2.3.4-2 glibc-kernheaders-2.4-9.1.87 glibc-devel-2.3.4-2 glibc-headers-2.3.4-2

glibc升级风险比较大,改用soure编译

先安装beecrypt

wget http://downloads.sourceforge.net/beecrypt/beecrypt-4.1.2.tar.gz tar zxvf beecrypt-4.1.2.tar.gz cd beecrypt-4.1.2 ./configure –prefix=/usr make

_bc-py.c:8:20: Python.h: No such file or directory

rpm -qa|grep python

rpm-python-4.3.3-18_nonptl gnome-python2-bonobo-2.6.0-3 python-2.3.4-14.2 libxml2-python-2.6.16-6 python-elementtree-1.2.6-4.2.1 python-sqlite-1.1.7-1.2 gnome-python2-2.6.0-3 gnome-python2-canvas-2.6.0-3 mod_python-3.1.3-5.1 dbus-python-0.22-12.EL.7 MySQL-python-1.0.0-1.RHEL4.1 python-urlgrabber-2.9.8-2

没有python-devel,升级下python https://blog.c1gstudio.com/archives/588

重新make make make install

更新动态库

ldconfig -v ln -s /lib/libelf.so.1 /usr/lib/libelf.so

安装net-snmp

wget http://nchc.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-5.4.2.1.tar.gz tar zxvf net-snmp-5.4.2.1.tar.gz cd net-snmp-5.4.2.1 ./configure -enable-mfd-rewrites -with-default-snmp-version=”2″ -with-sys-contact=”admin” -with-sys-location=”China” -with-logfile=”/var/log/snmpd.log” -with-persistent-directory=”/var/net-snmp”

编译的输出

SNMP Versions Supported: 1 2c 3 Net-SNMP Version: 5.4.2.1 Building for: linux Network transport support: Callback Unix TCP UDP SNMPv3 Security Modules: usm Agent MIB code: default_modules => snmpv3mibs mibII ucd_snmp notification notification-log-mib target agent_mibs agentx disman/event disman/schedule utilities host Embedded Perl support: enabled SNMP Perl modules: building — embeddable SNMP Python modules: disabled Authentication support: MD5 SHA1 Encryption support: DES AES make

安装出错

grep: /usr/lib/libbeecrypt.la: No such file or directory /bin/sed: can’t read /usr/lib/libbeecrypt.la: No such file or directory libtool: link: `/usr/lib/libbeecrypt.la’ is not a valid libtool archive #请安装beecrypt /usr/bin/ld: cannot find -lelf collect2: ld returned 1 exit status #ln -s libelf.so.1 /usr/lib/libelf.so make install ldconfig -v

community string 网络设备在使用SNMP中都设有community string,它类似于简单的口令验证机制,用来确认是否具有可读或读写的权限。许多用户在购买设备以来,从未修改系统缺省的community string,因此非授权用户使用缺省口令就可以对重要的系统信息、设备的状态等进行修改。 将”COMMUNITY”字段改为你要设置的密码.比如”public”或privatepass. 将“localhost”改为你想哪台机器可以看到你的snmp信息,如localhost或10.10.10.10。

SNMP的版本 在SNMP协议得益于重大升级,因为在1988年推出。 不幸的是,很大比例的网络内容供应商,甚至一些网络管理系统厂商都没有利用这些改进。 许多网络元素只支持SNMPv1和SNMPv2c 。 支持SNMPv3的是最小的。 版本 描述 SNMPv1 SNMPv1 ,其中实施以社区为基础的安全 SNMPv2c SNMPv2以社区为基础的安全 SNMPv2u SNMPv2与基于用户的安全 SNMPv2 SNMPv2党为基础的安全 SNMPv3安全机制 SNMPv3安全机制,而实现基于用户的安全

配置snmp

mkdir /usr/local/etc/snmp cp EXAMPLE.conf /usr/local/etc/snmp/snmpd.conf vi usr/local/etc/snmp/snmpd.conf # sec.name source community com2sec local localhost privatepass #com2sec mynetwork NETWORK/24 public #### # Second, map the security names into group names: # sec.model sec.name #group MyRWGroup v1 local #group MyRWGroup v2c local #group MyRWGroup usm local #group MyROGroup v1 mynetwork #group MyROGroup v2c mynetwork #group MyROGroup usm mynetwork group MyROGroup v1 local group MyROGroup v2c local #### # Third, create a view for us to let the groups have rights to: # incl/excl subtree mask #view all included .1 80 view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc #### # Finally, grant the 2 groups access to the 1 view with different # write permissions: # context sec.model sec.level match read write notif access MyROGroup “” any noauth exact mib2 none none #access MyRWGroup “” any noauth exact all all none

 

#启动 /usr/local/sbin/snmpd #加入启动 echo ‘/usr/local/sbin/snmpd’ >> /etc/rc.local #查看161端口是否开启 netstat -ano|grep 161 #测试 snmpwalk -v 1 -c privatepass localhost system

SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 2.6.9-5.ELsmp #1 SMP Wed Jan 5 19:30:39 EST 2005 i686 SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (2612) 0:00:26.12 SNMPv2-MIB::sysContact.0 = STRING: Me SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain SNMPv2-MIB::sysLocation.0 = STRING: Right here, right now. SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORID.1 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance SNMPv2-MIB::sysORID.2 = OID: SNMP-MPD-MIB::snmpMPDCompliance SNMPv2-MIB::sysORID.3 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB SNMPv2-MIB::sysORID.8 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup SNMPv2-MIB::sysORDescr.1 = STRING: The SNMP Management Architecture MIB. SNMPv2-MIB::sysORDescr.2 = STRING: The MIB for Message Processing and Dispatching. SNMPv2-MIB::sysORDescr.3 = STRING: The management information definitions for the SNMP User-based Security Model. SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing TCP implementations SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing UDP implementations SNMPv2-MIB::sysORDescr.8 = STRING: View-based Access Control Model for SNMP. SNMPv2-MIB::sysORUpTime.1 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.4 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.5 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.6 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.7 = Timeticks: (0) 0:00:00.00 SNMPv2-MIB::sysORUpTime.8 = Timeticks: (0) 0:00:00.00

snmp安装完毕

安装check_traffic脚本 下载check_traffic_v1.1.6.zip脚本 http://www.itnms.net/discuz/viewthread.php?tid=767&extra=pageD1&page=1 上传./check_traffic.sh 至/usr/local/nagios/libexec

cd /usr/local/nagios/libexec/ chown nagios:nagios ./check_traffic.sh chmod 755 ./check_traffic.sh

用 -L选项列出对应主机所有的interface,来确定你要监控的网络接口(如果能你确认接口的index值,这一步可以省略)。 通过输出,我们确认要监控的网络接口为4,对应为”Macronix MX98715-Based Ethernet Adapter (Generic) – 数据包计划程序微型端口”

./check_traffic.sh -V 2c -C privatepass -H localhost -L

List Interface for host localhost. Interface index 1 orresponding to lo Interface index 2 orresponding to eth0 Interface index 3 orresponding to eth1 Interface index 4 orresponding to sit0

按照说明,选择版本为2c(一般选择1或者2c),community为privatepass,interface为2,单位为KB/s,in流量对应warning/critical值为200/400,out流量对应warning/critical值为300/500.

sudo -u nagios ./check_traffic.sh -V 2c -C privatepass -H localhost -I 2 -w12,30 -c15,50 -K -b

Can not found data in the history data file. If it’s the first time for this plugins, that’s OK. Otherwise,please use debug mode and check the debug file.

第一次执行,因为history data file不存在,因此会由此提示,可以忽略。 如果每次执行都忽略,则要检查/var/tmp下是否有/var/tmp/checktraffic${Host}_${Interface}.hist_dat文件生成。 文件的内容是系统当前的时间,in及out当前的数值。

nagios监控本机的配置 修改/usr/local/nagios/etc/objects/commands.cfg,增下以下内容

define command{ command_name check_traffic_nv command_line $USER1$/check_traffic.sh -V 2c -C privatepass -H localhost -I $ARG1$ -w $ARG2$ -c $ARG3$ -M -b }

修改/usr/local/nagios/etc/objects/localhost.cfg,增下以下内容

define service{ use local-service,srv-pnp ; Name of service template to use host_name nagios service_description check_nv_traffic_eth0 check_command check_traffic_nv!2!12,30!15,35 notifications_enabled 0 normal_check_interval 5 ;5分钟 retry_interval 1 ;1分钟 }

  nagios监控远程机的配置

修改/usr/local/nagios/etc/objects/remotehost.cfg,增下以下内容

define service{ use local-service,srv-pnp ; Name of service template to use host_name nagios service_description check_nv_traffic_eth0 check_command check_nrpe!check_traffic_nv notifications_enabled 0 normal_check_interval 5 ;5分钟 retry_interval 1 ;1分钟 }

修改/usr/local/nagios/etc/nrpe.cfg增加以下内容

command[check_traffic_nv]=/usr/local/nagios/libexec/check_traffic_nv.sh -V 2c -C privatepass -H localhost -I 2 -w 12,30 -c 15,35 -M -b

访问http://localhost/nagios 点击Service Detail 点击check_nv_traffic_eth0服务旁的小太阳 等5分钟后就可以看到图表

which: no snmpwalk in (/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin) 如果check_nv_traffic_eth0服务报找不到snmpwalk.

ln -s /usr/local/bin/snmpwalk /usr/bin/snmpwalk

有时我作的软链接会丢失,挺奇怪的。。。

===================== 2014-09-24更新 固定网卡顺序 https://blog.c1gstudio.com/archives/1703

Posted in Nagios, 技术.

Tagged with , , .


查看Linux系统版本

这个命令适用于所有的linux,包括Redhat、SuSE、Debian等发行版

lsb_release -a

LSB Version: 1.3 Distributor ID: RedHatEnterpriseAS Description: Red Hat Enterprise Linux AS release 4 (Nahant) Release: 4 Codename: Nahant

cat /etc/redhat-release

Red Hat Enterprise Linux AS release 4 (Nahant)

rpm -q redhat-release

redhat-release-4AS-2

cat /proc/version

Linux version 2.6.9-5.EL ([email protected]) (gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)) #1 Wed Jan 5 19:22:18 EST 2005

cat /etc/issue

Red Hat Enterprise Linux AS release 4 (Nahant) Kernel \r on an \m

Posted in Linux 命令, 技术.

Tagged with , .


Nagios NRPE监控远程主机

参考:http://space.itpub.net/228190/viewspace-578408

示意图:

http://www.nagios.org/images/addons/nrpe/nrpe.png

监控机安装NRPE

wget http://nchc.dl.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz tar zxvf nrpe-2.12.tar.gz cd nrpe-2.12 ./configure –prefix=/usr/local/nagios make all make install-plugin #监控机只需安装到这步

被监控机添加用户

groupadd nagios useradd -g nagios -d /usr/local/nagios -s /sbin/nologin nagios

被监控机安装plugin

wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz tar zxf nagios-plugins-1.4.13.tar.gz cd nagios-plugins-1.4.13 ./configure –with-nagios-user=nagios –with-nagios-group=nagios –prefix=/usr/local/nagios –with-ping-command=”/bin/ping” –with-mysql=/opt/mysql make make install #查看播件文件是否已安装在这个目录 ls /usr/local/nagios/libexec

被监控机安装NRPE

wget http://nchc.dl.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz tar zxvf nrpe-2.12.tar.gz cd nrpe-2.12 ./configure –prefix=/usr/local/nagios make all make install-plugin make install-daemon make install-daemon-config chown -R nagios:nagios /usr/local/nagios

配置 NRPE:

vi /usr/local/nagios/etc/nrpe.cfg allowed_hosts=127.0.0.1,192.168.1.91 #Nagios监控机的地址或域名

修改/etc/hosts.allow增加监控机ip

echo ‘nrpe:192.168.1.91’ >> /etc/hosts.allow

启动 NRPE 守护进程:

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

可以将此命令加入 /etc/rc.local ,以便开机自动启动。

echo “/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d” >> /etc/rc.local

检查 NRPE 是否正常: 在被监控机上

/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1

查看相应的端口:netstat -an |grep 5666 防火墙开启5666 允许局域网IP或固定IP连接

在监控主机上

/usr/local/nagios/libexec/check_nrpe -H $目标主机地址

都应该可以输出 NRPE 的版本: NRPE v2.12

检查可监控的服务 在被监控端的 nrpe.cfg 文件中,可以看到这样的配置: command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20 这是用来检查 CPU 负载的。

如果需要自定参数则使用下面命令 command[check_load]=/usr/local/nagios/libexec/check_load -w $ARG1$ -c $ARG2$ 并开启dont_blame_nrpe =1 开启参数将会带来一定的安全风险

被监控机重启nrpe

ps aux|grep nrpe kill $pid /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

监控机设置 在监控机commands.cfg 添加nrpe的定义

# ‘check_nrpe ‘ command definition define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }

增加hostA.cfg 在/usr/local/nagios/etc/objects/ 目录下新建文件:hostA.cfg 把A.cfg添加到nagios主机: echo “cfg_file=/usr/local/nagios/etc/objects/hostA.cfg” >> /usr/local/nagios/etc/nagios.cfg 如果要再添加B机器方法炮制就可以了

hostA.cfg

define host{ use generic-server host_name A alias A address A 的IP } define service{ use generic-service host_name A service_description load check_command check_nrpe!check_load #使用自定参数 #check_command check_nrpe!check_load!6.0,5.0,4.0!15.0,8.0,6.0 }

重启监控机nagios

service nagios reload

访问http://localhost/nagios就可以看到新增的机器了

如何修改nrpe端口 被监控机nrpe.cfg修改server_port为15666 /usr/local/nagios/libexec/check_nrpe -p 15666 -H 127.0.0.1

server_port=15666

重启nrpe

监控机commands.cfg增加-p 15666

define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 15666 -c $ARG1$ }

重启nagios就可以了

Connection refused or timed out 检查nrpe 端口 检查nrpe.cfg中allowed_hosts是否包含监控机ip地址 检查/etc/hosts.allow文件中监控机ip地址nrpe:192.168.1.91 检查iptables

开放5666端口

iptables -L iptables -A RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 5666 -j ACCEPT #注意顺序 iptables -L service iptables save service iptables restart

NRPE: Unable to read output 1.检查客户端nrpe的权限是否可读,可被nagios执行。 2.检查nrpe.cfg里面commands命令路径是否正确。

CHECK_NRPE: Error – Could not complete SSL handshake. 1.查看防火墙 2.nrpe.cfg中授权ip 3./etc/hosts.allow中授权ip

Posted in Nagios, 技术.

Tagged with , .


Nagios 使用sendEmail 发送邮件

http://yahoon.blog.51cto.com/13184/49722

wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.55.tar.gz tar –zxvf sendEmail-v1.55.tar.gz cd sendEmail-v1.55 cp sendEmail /usr/local/bin chmod 0755 /usr/local/bin/sendEmail /usr/local/bin/sendEmail –f [email protected]–t [email protected] –s mail.test.com –u “from nagios” –xu nagios –xp 123456–m nagios test

解释: -f 表示发送者的邮箱 -t 表示接收者的邮箱 -s 表示SMTP服务器的域名或者ip -u 表示邮件的主题 -xu 表示SMTP验证的用户名 -xp 表示SMTP验证的密码(注意,这个密码貌似有限制,例如我用d!5neyland就不能被正确识别) -m 表示邮件的内容

修改commands.cfg

# ‘notify-by-email’ command definition define command{ command_name notify-by-email command_line /usr/bin/printf “%b” “***** Nagios 2.9 *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$” | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s mail.test.com -u “** $NOTIFICATIONTYPE$ alert – $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” -xu nagios -xp 123456 }

Posted in Nagios, 技术.

Tagged with , .


nagios 3.X 安装 pnp 增加绘图功能

参考: http://www.pnp4nagios.org/pnp/start http://www.pnp4nagios.org/pnp/install

Required Software Perl >= 5.x without additional modules RRDtool >= 1.x, better 1.2 but not compulsory Attention: installing RRDtool without a packet manager might lead to missing dejavu fonts. If you see graphs without text then this may be the cause. PHP >= 4.3.8 for Webfrontend PHP-extension zlib and GD. Nagios 2.x oder higher

rrdtool安装参考 https://blog.c1gstudio.com/archives/459 nagios安装参考 https://blog.c1gstudio.com/archives/545

安装pnp

wget http://nchc.dl.sourceforge.net/sourceforge/pnp4nagios/pnp-0.4.14.tar.gz tar -xvzf pnp-0.4.14.tar.gz cd pnp-0.4.14 ./configure checking for rrdtool… no checking rrdtool path … no configure: error: is a directory! PNP needs the Path to the rrdtool binary! export PKG_CONFIG_PATH=/usr/local/rrdtool/lib/pkgconfig export PKG_CONFIG=/usr/local/rrdtool/bin/pkg-config export PATH=/usr/local/rrdtool/bin:$PATH *** Configuration summary for pnp 0.4.14 05-02-2009 *** General Options: ————————- ——————- Nagios user/group: nagios nagios Install directory: /usr/local/nagios HTML Dir: /usr/local/nagios/share/pnp Config Dir: /usr/local/nagios/etc/pnp Location of rrdtool binary: /usr/local/rrdtool/bin/rrdtool Version 1.3.7 RRDs Perl Modules: *** NOT FOUND *** RRD Files stored in: /usr/local/nagios/share/perfdata process_perfdata.pl Logfile: /usr/local/nagios/var/perfdata.log Perfdata files (NPCD) stored in: /usr/local/nagios/var/spool/perfdata/ Review the options above for accuracy. If they look okay, type ‘make all’ to compile. WARNING: The RRDs Perl Modules are not found on your System Using RRDs will speedup things in larger Installtions. make all make install make install-config make install-init

process_perfdata.pl 安装在 /usr/local/nagios/share/ 配置示例文件安装在/usr/local/nagios/libexecs config.php安装于/usr/local/nagios/etc/pnp

修改配置文件

cp /usr/local/nagios/etc/pnp/process_perf data.cfg-sample /usr/local/nagios/etc/pnp/process_perfdata.cfg vi /usr/local/nagios/etc/pnp/process_perfdata.cfg LOG_FILE = /usr/local/nagios/var/perfdata.log # # Loglevel 0=silent 1=normal 2=debug # LOG_LEVEL = 2 #先改为2

在界面上加上小太阳 参考:http://www.pnp4nagios.org/pnp/webfe

修改etc/objects/templates.cfg增加新命令

define host { name host-pnp register 0 action_url /nagios/pnp/index.php?host=$HOSTNAME$ process_perf_data 1 } define service { name srv-pnp register 0 action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$ process_perf_data 1 }

修改etc/objects/localhost.cfg增加相应命令

define host{ use linux-server,host-pnp ; Name of host templates to use ; This host definition will inherit all variables that are defined ; in (or inherited by) the linux-server host template definition. host_name localhost alias localhost address 127.0.0.1 } define service{ use local-service,srv-pnp ; Name of service template to use host_name localhost service_description PING check_command check_ping!100.0,20%!500.0,60% }

修改etc/nagios.cfg 找到如下几项,去掉注释

process_performance_data=1 host_perfdata_command=process-host-perfdata service_perfdata_command=process-service-perfdata

修改commands.cfg

# ‘process-host-perfdata’ command definition define command{ command_name process-host-perfdata #command_line /usr/bin/printf “%b” “$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n” >> /usr/local/nagios/var/host-perfdata.out command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl -d HOSTPERFDATA } # ‘process-service-perfdata’ command definition define command{ command_name process-service-perfdata #command_line /usr/bin/printf “%b” “$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n” >> /usr/local/nagios/var/service-perfdata.out command_line /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl }

修改pnp的web服务器配置文件nginx.conf,请注意安全问题,我这里未做安全验证。

location /pnp/ { root /usr/local/nagios/share/; location ~ .*\.php?$ { #fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fcgi.conf; } }

如果开启了open_basedir还需修改php.ini

open_basedir = “/opt/htdoc:/opt/php/lib/php:/tmp/session:/tmp/upload:/usr/local/nagios/share/pnp:/usr/local/nagios/etc/pnp:/usr/local/nagios/share/perfdata:/usr/local/rrdtool/bin/rrdtool”

重新加载配置文件

service nagios reload /bin/kill -HUP `cat /dev/shm/nginx.pid`

http://localhost/nagios 点击小太阳就可以看到图表了

Posted in Nagios, 技术.

Tagged with , .


Nagios 安装

nagios nagios

Nagios是一个用来监控主机、服务和网络的开放源码软件,很多大的公司或组织都在使用它。

参考资料: http://yahoon.blog.51cto.com/13184/41300 http://bbs.linuxtone.org/thread-1281-1-1.html http://bbs.linuxtone.org/thread-2269-1-1.html nagios官方文档 http://www.nagios.org/docs/ nagios中文文档 http://www.itnms.net/docs/nagios/cn/build/html/ nagios中文相关讨论区 http://bbs.linuxtone.org/forum-20-1.html http://www.itnms.net/discuz/forumdisplay.php?fid=10&pageD1

nagios下载地址: http://www.nagios.org/download/

这里选用 nagios-3.0.6.tar.gz nagios-plugins-1.4.13.tar.gz nrpe2.12 wget http://downloads.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz?use_mirror=nchc wget http://downloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz?use_mirror=nchc wget http://nchc.dl.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz

安装nagios 系统为as4 1.创建用户和用户组

#创建用户和用户组 useradd -m nagios

-s /sbin/nologin 禁止登录,运行命令时可能会有限制,也可以不加本限制

groupadd nagcmd usermod -G nagcmd nagios #将nginx或apache运行用户加入组中 usermod -G nagcmd nobody

2.安装nagios

tar zxvf nagios-3.0.6.tar.gz cd nagios-3.0.6 #gd默认安装路径 #./configure –with-command-group=nagcmd –prefix=/usr/local/nagios –with-gd-lib=/usr/lib64/ –with-gd-inc=/usr/include

./configure –with-command-group=nagcmd –prefix=/usr/local/nagios –with-gd-lib=/usr/local/gd2/lib –with-gd-inc=/usr/local/gd2/include #以下为编译结果

Configuration summary for nagios 3.0.6 12-01-2008 :

General Options:

Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagcmd Embedded Perl: no Event Broker: yes Install ${prefix}: /usr/local/nagios Lock file: ${prefix}/var/nagios.lock Check result directory: ${prefix}/var/spool/checkresults Init directory: /etc/rc.d/init.d Apache conf.d directory: /etc/httpd/conf.d Mail program: /bin/mail Host OS: linux-gnu

Web Interface Options:

HTML URL: http://localhost/nagios/ CGI URL: http://localhost/nagios/cgi-bin/ Traceroute (used by WAP): /bin/traceroute

Review the options above for accuracy. If they look okay, type ‘make all’ to compile the main program and CGIs.

make all make install make install-init make install-config make install-commandmode

3.安装nagios-plugins

tar zxvf nagios-plugins-1.4.13.tar.gz cd nagios-plugins-1.4.13 ./configure –with-nagios-user=nagios –with-nagios-group=nagios –prefix=/usr/local/nagios

checking for ping6… /bin/ping6 checking for ICMP ping syntax… 到这里就停住了,应该是ipv6问题,加上–with-ping-command参数编译

参考下面地址: http://www.linuxquestions.org/questions/linux-software-2/.configure-script-hangs-at-checking-for-icmp-ping-syntax…l-499235/ http://bbs.bitscn.com/195707 ./configure –with-nagios-user=nagios –with-nagios-group=nagios –prefix=/usr/local/nagios –with-ping-command=”/bin/ping” –enable-perl-modules –with-mysql=/opt/mysql make

–with-apt-get-command: –with-ping6-command: /bin/ping6 -n -U -w %d -c %d %s –with-ping-command: /bin/ping –with-ipv6: yes –with-mysql: /opt/mysql/bin/mysql_config –with-openssl: yes –with-gnutls: no –enable-extra-opts: no –with-perl: /usr/bin/perl –enable-perl-modules: yes –with-cgiurl: /nagios/cgi-bin –with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin

如果没有mysql关联,libexec目录不会产生check_mysql,utils.pm等文件

make install #查看播件文件是否已安装在这个目录 ls /usr/local/nagios/libexec 4.配置nginx的web口 如果使用apache可以在安装nagios时使用make install-webconf,不需要下面的配置 我的web server是nginx ,编辑nginx.conf location ~ \.cgi$ { root /usr/local/nagios/sbin; allow 192.168.54.83; #充许访问的客户端ip deny all; auth_basic “Restricted”; auth_basic_user_file nagios; rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break; fastcgi_index index.cgi; fastcgi_pass unix:/dev/shm/perl_cgi-dispatch.sock; fastcgi_param HTTP_ACCEPT_ENCODING gzip,deflate; fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name; include fcgi.conf; } location /nagios/ { alias /usr/local/nagios/share/; allow 192.168.54.83; deny all; auth_basic “Restricted”; auth_basic_user_file nagios; } 5.使用apache的htpasswd生成用户和口令 /opt/apache/bin/htpasswd -c /opt/nginx/conf/nagios nagiosadmin 6.修改nagios配置文件 修改etc/cgi.cfg中的用户为nagiosadmin authorized_for_system_information=nagiosadmin authorized_for_configuration_information=nagiosadmin authorized_for_system_commands=nagiosadmin//多个用户之间用逗号隔开 authorized_for_all_services=nagiosadmin authorized_for_all_hosts=nagiosadmin authorized_for_all_service_commands=nagiosadmin authorized_for_all_host_commands=nagiosadmin 测试时可以将use_authentication=0 修改etc/objects/contacts.cfg联系人 define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** }   修改本机配置etc/objects/localhost.cfg 上传配置文件 检查配置文件 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 7.启动nagios #启动 /etc/rc.d/init.d/nagios start #手工启动 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg #重启 /etc/rc.d/init.d/nagios reload 8.reload nginx server /opt/nginx/sbin/nginx -t kill -HUP `cat /opt/nginx/logs/nginx.pid` nagios安装完成 访问http://localhost/nagios/就可以看到了 安装内存监控插件 wget “http://www.nagiosexchange.org/cgi-bin/jump.cgi?ID=1789&view=File1;d=1” mv jump.cgi\?ID\=1789\&view\=File1\;d\=1 check_mem.pl.gz gunzip check_mem.pl.gz mv check_mem.pl /usr/local/nagios/libexec/check_mem chown nagios:nagios check_mem chmod 0755 check_mem ./check_mem -w 95,60 -c 120,80 #测试结果 OK: Memory Usage (W> 95, C> 120): 83% Swap Usage (W> 60, C> 80): 3%|MemUsed=83%;95;120 SwapUsed=3%;60;80 commands.cfg增加 define command{ command_name check_mem command_line $USER1$/check_mem -w $ARG1$ -c $ARG2$ } 监控对像文件localhost.cfg添加 define service{ use local-service ; Name of service template to use host_name localhost service_description memory check_command check_mem!110,50!150,80 notifications_enabled 0 } 重新加载文件 /etc/init.d/nagios reload 访问http://localhost/nagios/ 输入口令后就可以看到界面了 nagios_screen1 疑难杂征 在service detail中看到ping的命令行是黄色的。 Current Status: UNKNOWN (for 3d 17h 46m 12s) Status Information: ping CRITICAL – Could not interpret output from ping command 多数情况为nagios用户没有执行ping的权限 可以先测试下ping命令有无返回 ping 127.0.0.1 nagios用户无执行权权时: root下 chmod u+s /path/ping 参考:http://blog.chinaunix.net/u/9861/showart_1001559.html 路径不正确时: nagios插件编译时使用参数 –with-ping-command=”/bin/ping” 参考:http://marc.info/?l=netsaintplug-help&m=101980226726163&w=2 禁ping时: cat /proc/sys/net/ipv4/icmp_echo_ignore_all #非0执行下面 echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all 还需检查下其它地方有无禁ping设置,如/etc/rc.local nagios里点”3-D Status Map”时提示”打开statuswrl.cgi”的问题 这个问题是玩nagios最常见的问题 nagios的官方网站的faq里都有得说,看这里 意思差不多就是说:“如果要看3-D statusmap CGI (statuswrl.cgi)的输出的话,得为你的web浏览器安装vrml的client(客户端)或plugin(插件)” 然后还推荐了四个 Cortona (Parallel Graphics) Cosmo Player (Computer Associates and NIST) FreeWRLOpenVRML 好像最后两个没有windows版本 所以如果是用windows机器看的话 需要装前两个软件之一,我安装的是Cortona3D Viewer ,支持ie7和firefox 访问本网址可以查看适合的plugin http://cic.nist.gov/vrml/vbdetect.html Firefox添加Nagios插件 https://addons.mozilla.org/en-US/firefox/addon/3607 解决Nagios安装好后statusmap.cgi找不到的问题
  • libgd
  • libgd-devel
  • libpng
  • libpng-devel
  • libjpeg
  • libjpeg-devel
  • zlib
  • zlib-devel
run ‘make devclean‘ in your Nagios source code distribution directory and rerun the configure script 我的gd安装在/usr/local/gd2/ ./configure –prefix=/usr/local/nagios –with-gd-lib=/usr/local/gd2/lib –with-gd-inc=/usr/local/gd2/include iconv找不时的出错 statusmap.cgi: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory ldd /usr/local/nagios/sbin/statusmap.cgi libgd.so.2 => /usr/lib64/libgd.so.2 (0x0000003f16e00000) libiconv.so.2 => not found 找一下libiconv.so.2是不是在/usr/local/lib/中,并且该目录不在/etc/ld.so.conf中 将目录放入动态库中 echo “/usr/local/lib” >> /etc/ld.so.conf ldconfig -v 再刷新下页面,问题解决. 安装NRPE tar zxvf nrpe2.12.tar.gz cd nrpe2.12 ./configure ./make all ./make install-plugin #监控机只需安装到这步

Posted in Nagios, 技术.

Tagged with .


rrdtool 1.3.7 安装

rrdtool 介绍 (http://www.rrdtool.org) RRDtool是指Round Robin Database 工具(环状数据库)。Round robin是一种处理定量数据、以及当前元素指针的技术。想象一个周边标有点的圆环--这些点就是时间存储的位置。从圆心画一条到圆周的某个点的箭头--这就是指针。就像我们在一个圆环上一样,没有起点和终点,你可以一直往下走下去。过来一段时间,所有可用的位置都会被用过,该循环过程会自动重用原来的位置。这样,数据集不会增大,并且不需要维护。 RRDtool源自MRTG(多路由器流量绘图器)。MRTG是有一个大学连接到互联网链路的使用率的小脚本开始的。MRTG后来被当作绘制其他数据源的工具使用,包括温度、速度、电压、输出量等等。

参考地址 RRDtool中英文翻译使用手册 http://leftleg.hzpub.com/post/634/

rrdtool 教學 http://www.study-area.org/tips/rrdtool/rrdtool.html

安装注意 在安装rrdtool时需要cairo包的支持,而cairo又需要pkg-config、glib、pixman、pang、freetype、fontconfig包的支持 支持包下载地址 http://oss.oetiker.ch/rrdtool/pub/libs/

前面安装失败记录 https://blog.c1gstudio.com/archives/446

下载完rrdtool解压后可以查看它的安装文档 http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.7.tar.gz tar zxvf rrdtool-1.3.7.tar.gz cat rrdtool-1.3.7/doc/rrdbuild.txt

开始安装 设置环境变量 安装临时目录为/tmp/rrdbuild,安装目录为/usr/local/rrdtool

export BUILD_DIR=/tmp/rrdbuild export INSTALL_DIR=/usr/local/rrdtool mkdir -p $BUILD_DIR cd $BUILD_DIR export CFLAGS=”-O3 -fPIC” #export LDFLAGS=”-Wl,–rpath -Wl,${INSTALL_DIR}/lib” export PKG_CONFIG_PATH=${INSTALL_DIR}/lib/pkgconfig export PATH=$INSTALL_DIR/bin:$PATH export PKG_CONFIG=$INSTALL_DIR/bin/pkg-config cd $BUILD_DIR wget -c http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.7.tar.gz tar zxvf rrdtool-1.3.7.tar.gz wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz tar zxvf pkg-config-0.23.tar.gz cd pkg-config-0.23 ./configure –prefix=$INSTALL_DIR make make install cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/zlib-1.2.3.tar.gz tar zxvf zlib-1.2.3.tar.gz cd zlib-1.2.3 ./configure –prefix=$INSTALL_DIR –shared make make install cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/libpng-1.2.18.tar.gz tar zxvf libpng-1.2.18.tar.gz cd libpng-1.2.18 ./configure –prefix=$INSTALL_DIR make make install cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/freetype-2.3.5.tar.gz tar zxvf freetype-2.3.5.tar.gz cd freetype-2.3.5 ./configure –prefix=$INSTALL_DIR CFLAGS=”-O3 -fPIC” make make install cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/libxml2-2.6.32.tar.gz tar zxvf libxml2-2.6.32.tar.gz cd libxml2-2.6.32 ./configure –prefix=$INSTALL_DIR make make install cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/fontconfig-2.4.2.tar.gz tar zxvf fontconfig-2.4.2.tar.gz cd fontconfig-2.4.2 ./configure –prefix=$INSTALL_DIR –with-freetype-config=$INSTALL_DIR/bin/freetype-config make make install cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/pixman-0.10.0.tar.gz tar zxvf pixman-0.10.0.tar.gz cd pixman-0.10.0 ./configure –prefix=$INSTALL_DIR make make install cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/cairo-1.6.4.tar.gz tar zxvf cairo-1.6.4.tar.gz cd cairo-1.6.4 ./configure –prefix=$INSTALL_DIR \ –enable-xlib=no \ –enable-xlib-render=no \ –enable-win32=no \ FONTCONFIG_CFLAGS=-I/usr/local/rrdtool/include FONTCONFIG_LIBS=”-L/usr/local/rrdtool/lib -lfontconfig ” \ FREETYPE_CFLAGS=-I/usr/local/rrdtool/include/freetype2 FREETYPE_LIBS=”-L/usr/local/rrdtool/lib -lfreetype” pixman_CFLAGS=-I/usr/local/rrdtool/include/pixman-1 pixman_LIBS=”-L/usr/local/rrdtool/lib -lpixman-1″ \ make make install cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/glib-2.15.4.tar.gz tar zxvf glib-2.15.4.tar.gz cd glib-2.15.4 ./configure –prefix=$INSTALL_DIR make make install

#gconvert.c:51:2: #error GNU libiconv not in use but included iconv.h is from libiconv 需带上–with-libiconv

cd $BUILD_DIR wget http://oss.oetiker.ch/rrdtool/pub/libs/pango-1.21.1.tar.bz2 bunzip2 pango-1.21.1.tar.bz2 tar xf pango-1.21.1.tar cd pango-1.21.1 ./configure –prefix=$INSTALL_DIR –without-x make make install cd $BUILD_DIR/rrdtool-1.3.7 ./configure –prefix=$INSTALL_DIR –disable-tcl –disable-python

#和nagios结合时增下下面参数 –with-rrdtool=/usr/local/rrdtool/bin/rrdtool –with-perfdata-dir=/usr/local/nagios/share/perfdata

Find 3rd-Party Libraries checking for cairo_font_options_create in -lcairo… no checking for pkg-config… pkg-config configure: WARNING: —————————————————————————- * I found a copy of pkgconfig, but there is no cairo-png.pc file around. You may want to set the PKG_CONFIG_PATH variable to point to its location. —————————————————————————- configure: WARNING: —————————————————————————- * I could not find a working copy of cairo-png. Check config.log for hints on why this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately so that compiler and the linker can find libcairo and its header files. If you have not installed cairo-png, you can get it either from its original home on http://cairographics.org/releases/ You can find also find an archive copy on http://oss.oetiker.ch/rrdtool/pub/libs The last tested version of cairo-png is 1.4.6. LIBS=-lm LDFLAGS= CPPFLAGS= —————————————————————————- checking for cairo_svg_surface_create in -lcairo… no checking for pkg-config… (cached) pkg-config

有以上信息请检查cairo安装和环境变量

checking in… and out again ordering CD from http://tobi.oetiker.ch/wish …. just kidding ;-) —————————————————————- Config is DONE! With MMAP IO: yes Build rrd_getopt: no Static programs: no Perl Modules: perl_piped perl_shared Perl Binary: /usr/bin/perl Perl Version: 5.8.5 Perl Options: PREFIX=$(DESTDIR)/usr/local/rrdtool LIB=$(DESTDIR)/usr/local/rrdtool/lib/perl/5.8.5 Ruby Modules: Ruby Binary: no Ruby Options: sitedir=$(DESTDIR)/usr/local/rrdtool/lib/ruby Build Tcl Bindings: no Build Python Bindings: no Build rrdcgi: yes Build librrd MT: yes Link with libintl: yes Libraries: -lxml2 -lcairo -lcairo -lcairo -lm -lcairo -lpng12 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 Type ‘make’ to compile the software and use ‘make install’ to install everything to: /usr/local/rrdtool. … that wishlist is NO JOKE. If you find RRDtool useful make me happy. Go to http://tobi.oetiker.ch/wish and place an order.

出现以上信息表明离成功不远了哈。

make make install

========================= 2010-7-22更新 RRDtool 1.4.4 安装 https://blog.c1gstudio.com/archives/1057

Posted in Nagios, RRDtool, 技术.

Tagged with .


rrdtool 安装失败篇

在安装rrdtool时需要cairo包的支持,而cairo又需要pkg-config、glib、pixman、pang、freetype、fontconfig包的支持

pkg-config http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz tar zxvf pkg-config-0.23.tar.gz cd pkg-config-0.23 ./configure make make install

其它的安装包 http://oss.oetiker.ch/rrdtool/pub/libs/

pango-1.21.1.tar.bz2 pixman-0.10.0.tar.gz libxml2-2.6.32.tar.gz glib-2.15.4.tar.gz cairo-1.6.4.tar.gz libpng-1.2.18.tar.gz freetype-2.3.5.tar.gz cairo-1.4.10.tar.gz fontconfig-2.4.2.tar.gz libart_lgpl-2.3.17.tar.gz zlib-1.2.3.tar.gz

其中系统中已安装的是(参见https://blog.c1gstudio.com/archives/152) zlib-1.2.3.tar.gz freetype-2.3.5.tar.gz libpng-1.2.31.tar.gz libxml2-2.6.32.tar.gz fontconfig-2.6.0.tar.gz tar zxvf glib-2.15.4.tar.gz cd glib-2.15.4 ./configure –with-libiconv make

Nothing to be done for `all’.

mv /install-prefix/include/glib.h /install-prefix/include/glib.h.del

mv /install-prefix/include/gmodule.h /install-prefix/include/gmodule.h.del make clean make uninstall ./configure –with-libiconv make

还是不行

make clean ./configure –with-libiconv –prefix=/usr make clean make make install

 pkg-config –cflags glib-2.0  pkg-config –libs glib-2.0 ldconfig wget -c http://oss.oetiker.ch/rrdtool/pub/libs/pixman-0.10.0.tar.gz tar zxvf pixman-0.10.0.tar.gz cd pixman-0.10.0 ./configure make make install wget -c http://oss.oetiker.ch/rrdtool/pub/libs/cairo-1.6.4.tar.gz tar zxvf cairo-1.6.4.tar.gz cd cairo-1.6.4 ./configure

configure: error: Cairo requires at least one native font backend. Please install FreeType and fontconfig and try again

make clean cp /usr/local/freetype/include/ft2build.h /usr/local/freetype/include/freetype2/ ./configure FREETYPE_LIBS=/usr/local/freetype/lib/libfreetype.so FREETYPE_CFLAGS=”-I/usr/local/freetype/include/freetype2″ FONTCONFIG_CFLAGS=”-I/usr/local/fontconfig/include” FONTCONFIG_LIBS=/usr/local/fontconfig/lib/libfontconfig.so

cairo (version 1.8.6 [release]) will be compiled with:

make make install

The following surface backends: Image: yes (always builtin) Xlib: no (requires X development libraries) Xlib Xrender: no (requires –enable-xlib) Quartz: no (requires CoreGraphics framework) Quartz-image: no (disabled, use –enable-quartz-image to enable) XCB: no (disabled, use –enable-xcb to enable) Win32: no (requires a Win32 platform) OS2: no (disabled, use –enable-os2 to enable) PostScript: yes PDF: yes SVG: yes glitz: no (disabled, use –enable-glitz to enable) BeOS: no (disabled, use –enable-beos to enable) DirectFB: no (disabled, use –enable-directfb to enable)

The following font backends: User: yes (always builtin) FreeType: yes Win32: no (requires a Win32 platform) Quartz: no (requires CoreGraphics framework)

The following functions: PNG functions: yes

And the following internal features: gcov support: no test surfaces: no (disabled, use –enable-test-surfaces to enable) ps testing: yes pdf testing: no (requires poppler-glib >= 0.9.2) svg testing: no (requires librsvg-2.0 >= 2.15.0)

It is strictly recommended that you enable the native surface backend feature for your platform.

make clean ./configure –prefix=/usr/local/cairo

echo ‘/usr/local/cairo/lib’ >> /etc/ld.so.conf ldconfig -v pkg-config –list-all

会报某些库找不到, 设置链接库路径

export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH export PKG_CONFIG_PATH=/usr/local/freetype/lib/pkgconfig:$PKG_CONFIG_PATH export PKG_CONFIG_PATH=/usr/local/fontconfig/lib/pkgconfig:$PKG_CONFIG_PATH

每次退出后以上变量需重新设置,可以保存成一个文件如:set_pkg_path.sh,然后source set_pkg_path.sh 如果想避免使用 GTK+ 库之前上述设置的麻烦,可以把上面环境变量的设置在系统的配置文件中(如 /etc/profile)或者自己的用户配置文件中(如 ~/.bash_profile) wget -c http://oss.oetiker.ch/rrdtool/pub/libs/pango-1.21.1.tar.bz2 tar jxvf pango-1.21.1.tar.bz2 cd pango-1.21.1 ./configure –enable-cairo –prefix=/usr make make install  wget http://oss.oetiker.ch/rrdtool/pub/libs/libart_lgpl-2.3.17.tar.gz  tar zxvf libart_lgpl-2.3.17.tar.gz  cd libart_lgpl-2.3.17 make make install wget -c http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.7.tar.gz cp /usr/local/cairo/lib/pkgconfig/* /usr/lib/pkgconfig/ export PKG_CONFIG_PATH=/usr/local/cairo/lib/pkgconfig:$PKG_CONFIG_PATH

CPPFLAGS=”-I/usr/local/lib/pkgconfig/ -I/usr/local/include/libart-2.0/ -I/usr/local/freetype/ -I/usr/local/lib/” ./configure –prefix=/usr/local/rrdtool –disable-tcl –disable-python make clean make make install

安装失败,找不到cairo-png,应该是动态链接库路径问题.

请看成功安装篇 https://blog.c1gstudio.com/archives/459

Posted in Nagios.

Tagged with , .


如何使用shell命令统计某个目录下的文件数(目录中有下级目录)

如何使用shell命令统计某个目录下的文件数(目录中有下级目录)?我想要输出的效果如下: 文件数 目录名 17 ./test/dir1 12 ./test/dir2 16 ./test/dir3/dir4/dir5 15 ./test/dir3/dir4/d …

find . -type f | sed ‘s/\(.*\)\/.*/\1\//’|sort | uniq -c find . -type f | awk ‘BEGIN{FS=OFS=”/”}{$NF=””;a[$0]++}END{for(i in a) print a[i]”\t”i}’

Posted in shell.

Tagged with .