saltstack源码安装nrpe
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了saltstack源码安装nrpe相关的知识,希望对你有一定的参考价值。
最近弄saltstack弄上瘾了,今天又弄了saltstack源码安装nrpe,安装nrpe之前需要安装nagios-plugins,首先是top.sls文件:
[[email protected] salt]# cat top.sls
base:
‘*‘:
- nagios
[[email protected] salt]# tree nagios #目录结构
nagios
├── conf.sls
├── files
│?? ├── conf.sh
│?? ├── nagios-plugins-1.5.tar.gz
│?? ├── nrpe-2.12.tar.gz
│?? └── nrpe.cfg
├── init.sls
├── install.sls
└── top.sls
[[email protected] nagios]# cat init.sls #sls文件引用
include:
- nagios.conf
- nagios.install
[[email protected] nagios]# cat install.sls #安装nagios-plugins
nagios_users: #创建用户
user.present:
- name: nagios
- uid: 5556
- gid_from_name: True
- createhome: False
- shell: /sbin/nologin
nagios_source:
file.managed:
- name: /usr/local/src/nagios-plugins-1.5.tar.gz
- source: salt://nagios/files/nagios-plugins-1.5.tar.gz
- user: root
- group: root
- mode: 644
- unless: test -f /usr/local/src/nagios-plugins-1.5.tar.gz
extract_nagios-plugins:
cmd.run:
- cwd: /usr/local/src
- name: tar xf nagios-plugins-1.5.tar.gz
- require:
- file: nagios_source
nagios_pkginstall:
pkg.installed:
- pkgs:
- gcc
- gcc-c++
- autoconf
- automake
- openssl
- openssl-devel
- zlib
- zlib-devel
- glibc
- glibc-common
nagios_commpile:
cmd.run:
- name: cd /usr/local/src/nagios-plugins-1.5 && ./configure --enable-redhat-pthread-workaround && make && make install
- require:
- cmd: extract_nagios-plugins
- pkg: nagios_pkginstall
[[email protected] nagios]# cat conf.sls #nrpe安装配置
include:
- nagios.install
nrpe_source:
file.managed:
- name: /usr/local/src/nrpe-2.12.tar.gz
- source: salt://nagios/files/nrpe-2.12.tar.gz
- user: root
- group: root
- mode: 755
- unless: test -f /usr/local/src/nrpe-2.12.tar.gz
cmd.run:
- name: cd /usr/local/src && tar xf nrpe-2.12.tar.gz && cd nrpe-2.12 && ./configure --enable-command-args && make all && make install-plugin && make install-daemon && make install-daemon-config
- require:
- file: nrpe_source
/usr/local/nagios/etc/nrpe.cfg:
file.managed:
- name: /usr/local/nagios/etc/nrpe.cfg
- source: salt://nagios/files/nrpe.cfg
- user: nagios
- group: nagios
- mode: 644
salt://nagios/files/conf.sh:
cmd.script:
- env:
- BATCH: ‘yes‘
- require:
- cmd: nrpe_source
- pkg: nagios_pkginstall
[[email protected] files]# cat conf.sh #执行nrpe启动脚本
#!/bin/bash
#
/bin/chown -R nagios.nagios /usr/local/nagios && /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
最后在Master端执行:
salt ‘minions‘ state.highstate即可
值得说明的是:这个是源码安装nrpe,nagios/libexec下可能没有我们自定义使用的脚本及其他二进制程序,如果把已经源码配置好的nrpe,打包成rpm包,可能会更方便管理;可惜不会制作rpm包啊!
本文出自 “LawLer” 博客,谢绝转载!
以上是关于saltstack源码安装nrpe的主要内容,如果未能解决你的问题,请参考以下文章