月度归档:2014年10月

mount: /dev/sdb1 already mounted or /mnt busy

We added a 500GB 7.2K SATA/300 Hitachi Deskstar E7K500 16MB disk to one of our dev servers and partitioned using fdisk and formatted the partition with etx3. When we tried mounting the same, we got the following error :

[root@]# mount -t ext3  /dev/sdb1 /mnt
mount: /dev/sdb1 already mounted or /mnt busy

lsof didn’t provide any open files that might be linked to this problem or there was any “famd” running. Finally doing the following steps to remove the logical devices from the device-mapper driver helped us fix the problem.

[root@]# dmsetup ls
ddf1_44656c6c202020201028001510281f033832b7a2f6678dab   (253, 0)
ddf1_44656c6c202020201028001510281f033832b7a2f6678dab1  (253, 1)

[root@]# dmsetup remove ddf1_44656c6c202020201028001510281f033832b7a2f6678dab1
[root@]# dmsetup ls
ddf1_44656c6c202020201028001510281f033832b7a2f6678dab   (253, 0)

[root@]# dmsetup remove ddf1_44656c6c202020201028001510281f033832b7a2f6678dab

[root@]# dmsetup ls
No devices found

Mounting using the command “mount -t ext3  /dev/sdb1 /mnt”  after the above steps worked fine.

添加一块移动硬盘,发现除了/dev/sdb之外,还出现/dev/dm-x之类的标识,mount时出现类似报错,使用dmsetup 工具remove/dev/dm-x后正常挂载。

Smokeping 发送告警邮件

smokeping 默认用sendmail发邮件,无法满足要求,改了一下源码,这样可以使用自定义方式发送邮件(如用QQ的smtp server来发告警邮件)。

首先需要安装 Authen::SASL 模块(auth 需要用的) 我用CPAN装的,不细说了

修改 smokeping/lib/Smokeping.pm

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#头上加
use Authen::SASL;
#定位到sendmail函数,改成下面这样
sub sendmail ($$$){
    my $from = shift;
    my $to = shift;
    $to = $1 if $to =~ /<(.*?)>/;
    my $body = shift;
    if ($cfg->{General}{mailhost} and
        my $smtp = Net::SMTP->new([split /\s*,\s*/, $cfg->{General}{mailhost}],Timeout=>5) ){
        $smtp->auth(split(/\s*,\s*/, $cfg->{General}{mailusr}),split(/\s*,\s*/, $cfg->{General}{mailpwd}));
        $smtp->mail($from);
        $smtp->to(split(/\s*,\s*/, $to));
        $smtp->data();
        $smtp->datasend($body);
        $smtp->dataend();
        $smtp->quit;
    } elsif ($cfg->{General}{sendmail} or -x "/usr/lib/sendmail"){
        open (M, "|-") || exec (($cfg->{General}{sendmail} || "/usr/lib/sendmail"),"-f",$from,$to);
        print M $body;
        close M;
    } else {
        warn "ERROR: not sending mail to $to, as all methodes failed\n";
    }
}
#找到  '_vars =>' ,把 mailusr mailpwd  加进去。不然不能启动哦!General configuration values valid for the whole SmokePing setup.
DOC
_vars =>
[ qw(owner imgcache imgurl datadir dyndir pagedir piddir sendmail offset
smokemail cgiurl mailhost mailusr mailpwd snpphost contact display_name
syslogfacility syslogpriority concurrentprobes changeprocessnames tmail
changecgiprogramname linkstyle precreateperms ) ],

然后修改配置文件
/etc/config

1
2
3
4
5
6
7
mailhost = smtp.qq.com
mailusr = noreply@qq.com
mailpwd = xxxxxxxxx

Smokeping的Master.Slave.线上配置

前言:

通常情况下,smokeping主机和被监控的主机之间都会存在网络延迟和丢包情况。因此现在比较热火的分布式,多节点监控架构似乎迫在眉睫,而smokeping完全支持master/slave多节点监控

优点:

