安哥网络 发表于 2015-8-24 15:14:44

Nagios配置文件美化

Nagios配置文件美化
监控的机器多了,那个hostgroups文件就成了这:#----------------------------引用文字-开始----------------------------
define hostgroups{
hostgroup_name       all_hosts
alias       all_hosts
members<code>       66.66.66.28,66.66.66.29,66.66.66.30,77.77.77.4,88.88.88.11,88.88.88.12,
88.88.88.13,88.88.88.14,88.88.88.15,88.88.88.16,88.88.88.17,88.88.88.18,
88.88.88.19,88.88.88.20,88.88.88.21,88.88.88.23,55.55.55.4,55.55.55.5,
55.55.55.6,55.55.55.7,99.99.99.28,99.99.99.4,99.99.99.2</code><code>
#notes       note_string
#notes_url       url
#action_url       url
}</code><code>

define hostgroups{
hostgroup_name       http_hosts
alias       http_hosts
members</code><code>      66.66.66.29,77.77.77.4,88.88.88.11,88.88.88.12,88.88.88.13,55.55.55.4,
55.55.55.7,55.55.55.5,99.99.99.4,99.99.99.2</code>
#notes       note_string
#notes_url       url
#action_url       url
}

define hostgroups{
hostgroup_name       mysql_hosts
alias       mysql_hosts
members<code>   66.66.66.28,66.66.66.30,77.77.77.4,88.88.88.14,88.88.88.15,88.88.88.20,
88.88.88.21,55.55.55.6,55.55.55.7,99.99.99.2,99.99.99.3</code>
#notes       note_string
#notes_url       url
#action_url       url
}
#----------------------------引用文字-结束----------------------------
一时半会还没发现怎么用include把member的内容写到其它地方。于是折中一下
写成这样:#----------------------------引用文字-开始----------------------------
define hostgroups{
hostgroup_name       all_hosts
alias       all_hosts<code>
members   66.66.66.28,\
66.66.66.29,\
66.66.66.30,\
77.77.77.4,\
88.88.88.11,\
88.88.88.12,\
88.88.88.13,\
88.88.88.14,\
88.88.88.15,\
88.88.88.16,\
88.88.88.17,\</code><code>
88.88.88.18,\
88.88.88.19,\
88.88.88.20,\
88.88.88.21,\
88.88.88.23,\
55.55.55.4,\
55.55.55.5,\
55.55.55.6,\
55.55.55.7,\
99.99.99.28,\
99.99.99.4,\
99.99.99.2</code><code>
#notes       note_string
#notes_url       url
#action_url       url
}

define hostgroups{
hostgroup_name       http_hosts
alias       http_hosts</code><code>
members    66.66.66.29,\
77.77.77.4,\
88.88.88.11,\
88.88.88.12,\
88.88.88.13,\
55.55.55.4,\
55.55.55.7,\
55.55.55.5,\
99.99.99.4,\
99.99.99.2</code><code>
#notes       note_string
#notes_url       url
#action_url       url
}

define hostgroups{
hostgroup_name       mysql_hosts
alias       mysql_hosts</code><code>
members   66.66.66.28,\
66.66.66.30,\
77.77.77.4,\
88.88.88.14,\
88.88.88.15,\
88.88.88.20,\
88.88.88.21,\
55.55.55.6,\
55.55.55.7,\
99.99.99.2,\
99.99.99.3</code><code>
#notes       note_string
#notes_url       url
#action_url       url
}
#----------------------------引用文字-结束----------------------------
</code>使用vi编辑器是很容易的,打冒号进入,然后查找替换就行了

1:1,$ s/,/,\\\r/g



然后

1:行号,行号 s/^/\t\t\t/g



就行了
很简单的一个东西,写博客主要是因为忘了vi下的替换成换行是\r,所以记一下。
http://www.chengyongxu.com/blog/nagios%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%BE%8E%E5%8C%96/
Nagios配置文件美化

页: [1]
查看完整版本: Nagios配置文件美化