Python Nagios Plugins

Source: Internet
Author: User

Nagios configuration file generation

HTPASSWD/ETC/NAGIOS/PASSWD Nagiosadmin

Identity Asset Unique Number

chmod 444/etc/assetid

Interface to write robust interface to determine whether the value is comprehensive

Batch build IP, hostname, other items are consistent

Pip install ' ipython<2.0 '

Curr_dir=os.path.abspath (Os.path.dirname (__file__)) The directory where the file name is currently located, the absolute path

Host_conf_dir=os.path.join (Curr_dir, ' hosts ')

Cache_file=/var/tmp/api-cache.json

Host_tmp% h string formatting

Nagios-plugins Nagios Plugin

The CMDB API generates a configuration file that the shell synchronizes to the Nagios configuration file directory


/etc/yum.conf has keepcache=1 inside.

/var/cache/yum/x86_64/6/base/packages, there's a RPM package cached locally.


VCs version control system (git svn CVS)


Configuration of the generated host from the CMDB API call sent into the Svn/git sent to puppet inside, thrown into Nagios


How to write the Nagios plugin plugins

1.exit status

0.ok

1.warning

2.critical

3.unknown


[-f/e xxx]&& exit 0 | | Exit 1


/var/log/message rsyslog (software name) write Syslog is protocol

Log format time host name Process name Program name


Log time stamp

Delta = Datetime.timedelta (minutes=3)

now = Datetime.datetime.now ()

Now-delta


Nagios message can only be in one row


\w Word +

\d Digital

() All

[] to part


Performance optimization

1. The algorithm changed

2. Multiple invocations changed to one call


Uppercase Global Variables

This article is from the "Muzinan Technology blog" blog, make sure to keep this source http://muzinan110.blog.51cto.com/684213/1439043

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.