Thread Sys::Statistics::Linux (neu) (7 answers)
Opened by bloonix at 2006-12-08 10:26

bloonix
 2007-02-25 20:27
#38965 #38965
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
Hallo Renee,

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use strict;
use warnings;
use Data::TreeDumper;
use Sys::Statistics::Linux;

my $options = {
  SysInfo   => 2,
  CpuStats  => 2,
  ProcStats => 2,
  MemStats  => 2,
  PgSwStats => 2,
  NetStats  => 2,
  SockStats => 2,
  DiskStats => 2,
  DiskUsage => 2,
  LoadAVG   => 2,
  FileStats => 2,
  Processes => 2,
};

my $thresholds = {
  LoadAVG   => { avg_1 => 'gt:20' },
  NetStats  => { ttbyt => 'gt:4000000' },
  PgSwStats => { pswpout => 'gt:1' },
  Processes => { cmd => 'eq:(apache2)' },
  CpuStats  => {
     total => 'gt:80',
     iowait => 'gt:20'
  },
  MemStats  => {
     swapusedper => 'gt:80',
     realfreeper => 'lt:10',
  },
  DiskUsage => {
     '/dev/md1' => {
        usageper => 'gt:80'
      }
  },
};

my $lxs = new Sys::Statistics::Linux;
$lxs->set($options);
$lxs->init();
sleep(1);
my $stats = $lxs->get();
my $hits  = $lxs->search($thresholds);
print DumpTree($hits);


`- Processes  [H1]
  |- 8786  [H2]
  |  `- cmd = (apache2)  [S3]
  |- 9784  [H4]
  |  `- cmd = (apache2)  [S5]
  |- 9798  [H6]
  |  `- cmd = (apache2)  [S7]
  |- 9799  [H8]
  |  `- cmd = (apache2)  [S9]
  |- 9800  [H10]
  |  `- cmd = (apache2)  [S11]
  |- 9801  [H12]
  |  `- cmd = (apache2)  [S13]
  `- 9802  [H14]
     `- cmd = (apache2)  [S15]


sinn der Methode ist, nach bestimmten Werten zu suchen und nur
die Matches zurück zu geben. Auf diese Weise ist es einfach, einige
Statistiken zu überwachen und gegebenfalls Warnmeldungen für alle
Treffer in %hits zu generieren.

Gruss,
opi

Edit: betrifft Release 0.09_06\n\n

<!--EDIT|opi|1172428227-->
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.

View full thread Sys::Statistics::Linux (neu)