RSS
 

Cacti自定义绘制图形

08 Apr

Cacti可以跟据自己的需要来定制图形,比如说你想监控远程一台web(squid)机器的打开页面的速度如何,或者自定义/usr/local/squid/bin/squidclient -p 80 mgr:info的信息时,可以很自由地大展身手。

/usr/local/squid/bin/squidclient -p 80 mgr:info

我们可以获取大概这么多的信息:

Squid Object Cache: Version 2.7.STABLE5
Start Time:     Tue, 06 Apr 2010 13:05:16 GMT
Current Time:   Wed, 07 Apr 2010 07:54:25 GMT
Connection information for squid:
        Number of clients accessing cache:      28013
        Number of HTTP requests received:       12921285
        Number of ICP messages received:        0
        Number of ICP messages sent:    0
        Number of queued ICP replies:   0
        Request failure ratio:   0.00
        Average HTTP requests per minute since start:   11443.3
        Average ICP messages per minute since start:    0.0
        Select loop called: 63269905 times, 1.071 ms avg
Cache information for squid:
        Request Hit Ratios:     5min: 92.9%, 60min: 92.3%
        Byte Hit Ratios:        5min: 68.0%, 60min: 69.3%
        Request Memory Hit Ratios:      5min: 64.9%, 60min: 63.2%
        Request Disk Hit Ratios:        5min: 0.1%, 60min: 0.2%
        Storage Swap size:      4264052 KB
        Storage Mem size:       803608 KB
        Mean Object Size:       44.59 KB
        Requests given to unlinkd:      0
Median Service Times (seconds)  5 min    60 min:
        HTTP Requests (All):   0.00091  0.00091
        Cache Misses:          0.08265  0.02742
        Cache Hits:            0.00000  0.00000
        Near Hits:             0.00562  0.00562
        Not-Modified Replies:  0.00000  0.00000
        DNS Lookups:           1.96483  1.96483
        ICP Queries:           0.00000  0.00000
Resource usage for squid:
        UP Time:        67749.459 seconds
        CPU Time:       4082.432 seconds
        CPU Usage:      6.03%
        CPU Usage, 5 minute avg:        9.89%
        CPU Usage, 60 minute avg:       9.83%
        Process Data Segment Size via sbrk(): 994496 KB
        Maximum Resident Size: 0 KB
        Page faults with physical i/o: 0
Memory usage for squid via mallinfo():
        Total space in arena:  994496 KB
        Ordinary blocks:       915646 KB  35590 blks
        Small blocks:               0 KB      0 blks
        Holding blocks:         16924 KB      3 blks
        Free Small blocks:          0 KB
        Free Ordinary blocks:   78849 KB
        Total in use:          932570 KB 92%
        Total free:             78849 KB 8%
        Total size:            1011420 KB
Memory accounted for:
        Total accounted:       892249 KB
        memPoolAlloc calls: 975833131
        memPoolFree calls: 974218783
File descriptor usage for squid:
        Maximum number of file descriptors:   60000
        Largest file desc currently in use:   6739
        Number of file desc currently in use: 5897
        Files queued for open:                   0
        Available number of file descriptors: 54103
        Reserved number of file descriptors:   100
        Store Disk files open:                   7
        IO loop method:                     epoll
Internal Data Structures:
        109848 StoreEntries
         60207 StoreEntries with MemObjects
         60153 Hot Object Cache Items
         95630 on-disk objects

 

比如你对Request Hit Ratios(请求命中率)感兴趣,你可以可以绘制出如下的图形。

SpxImage

1.要启用squid的snmp功能,所以需要在编译的时候,启用—enable-snmp

2.配置 squid.conf

添加:

acl ADMIN src 127.0.0.1/32
acl SNMP snmp_community   xxxxxx
snmp_access allow SNMP ADMIN
snmp_access deny  all

3.配置 /etc/snmpd.conf

添加:

proxy -v 1 -c xxxxx 127.0.0.1:3401 .1.3.6.1.4.1.3495.1

4.然后通对过人肉对比,可以得到:

Byte  Hit Ratio对应的snmpd 的OID是:.1.3.6.1.4.1.3495.1.3.2.2.1.10.5

 

5.创建数据模板(Data Templates):

因为这里snmp获取的数据,所以就选取通过snmp来获取值,下文将讲如何通过脚本来获取值。

如下图:

image

6.创建图形模板:(Graph Templates)

 

image

7.修改每个模板项目,如下图:

image

“Data Source ” 就选刚才创建的数据来源

8.然后就在需要创建图形的主机上添加刚才这个图形模板就可以了。

我把这个模板上传到这里,你可以直接导入到你的cacti里,然后仔细查看了。

如果说我要创建的图形是无法通过snmp获取的呢?

请听下回分解。

 
57 Comments

Posted in cacti, snmp, squid

 

Tags: , ,

  1. Commission Syphon X

    December 17, 2011 at 1:12 am

    Check this out…

    [...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……

     
  2. Nose Job Guide

    December 17, 2011 at 9:04 am

    Websites we think you should visit…

    [...]although websites we backlink to below are considerably not related to ours, we feel they are actually worth a go through, so have a look[...]……

     
  3. weight loss hypnosis

    December 17, 2011 at 11:48 pm

    Blogs ou should be reading…

    [...]Here is a Great Blog You Might Find Interesting that we Encourage You[...]……

     
  4. Arizona auto glass replacement

    December 18, 2011 at 3:36 am

    Superb website…

    [...]always a big fan of linking to bloggers that I love but don’t get a lot of link love from[...]……

     
  5. 21st Birthday Dress

    December 18, 2011 at 4:27 am

    Websites we think you should visit…

    [...]although websites we backlink to below are considerably not related to ours, we feel they are actually worth a go through, so have a look[...]……

     
  6. embroidered clothing

    December 18, 2011 at 5:11 am

    Check this out…

    [...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……

     
  7. watch new mission impossible movie online

    December 18, 2011 at 8:13 pm

    Websites worth visiting…

    [...]here are some links to sites that we link to because we think they are worth visiting[...]……

     

Leave a Reply

 

 
 
viagraatlantic drugs