wskickahn 发表于 2017-4-20 06:45:17

CACTI增加自定义图形

  CACTI中增加新的数据获取方法、数据来源、图像模版以及添加图形到某个监控的主机图像集里面。

1. Data Input Methods

1.1 Data Input Methods
  Name: ptt server stat
  Input Type: Script/Command
  Input String: /usr/bin/perl <path_cacti>/scripts/get_ptt_server_status.pl <stub_status_url>

1.2 Input Fields
  stub_status_url: 填写Friendly Name

1.3 Output Fields
  current_session: 填写Field和Friendly Name

2. Data Templates

2.1 Data Templates
  Name: PTT Server Stat

2.2 Data Source
  Name: |host_description| - PTT Server Stat
  Data Input Method: ptt server stat
  Associated RRA's: 缺省
  Step: 缺省
  Data Source Active: 缺省(打勾)

2.3 Data Source Item
  Internal Data Source Name: current_session
  Minimum Value: 0
  Maximum Value: 0
  Data Source Type: GAUGE
  Heartbeat: 600
  Output Field: current_session - current_session

2.4 Custom Data
  Use Per-Data Source Value: addr
  打对勾 Use Per-Data Source Value

3. Graph Templates

3.1 Graph Template Items
  Graph Item  Data Source                 Graph Item Type     CF Type
  Item # 1    (current_session): Active   LINE1               AVERAGE
  Item # 2    (current_session): Current: GPRINT              LAST
  Item # 3    (current_session): Average: GPRINT              AVERAGE
  Item # 4    (current_session): Max:     GPRINT              MAX

3.2 Graph Item Inputs
  Name: Data Source

3.3 Template
  Name: PTT Server Stat

3.4 Graph Template
  Title: |host_description| - PTT Server Stat
  其它缺省

4 添加图形

4.1 Devices->host->Associated Graph Templates增加PTT Server Stat

4.2 Create Graphs for this Host

4.3 Graph Template Name里面打勾PTT Server Stat

5 监控脚本
  cat get_ptt_server_status.pl


#!/usr/bin/perl
use strict;
use Socket;
use IO::Socket;
if ( exists $ARGV) {
if ( $ARGV =~ /^(.+):(\d+)$/ ) {
my $host = $1;
my $port = $2;
my $n = 0;
my $sock = new IO::Socket::INET(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
Timeout => 5,
);
$sock->send("RPTR 0\n");
my $pdu = <$sock>;
if ($pdu =~ /(\d+)\n$/) {
$sock->read($pdu, $1);
if ($pdu =~ /^SESSIONS: (\d+)/) {
$n = $1;
}
}
close($sock);
print "current_session:$n ";
print "\n";
}
}

 
页: [1]
查看完整版本: CACTI增加自定义图形