首页 > xen > nagiospnp 添加模版替换默认模版

nagiospnp 添加模版替换默认模版

2010年8月25日 eric 发表评论 阅读评论

PNP,我们安装好了,有很多监控服务,都是使用的默认模版,而且有三条数据的,都不在同一图上显示,会出三个图,所以默认模版不可取,而且也难看。那么我就来添加新的模版替换掉默认模版。
添加模版呢,记得要与commands.cfg里的 check_cpu 名字相同。

比如我的 commands.cfg 里的 check_memory 我添加一个模版。

nagios $> cd /usr/local/pnp4nagios/share/templates
nagios $> vim check_memory.php
< ?php
#
# Copyright (c) 2006-2010 Joerg Linge (http://www.pnp4nagios.org)
# Plugin: check_load
#
$opt[1] = "--vertical-label MEMORY -l0  --title \"NGINX_MEMORY for $hostname / $servicedesc\" ";
#
#
#
$def[1] = rrd::def("var1", $RRDFILE[1], $DS[1], "AVERAGE");   //第一条数据 变量1
$def[1] .= rrd::def("var2", $RRDFILE[1], $DS[2], "AVERAGE");  //第二条数据 变量2
$def[1] .= rrd::def("var3", $RRDFILE[1], $DS[3], "AVERAGE");  //第三条数据 变量3
$def[1] .= rrd::def("var4", $RRDFILE[1], $DS[4], "AVERAGE");  //第四条数据 变量4

if ($WARN[1] != "") {
    $def[1] .= "HRULE:$WARN[1]#FFFF00 ";
}
if ($CRIT[1] != "") {
    $def[1] .= "HRULE:$CRIT[1]#FF0000 ";
}
$def[1] .= rrd::area("var1", "#ff0000", "TOTAL") ;
$def[1] .= rrd::gprint("var1", array("LAST", "AVERAGE", "MAX"), "%6.2lf");
$def[1] .= rrd::area("var2", "#0000FF", "FREE") ;
$def[1] .= rrd::gprint("var2", array("LAST", "AVERAGE", "MAX"), "%6.2lf");
$def[1] .= rrd::area("var3", "#00FFFF", "USED") ;
$def[1] .= rrd::gprint("var3", array("LAST", "AVERAGE", "MAX"), "%6.2lf");
$def[1] .= rrd::area("var4", "#00FF00", "CACHES") ;
$def[1] .= rrd::gprint("var4", array("LAST", "AVERAGE", "MAX"), "%6.2lf");
?>
#保存

PS:注意一点,首先要用默认的模版出一下图,然后在做自己的模版,这样的话就有几条数据,这样可以在模版上声明几条变量!
效果图:

pnp新建模版

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/247.html

分类: xen 标签: , ,
  1. 2018年11月18日21:44 | #1

    Hi there to every , for the reason that I am truly eager of reading this website’s post to be updated on a
    regular basis. It consists of fastidious
    stuff.

  2. 2018年11月19日16:50 | #2

    all the time i used to read smaller articles that as well clear their motive, and that is also happening with this post which I am reading now.

  3. 2018年11月20日03:46 | #3

    hi!,I really like your writing very a lot! proportion we be in contact more approximately your post on AOL?
    I require an expert on this space to unravel my problem.
    Maybe that’s you! Taking a look ahead to peer you.

  4. 2018年11月21日23:57 | #4

    I know this if off topic but I’m looking into starting my own weblog and
    was wondering what all is needed to get setup? I’m assuming having a blog like
    yours would cost a pretty penny? I’m not very web smart so I’m not 100% certain. Any suggestions or advice would be greatly appreciated.
    Appreciate it

  5. 2018年11月22日23:44 | #5

    Hi there everyone, it’s my first pay a quick visit at this site, and article is
    genuinely fruitful for me, keep up posting these types of articles.

  6. 2018年11月28日00:05 | #6
  7. 2018年12月1日09:20 | #7
  8. 2018年12月2日00:08 | #8
  9. 2018年12月5日01:44 | #9

    Write more, thats all I have to say. Literally, it seems as though you
    relied on the video to make your point. You definitely know what youre talking about,
    why waste your intelligence on just posting videos to your weblog
    when you could be giving us something enlightening to read?

评论分页
1 ... 5 6 7 247
订阅评论
1+4= (必填)