Projet

Général

Profil

Révision 1dddd2fb

ID1dddd2fbc402baa697de907f77518ca5e357059d
Parent 9ec552e0
Enfant 12d632ca

Ajouté par Thomas VIAL il y a plus de 12 ans

- Fixed key that was based on $index and no unique name (when you changed a url, old stats were kept)
- Indentation changed to soft tabs

Voir les différences:

plugins/network/multiping
22 22
#
23 23
# Parameters:
24 24
#
25
# 	ping_args      - Arguments to ping (default "-c 2 -w 1")
26
# 	ping_args2     - Arguments after the host name (required for Solaris)
27
# 	ping           - Ping program to use
28
# 	hosts          - List of comma-separated hosts to ping (IP address or FQDN)
29
# 	names          - Friendly display name of each host given in the "hosts" parameter (comma-separated list).
30
# 	                 If not set, "hosts" elements will be used
25
#   ping_args      - Arguments to ping (default "-c 2 -w 1")
26
#   ping_args2     - Arguments after the host name (required for Solaris)
27
#   ping           - Ping program to use
28
#   hosts          - List of comma-separated hosts to ping (IP address or FQDN)
29
#   names          - Friendly display name of each host given in the "hosts" parameter (comma-separated list).
30
#                    If not set, "hosts" elements will be used
31 31
#
32 32
# Arguments for Solaris:
33 33
#      ping_args      -s
......
58 58
my $ping_args2 = exists $ENV{ping_args2} ? $ENV{ping_args2} : '';
59 59

  
60 60
if ($#hosts != $#names) {
61
	print "unequal amount of hosts and names\n";
62
	exit 1;
61
  print "unequal amount of hosts and names\n";
62
  exit 1;
63 63
}
64 64

  
65 65
if ((exists $ARGV[0]) && ($ARGV[0] eq "autoconf")) {
66
	my @ping = `$ping_cmd $ping_args $hosts[0] $ping_args2`;
67
	chomp @ping;
68
	my $ping = join(" ", @ping);
69
	if ($ping =~ m@min/avg/max@) {
70
		print "yes\n";
71
		exit 0;
72
	} else {
73
		print "no\n";
74
		exit 1;
75
	}
66
  my @ping = `$ping_cmd $ping_args $hosts[0] $ping_args2`;
67
  chomp @ping;
68
  my $ping = join(" ", @ping);
69
  if ($ping =~ m@min/avg/max@) {
70
    print "yes\n";
71
    exit 0;
72
  } else {
73
    print "no\n";
74
    exit 1;
75
  }
76 76
}
77 77

  
78 78
if ((exists $ARGV[0]) && ($ARGV[0] eq "config")) {
79
	print "graph_title Ping times\n";
80
	print "graph_args --base 1000 -o\n";
81
	print "graph_vlabel seconds\n";
82
	print "graph_category network\n";
83
	print "graph_info This graph shows ping RTT statistics.\n";
84
    for (my $site=1; $site<=$#hosts+1; $site++) {
85
		print "site$site.label $names[$site-1]\n";
86
		print "site$site.info Ping RTT statistics for $hosts[$site-1].\n";
87
		print "site$site.draw LINE2\n";
88
		print "site${site}_packetloss.label $names[$site-1] packet loss\n";
89
		print "site${site}_packetloss.graph no\n";
90
	}
79
  print "graph_title Ping times\n";
80
  print "graph_args --base 1000 -o\n";
81
  print "graph_vlabel seconds\n";
82
  print "graph_category network\n";
83
  print "graph_info This graph shows ping RTT statistics.\n";
84
  for (my $site=1; $site<=$#hosts+1; $site++) {
85
    my $item = lc($hosts[$site-1]); 
86
    $item =~ s/\.//g;
87
    print "$item.label $names[$site-1]\n";
88
    print "$item.info Ping RTT statistics for $hosts[$site-1].\n";
89
    print "$item.draw LINE2\n";
90
    print "${item}_packetloss.label $names[$site-1] packet loss\n";
91
    print "${item}_packetloss.graph no\n";
92
  }
91 93
    exit 0;
92 94
}
93 95

  
94 96
for (my $site=1; $site<=$#hosts+1; $site++) {
95
	my $host = $hosts[$site-1];
96
	my @ping = `$ping_cmd $ping_args $host $ping_args2`;
97
	chomp @ping;
98
	my $ping = join(" ", @ping);
99
	print "site".$site.".value ".($1 / 1000)."\n" if ($ping =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@);
100
	print "site".$site."_packetloss.value $1\n" if ($ping =~ /(\d+)% packet loss/);
97
  my $item = lc($hosts[$site-1]); 
98
  $item =~ s/\.//g;
99
  my $host = $hosts[$site-1];
100
  my @ping = `$ping_cmd $ping_args $host $ping_args2`;
101
  chomp @ping;
102
  my $ping = join(" ", @ping);
103
  print $item.".value ".($1 / 1000)."\n" if ($ping =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@);
104
  print $item."_packetloss.value $1\n" if ($ping =~ /(\d+)% packet loss/);
101 105
}
102 106

  

Formats disponibles : Unified diff