varnish性能监控小结之check_varnish.pl、rsvp

一个优秀的工具,总会相应的会衍生很多与其相关的优秀插件或产品。就像varnish一样,其衍生的监控插件非常多。像munin-varnish、varnishgather、check_varnish.pl、rsvp等等。上面提到的前两个是官方提到的,尤其是munin也确实非常优秀。不过,前面两者对我现有的nagios监控平台并没有太多帮助。所以我这里想要重点提下check_varnish.pl和rsvp。

一、check_varnish.pl

提到check_varnish.pl就不得不提下varnish-nagios,该工具安装完成后,生成后的插件用为check_varnish。而这个perl版的monitor程序同其一样都是基于对varnishstat -1的输出结果进行处理并输出用户想用的结果,但从两者的对比上来看,个人感觉check_varnish.pl更胜一筹。原因如下:

1、安装难易程序上,varnish-nagios上更繁琐 。而check_varnish.pl 只需要依赖perl环境并在脚本内正确的指向varnishstat文件的位置就可以使用。

2、输出结果上,varnish-nagios的输出项过于古板,对于未使用-c -w设值的情况,会输出VARNISH UNKNOWN,如下:

[root@back ~]# /App/nagios/libexec/check_varnish -p client_conn
VARNISH UNKNOWN: Client connections accepted (26,816,539)|client_conn=2681653

而在这方面,check_varnish.pl处理的就非常好。如下:

[root@back ~]# ./check_varnish.pl --spec client_conn
OK - all counters in range;  | client_conn=26821214;;;;

两者在针对pnp4nagios出图上。check_varnish.pl完全是按照默认模板的方式进行的输出。而varnish-nagios的输出结果也能很好的找到相应的模板。

3、多参数输出

varnish-nagios不支持-p 加多个参数的输出。而check_varnish.pl在该方面确支持的很好。

[root@back ~]# ./check_varnish.pl --spec SMA.s0.g_bytes,104857600,1048576000  --spec SMA.s0.g_space
OK - all counters in range;  | SMA.s0.g_bytes=1024028;104857600;1048576000;; SMA.s0.g_space=6441426916;;;;

二、rsvp

1、综述

rsvp是Really Simple Varnish Panel的缩写。其向我们提供了另一种通过web界面管理和查看的功能。就像其命名方式一样,其真正做到了向我们提供一种简捷方便的varnish查看控制面板。其能提供的功能如下:

  • Display real-time varnishstat with HIT/(HIT+MISS) ratio
  • Display real-time varnishlog
  • Ban every URL from cache
  • Restart Varnish cache

我们先来看两张其界面图:

rsvp1

rsvp2

2、安装

先到https://github.com/benjaminbellamy/rsvp 页面下载最新的rsvp程序包。按以下步骤操作:

  • You need Apache to be able to connect to varnishadm, so copy /etc/varnish/secret to /etc/varnish/secret.www-data and chown it to www-data:www-data.
  • I strongly suggest that you protect your server with some authentification (.htpasswd with Basic AuthType should be enough).
  • Copy rsvp directory to /var/www-data should have write access to /var/rsvp/www/logs/ directory

接着在apache里增加如下配置(如果80端口被varnish使用,就让apache监听81端kkkk):

<VirtualHost *:81>
  ServerAdmin admin@localhost
  ServerName varnish.361way.com
    DocumentRoot /var/rsvp/www
    <Directory />  #如果不使用密码认证,请取消该段认证的内容
        Options FollowSymLinks
        AllowOverride None
        AuthType Basic
        AuthName "Really Simple Varnish Panel"
        AuthType Basic
        AuthUserFile /var/rsvp/.htpasswd
        Require valid-user
    </Directory>
    <Directory /var/rsvp/www>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
    ScriptAlias /cgi-bin/ /var/rsvp/cgi-bin/
    <Directory "/var/rsvp/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog /var/log/apache2/rsvp-error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog /var/log/apache2/rsvp-access.log combined
</VirtualHost>

注:如果是源码包安装的,需要在cgi-bin目录里将所有varnish程序的路径改成绝对路径。也可以在环境变量里增加varnish的路径或通过ln建立软链接。

参考页面如下:

https://github.com/andytinycat/check_varnish.pl

https://github.com/benjaminbellamy/rsvp

http://techwatch.keeward.com/geeks-and-nerds/really-simple-varnish-panel/

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注