六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 729|回复: 0

Nagios配置文件美化

[复制链接]
 楼主| 发表于 2015-8-24 15:14:44 | 显示全部楼层 |阅读模式
Nagios配置文件美化
监控的机器多了,那个hostgroups文件就成了这:
  1. #----------------------------引用文字-开始----------------------------
  2. define hostgroups{
  3. hostgroup_name       all_hosts
  4. alias       all_hosts
  5. 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,
  6. 88.88.88.13,88.88.88.14,88.88.88.15,88.88.88.16,88.88.88.17,88.88.88.18,
  7. 88.88.88.19,88.88.88.20,88.88.88.21,88.88.88.23,55.55.55.4,55.55.55.5,
  8. 55.55.55.6,55.55.55.7,99.99.99.28,99.99.99.4,99.99.99.2</code><code>
  9. #notes       note_string
  10. #notes_url       url
  11. #action_url       url
  12. }</code><code>

  13. define hostgroups{
  14. hostgroup_name       http_hosts
  15. alias       http_hosts
  16. 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,
  17. 55.55.55.7,55.55.55.5,99.99.99.4,99.99.99.2</code>
  18. #notes       note_string
  19. #notes_url       url
  20. #action_url       url
  21. }

  22. define hostgroups{
  23. hostgroup_name       mysql_hosts
  24. alias       mysql_hosts
  25. 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,
  26. 88.88.88.21,55.55.55.6,55.55.55.7,99.99.99.2,99.99.99.3</code>
  27. #notes       note_string
  28. #notes_url       url
  29. #action_url       url
  30. }
  31. #----------------------------引用文字-结束----------------------------
复制代码
一时半会还没发现怎么用include把member的内容写到其它地方。于是折中一下
写成这样:
  1. #----------------------------引用文字-开始----------------------------
  2. define hostgroups{
  3. hostgroup_name       all_hosts
  4. alias       all_hosts<code>
  5. members   66.66.66.28,\
  6. 66.66.66.29,\
  7. 66.66.66.30,\
  8. 77.77.77.4,\
  9. 88.88.88.11,\
  10. 88.88.88.12,\
  11. 88.88.88.13,\
  12. 88.88.88.14,\
  13. 88.88.88.15,\
  14. 88.88.88.16,\
  15. 88.88.88.17,\</code><code>
  16. 88.88.88.18,\
  17. 88.88.88.19,\
  18. 88.88.88.20,\
  19. 88.88.88.21,\
  20. 88.88.88.23,\
  21. 55.55.55.4,\
  22. 55.55.55.5,\
  23. 55.55.55.6,\
  24. 55.55.55.7,\
  25. 99.99.99.28,\
  26. 99.99.99.4,\
  27. 99.99.99.2</code><code>
  28. #notes       note_string
  29. #notes_url       url
  30. #action_url       url
  31. }

  32. define hostgroups{
  33. hostgroup_name       http_hosts
  34. alias       http_hosts</code><code>
  35. members    66.66.66.29,\
  36. 77.77.77.4,\
  37. 88.88.88.11,\
  38. 88.88.88.12,\
  39. 88.88.88.13,\
  40. 55.55.55.4,\
  41. 55.55.55.7,\
  42. 55.55.55.5,\
  43. 99.99.99.4,\
  44. 99.99.99.2</code><code>
  45. #notes       note_string
  46. #notes_url       url
  47. #action_url       url
  48. }

  49. define hostgroups{
  50. hostgroup_name       mysql_hosts
  51. alias       mysql_hosts</code><code>
  52. members   66.66.66.28,\
  53. 66.66.66.30,\
  54. 77.77.77.4,\
  55. 88.88.88.14,\
  56. 88.88.88.15,\
  57. 88.88.88.20,\
  58. 88.88.88.21,\
  59. 55.55.55.6,\
  60. 55.55.55.7,\
  61. 99.99.99.2,\
  62. 99.99.99.3</code><code>
  63. #notes       note_string
  64. #notes_url       url
  65. #action_url       url
  66. }
  67. #----------------------------引用文字-结束----------------------------
  68. </code>
复制代码
使用vi编辑器是很容易的,打冒号进入,然后查找替换就行了
1:1,$ s/,/,\\\r/g



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



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

该会员没有填写今日想说内容.
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表