zoukankan      html  css  js  c++  java
  • nagios note

    1 server:    nagios    nagios_plugin    nrpe  ip:192.168.1.2
    2 client    nagios_plugin    xinetd    nrpe     ip:192.168.1.3

    一篇介绍nagios很好的博文 http://www.cnblogs.com/mchina/archive/2013/02/20/2883404.html

    nagios插件(python + psutil)(client 被监控点)(收集system信息)

    1 yum install -y gcc python-devel
    2 yum install python-setuptools -y
    3 easy_install psutil
     1 #client side
     2 #vim /usr/local/nagios/libexec/get_sys_info.py
     3 
     4 #!/usr/bin/env python
     5 __author__ = 'metasequoia'
     6 
     7 import psutil
     8 import datetime
     9 import platform
    10 
    11 def info():
    12     system_info = platform.version()
    13     print "system_version:%s" % system_info
    14     cpu_count = psutil.cpu_count()
    15     print "logical_cpu_count:%score" % cpu_count
    16     mem = psutil.virtual_memory()
    17     print "memory_volume:%sM memory_used:%sM memory_free:%sM percent:%s%s" % ((mem[0]/1024/1024),(mem[3]/1024/1024),(mem[4]/1024/1024),mem[2],"%")
    18     swap = psutil.swap_memory()
    19     print "swap_volume:%sM swap_used:%sM swap_free:%sM percent:%s%s" % ((swap[0]/1024/1024),(swap[1]/1024/1024),(swap[2]/1024/1024),swap[3],"%")
    20     print datetime.datetime.fromtimestamp(psutil.boot_time()).strftime("%Y-%m-%d %H:%M:%S") + " UP"
    21     users = psutil.users()
    22     for user in users:
    23         print "%s	%s	%s (%s)" % (user[0],user[1],datetime.datetime.fromtimestamp(user[3]).strftime("%Y-%m-%d %H:%M"),user[2])
    24     #disk_partitions = psutil.disk_partitions()
    25     disk_usage = psutil.disk_usage('/')
    26     print "disk_volume:%sG disk_used:%sG disk_free:%sG percent:%s%s" % ((disk_usage[0]/1024/1024/1024),(disk_usage[1]/1024/1024/1024),(disk_usage[2]/1024/1024/1024),disk_usage[3],"%")
    27 
    28 if __name__ == "__main__":
    29     info()

    chmod + /usr/local/nagios/libexec/get_sys_info.py

    client define command

    1 vim /usr/local/nagios/etc/nrpe.cfg  
    2     command[check_sys_info]=/usr/local/nagios/libexec/get_sys_info.py

    server define command

    1 vim commands.cfg
    2 define command{
    3         command_name    check_nrpe
    4         command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1
    5 }

    server register service

    1 vim services.cfg
    2 
    3 define service{
    4         use                     local-service
    5         host_name               Nagios-Linux
    6         service_description     Check sys_info
    7         check_command           check_nrpe!check_sys_info
    8         }

    server test 

    1 /usr/local/nagios/libexec/check_nrpe -H 192.168.1.3 -c check_sys_info
  • 相关阅读:
    web通信浅析(上B/S交互)转载
    tomcat内部运行原理浅析转载
    oracle集合运算
    Oracle 游标使用全解
    oracle 一些基本概念
    1.搭建项目环境之TestDirector 8.0
    修改Win7远程桌面端口
    从第二份工作开始
    2.搭建项目环境之源代码管理SVN
    How to Get IIS Web Sites Information Programmatically
  • 原文地址:https://www.cnblogs.com/metasequoia/p/3824018.html
Copyright © 2011-2022 走看看