~ocsinventory-dev/ocsinventory-server/trunk

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/perl -s

$f = $f || '/var/log/ocsinventory-server/activity.log';

unless($a){
	$a = 0;
	@lines = `cat $f`;
}
else{
	@lines = `$f.$a.gz`;
}

push @heures, sprintf("%02i",$_) for(0..23);
push @minutes, sprintf("%02i",$_) for(0..59);


@lines = grep { /^[^;]+;[^;]+;[^;]+;[^;]+;[^;]+$v;[^;]+;[^;]+$/i } @lines if defined($v); 

@prologs = grep { /;(?:102|100);/i } @lines; 
@accepts = grep { /;100;/i } @lines;
@incomings = grep { /;104;/i } @lines;
@arrived = grep { /;101;/i } @lines;
@errors = grep { /;515;/i } @lines;
@agents = grep { /deploy.+transmitted/i } @lines;
@new = grep { /;103;/i } @lines;
@dup = grep { /;300;/i } @lines;
@gr_nv = grep { /;306;/i } @lines;
@gr_rv = grep { /;307;/i } @lines;



print 	"\n\nSynthese - ",scalar(localtime())," - $a jours\n\n",
	"Prologs: ", scalar(@prologs),"\n",
	"Accepted: ", scalar(@accepts),"\n",
	"New: ",  scalar(@new),"\n",
	"Incomings: ", scalar(@incomings),"\n",
	"Auto duplicates: ", scalar(@dup),"\n",
	"Transmitted: ", scalar(@arrived),"\n",
	"Errors: ", scalar(@errors),"\n",
	"Groups out-of-date: ",scalar(@gr_nv),"\n",
	"Groups revalidated: ",scalar(@gr_nv),"\n",
	"Déploiement: ", scalar(@agents),"\n\n" if $s;

per_hour() if $r;
if(defined($h)){
	per_deca("$h") if $d;
	per_minutes("$h") if $m;
}

sub per_hour 
{ 
	print "\n\nRecapitulatif par heure - ",scalar(localtime())," - $a jours\n\n";
	print "\t\t\tPrologs\t\tAccepted\tIncomings\tNew\t\tDuplicates\tTransmitted\tErrors\tgr:ood\t:gr:reval\t\tDeployed\n";
	for $heure (@heures){
		print "$heure heures :\t";
		print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @prologs),"\t"; 
		print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @accepts),"\t";
		print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @incomings),"\t";
		print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @new),"\t";
		print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @dup),"\t";
		print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @arrived),"\t";
		print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @errors),"\t";
		print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @gr_nv),"\t";
		print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @gr_rv),"\t";
		print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @agents),"\n";
		
	}
}

sub per_minutes
{
	$heure = shift;
	$heure = sprintf("%02i",$heure);
	
	print scalar(localtime()),"\n\n";
	print "\n\nRecapitulatif minute par minute pour $heure heures - ",scalar(localtime())," - $ai jours\n\n";
	print "\t\t\t\tPrologs\t\tAccepted\tIncomings\tNew\t\tDuplicates\tTransmitted\tErrors\tgr:ood\t:gr:reval\t\tDeployed\n";
	for $minute (@minutes){
		print "$heure heure $minute minutes :\t";
		print "\t",scalar(grep { /$heure:$minute:\d\d/ } @prologs),"\t";
		print "\t",scalar(grep { /$heure:$minute:\d\d/ } @accepts),"\t";
		print "\t",scalar(grep { /$heure:$minute:\d\d/ } @incomings),"\t";
		print "\t",scalar(grep { /$heure:$minute:\d\d/ } @new),"\t";
		print "\t",scalar(grep { /$heure:$minute:\d\d/ } @dup),"\t";
		print "\t",scalar(grep { /$heure:$minute:\d\d/ } @arrived),"\t";
		print "\t",scalar(grep { /$heure:$minute:\d\d/ } @errors),"\t";
		print "\t",scalar(grep { /$heure:$minute:\d\d/ } @gr_nv),"\t";
		print "\t",scalar(grep { /$heure:$minute:\d\d/ } @gr_rv),"\t";
		print "\t",scalar(grep { /$heure:$minute:\d\d/ } @agents),"\n";
	}
}

sub per_deca
{
	$heure = shift;
	@deca = (0..5);
	
	print scalar(localtime()),"\n\n";
	print "\n\nRecapitulatif par dix minutes pour $heure heures - ",scalar(localtime())," - $a jours\n\n";
	print "\t\t\t\tPrologs\t\tAccepted\tIncomings\tNew\t\tDuplicates\tTransmitted\tErrors\tgr:ood\t:gr:reval\t\tDeployed\n";
	for $minute (@deca){
		print "$heure heure ($minute*10) :\t";
		print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @prologs),"\t";
		print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @accepts),"\t";
		print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @incomings),"\t";
		print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @new),"\t";
		print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @dup),"\t";
		print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @arrived),"\t";
		print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @errors),"\t";
		print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @gr_nv),"\t";
		print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @gr_rv),"\t";
		print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @agents),"\n";
	}
														 
}