smokeping的主从结构,默认是开启master和slave所有的检测指针去检测远程主机(当然这个选项也是有个参数可以控制,只让slave去检测远程主机)。一个master可以管理多个slave,而且slave配置起来也很简单
slave从master上获取自己的配置信息,所有的检测数据以及web呈现都在master上,slave只负责按照从master获取的配置信息进行数据检测,所以说master/slave的架构也只需要维护好master的配置文件即可,其他的信息slave都会动态获取到。
Smoking 检测分布式的检测方式是被动模式,由从节点启动时获得主节点的config 文件,然后进行数据检测收集,收集完毕后直接将数据提交给主节点。主从通信验证是通过类似于rsync的密码认证方式,在启动slave节点时指定–shared-secret=filename 来和主进行密码验证 继续阅读

New Clustering Utility – Remote Desktop Connection Manager

Hi Cluster Fans,

We wanted to let you know about a new tool which will significantly help you manage your cluster deployments.  Remote Desktop Connection Manager is actually not cluster-specific, but it allows you to logically group server remote desktop connections – ideal if you are working with clusters for easy access to all the nodes within the cluster. 继续阅读

Simple HTTP api for Executing PowerShell Scripts

[Based on the feedback, I’ve renamed this to HTTP]

There may be scenarios where you don’t need the full interactive experience of PowerShell remoting over PSRP  (PowerShell Remoting Protocol), or have the need to execute some PowerShell scripts from a non-Windows system.  You could directly code against WS-Man as I’ve blogged about a long time ago, however, it’s quite complicated requiring knowledge of SOAP and WS-Man.  In cases where you want to simply invoke a PowerShell script remotely, a REST api is a good choice since all modern programming languages make it simple to perform a HTTP GET operation. 继续阅读

Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)

H

ow do I increase the maximum number of open files under CentOS Linux? How do I open more file descriptors under Linux?

The ulimit command provides control over the resources available to the shell and/or to processes started by it, on systems that allow such control. The maximum number of open file descriptors displayed with following command (login as the root user). 继续阅读

Apache模块 mod_rewrite

Apache模块 mod_rewrite

说明 一个基于一定规则的实时重写URL请求的引擎
状态 扩展(E)
模块名 rewrite_module
源文件 mod_rewrite.c
兼容性 仅在 Apache 1.3 及以后的版本中可用

概述

此模块提供了一个基于正则表达式分析器的重写引擎来实时重写URL请求。它支持每个完整规则可以拥有不限数量的子规则以及附加条件规则的灵活而且强大的URL操作机制。此URL操作可以依赖于各种测试,比如服务器变量、环境变量、HTTP头、时间标记,甚至各种格式的用于匹配URL组成部分的查找数据库。 继续阅读

How to Install Nagios 4.0.7 (Monitoring Server) on CentOS, Redhat, Fedora

Nagios is the most popular, open source, powerful monitoring system. It enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes. Nagios has capability of monitoring application, services, entire IT infrastructure.

This is Part-1 of complete article How to Setup Nagios Monitoring Server with NagiosQL on CentOS/RHEL 6/5, In this part you will find the steps to setup Nagios Monitoring Server on CentOS, Redhat and Fedora systems. 继续阅读

Making changes to /proc filesystem permanently

Q. How do I make changes to /proc filesystem permanently? For example I want to se fs.file-max to 65536, I can use command echo “65536” > /proc/sys/fs/file-max. But, after rebooting my Linux server this value will be reset to the default. How do I make it permanent?

A. You are right. You are using sysctl. It is used to modify kernel parameters at runtime. The parameters available are those listed under /proc/sys/.

You need to use /etc/sysctl.conf file, which is a simple file containing sysctl values to be read in and set by sysctl. This is a configuration file for setting system variables.

So all you have to do is add variable = value in /etc/sysctl.conf file. So the changes remains the permanent. 继续阅读

iftop 线程流量查看工具

在类Unix系统中可以使用top查看系统资源、进程、内存占用等信息。查看网络状态可以使用netstat、nmap等工具。若要查看实时的网络流量,监控TCP/IP连接等,则可以使用iftop

一、iftop是什么?

iftop是类似于top的实时流量监控工具。

官方网站:http://www.ex-parrot.com/~pdw/iftop/ 继续阅读