1.1 Data Input Methods[edit: ptt server stat]
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[edit: PTT Server Stat]
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[current_session]
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[data input: ptt server stat]
Use Per-Data Source Value: addr
打对勾 Use Per-Data Source Value
3. Graph Templates
3.1 Graph Template Items[edit: PTT Server Stat]
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[current_session]
3.3 Template[edit: PTT Server Stat]
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[0]) {
if ( $ARGV[0] =~ /^(.+):(\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";
}
}