snmp/mrtgでプロセスの開いているファイルディスクリプタ数を監視

してみる
PLAIN TEXT
PERL:

#!/usr/bin/perl

 

use strict;

use warnings;

use Unix::Lsof;

use Unix::PID;

 

my $pid = Unix::PID->new();

my $red5_pid = $pid->get_pidof('search for a process by this string');

unless ( $red5_pid ) {

  print '0';

  exit;

}

 

my ( $output, $error ) = lsof( '-p', $red5_pid, '-w' );

my @vals = values %{$output};

print scalar @{ $vals[0]{files} };

snmpd.conf に
PLAIN TEXT
CODE:

exec fd_mon   /path/to/fd_mon.pl

mrtg.cfg に
PLAIN TEXT
CODE:

Target[fd]: .1.3.6.1.4.1.2021.8.1.101.1&.1.3.6.1.4.1.2021.8.1.101.1:public@localhost

MaxBytes[fd]: 2000

YLegend[fd]: File Descriptors

ShortLegend[fd]:

LegendI[fd]: [...]