有些时候,监控的服务输出Perfdata为空,nagiosgraph就没法绘图了。比如自己定义的监控服务。这个时候就需要对output数据进行处理,以便于生成rrd文件。
这就需要对map文件进行修改,其实map文件就是个perl脚本,定义一些正则表达式来对监控结果输出的处理。
输出包含两个不同的输出。第一部分是“Status Information”,对应于map文件的output。“|”后面的数据是“Performance Data”对应于map文件的perfdata。这个可以在在Nagios的Web界面的服务细节中找到。
例如下面的监控输出:
OK - Memory Usage: 2.53GB mapped, 5.06GB mappedWithJournal
OK - Memory Usage: 0.29GB resident, 5.38GB virtual, 2.53GB mapped, 5.06GB mappedWithJournal
将下面的正则表达式添加到map文件中:
1
2
3
4
5
6
7
8
9
10
11
12
|
# vim /usr/local/nagiosgraph/etc/map
(
/
output
:
.
*
Memory
Usage
:
(
[
-
.
0
-
9
]
+
)
GB
\
smapped
.
*
?
(
[
-
.
0
-
9
]
+
)
GB
\
smappedWithJournal
/
and
push
@
s
,
[
'memory'
,
[
'mapped'
,
GAUGE
,
$
1
]
,
[
'smappedWithJournal'
,
GAUGE
,
$
2
]
]
)
or
(
/
output
:
.
*
Memory
Usage
:
(
[
-
.
0
-
9
]
+
)
GB
\
sresident
,
\
s
(
[
-
.
0
-
9
]
+
)
GB
\
svirtual
,
\
s
(
[
-
.
0
-
9
]
+
)
GB
\
smapped
,
\
s
(
[
-
.
0
-
9
]
+
)
GB
\
smappedWithJournal
/
and
push
@
s
,
[
'memory'
,
[
'resident'
,
GAUGE
,
$
1
]
,
[
'virtual'
,
GAUGE
,
$
2
]
,
[
'mapped'
,
GAUGE
,
$
3
]
,
[
'mappedWithJournal'
,
GAUGE
,
$
4
]
]
)
;
|
检测map语法是否正确:
1
2
|
# perl -c map
map
syntax
OK
|
这样就nagiosgraph可以正常的绘图了。
这里就不贴出图来了,这个是nagios监控mongodb插件的输出,插件自带有生成perfdata的结果。
收 藏
转载请注明:成长的对话 » 自定义nagiosgraph map匹配规则一例