1 | 1 | simandl | #!/usr/bin/env perl |
2 | | | |
3 | | | # $Id: diagrams.pl,v 1.10 2004/05/23 23:53:39 bernisys Exp $ |
4 | | | |
5 | | | # include PERL libraries |
6 | | | use strict; |
7 | | | use warnings; |
8 | | | use diagnostics; |
9 | | | |
10 | | | # include HotSaNIC libraries |
11 | | | use lib "../../lib"; |
12 | | | use lib "./platform"; |
13 | | | use HotSaNICparser; |
14 | | | use HotSaNICdiagram; |
15 | | | use common; |
16 | | | |
17 | | | (my $VERSION = '$Revision: 1.10 $') =~ s/.*(\d+\.\d+).*/$1/; |
18 | | | (my $IDENTIFIER = '$Id: diagrams.pl,v 1.10 2004/05/23 23:53:39 bernisys Exp $') =~ s/.*,v (.*) \$/$1/; |
19 | | | |
20 | | | # read all settings |
21 | | | # |
22 | | | my $MODNAME=HotSaNICparser::get_module_name(); |
23 | | | my %CONFIG=HotSaNICparser::get_config("../.."); |
24 | | | my %MODULECONFIG=HotSaNICmod::common::configure(); |
25 | | | |
26 | | | my $IMGFMT=lc $CONFIG{"IMAGEFORMAT"}; |
27 | | | |
28 | | | my $OUTDIR=$CONFIG{"WEBDIR"}."/".lc $MODNAME; |
29 | | | if ( ! -e $OUTDIR ) { mkdir $OUTDIR,0755; } |
30 | | | |
31 | | | my ($FORCE,$DEBUGLEVEL,%PLOT)=HotSaNICdiagram::check_args(@ARGV); |
32 | | | my @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG); |
33 | | | |
34 | | | # handle module-specific stuff |
35 | | | # |
36 | | | my $LEGEND="connections"; |
37 | | | push @OPTIONS,( |
38 | | | "-v",$LEGEND, # Y-legend |
39 | | | "--alt-autoscale-max"); # alternate scaling |
40 | | | |
41 | | | # closing connection: ESTA -> FW1 -> CLSWT -> FW2 -> LACK -> TWT -> CLOSE |
42 | | | # establishing connection: CLOSE -> LSTN -> SYNS -> SYNR -> ESTA |
43 | | | # CLOSING: both sides shutdown, but data still to be sent (kind of an error state) |
44 | | | |
45 | | | # generate diagrams |
46 | | | # |
47 | | | foreach my $dev ("connections") { |
48 | | | my $name=$dev; |
49 | | | |
50 | | | my $DB_FILE="./rrd/$dev.rrd"; |
51 | | | |
52 | | | print "creating images for $dev netstats...\n"; |
53 | | | # if database exists, create images... |
54 | | | if ( -e $DB_FILE) { |
55 | | | |
56 | | | foreach my $range ("1h","6h","1day","1week","1month","1year") { |
57 | | | my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); |
58 | | | |
59 | | | my $FILENAME="$OUTDIR/$name-$file.$IMGFMT"; |
60 | | | |
61 | | | # 01=ESTABLISHED 02=SYN_SENT 03=SYN_RECV 04=FIN_WAIT1 05=FIN_WAIT2 |
62 | | | # 06=TIME_WAIT 07=CLOSE 08=CLOSE_WAIT 09=LAST_ACK 0A=LISTEN 0B=CLOSING |
63 | | | |
64 | | | my @EXTOPTIONS=("-s","-$range", "--title", "socket stats for $name - last $descr ($DATESTRING)"); |
65 | | | my @COMMANDS; |
66 | | | |
67 | | | my $legends="min avg max"; |
68 | | | if ($range eq "1h") { $legends="min avg max cur"; } |
69 | | | |
70 | | | if ($^O =~ /linux/) { |
71 | | | @COMMANDS=("DEF:aunkn=$DB_FILE:unknown:AVERAGE", |
72 | | | "DEF:aesta=$DB_FILE:established:AVERAGE", |
73 | | | "DEF:asyns=$DB_FILE:synsent:AVERAGE", |
74 | | | "DEF:asynr=$DB_FILE:synrecv:AVERAGE", |
75 | | | "DEF:afwt1=$DB_FILE:finwait1:AVERAGE", |
76 | | | "DEF:afwt2=$DB_FILE:finwait2:AVERAGE", |
77 | | | "DEF:atmwt=$DB_FILE:timewait:AVERAGE", |
78 | | | "DEF:aclse=$DB_FILE:close:AVERAGE", |
79 | | | "DEF:aclwt=$DB_FILE:closewait:AVERAGE", |
80 | | | "DEF:alack=$DB_FILE:lastack:AVERAGE", |
81 | | | "DEF:alstn=$DB_FILE:listen:AVERAGE", |
82 | | | "DEF:acsng=$DB_FILE:closing:AVERAGE", |
83 | | | "DEF:iunkn=$DB_FILE:unknown:MIN", |
84 | | | "DEF:iesta=$DB_FILE:established:MIN", |
85 | | | "DEF:isyns=$DB_FILE:synsent:MIN", |
86 | | | "DEF:isynr=$DB_FILE:synrecv:MIN", |
87 | | | "DEF:ifwt1=$DB_FILE:finwait1:MIN", |
88 | | | "DEF:ifwt2=$DB_FILE:finwait2:MIN", |
89 | | | "DEF:itmwt=$DB_FILE:timewait:MIN", |
90 | | | "DEF:iclse=$DB_FILE:close:MIN", |
91 | | | "DEF:iclwt=$DB_FILE:closewait:MIN", |
92 | | | "DEF:ilack=$DB_FILE:lastack:MIN", |
93 | | | "DEF:ilstn=$DB_FILE:listen:MIN", |
94 | | | "DEF:icsng=$DB_FILE:closing:MIN", |
95 | | | "DEF:xunkn=$DB_FILE:unknown:MAX", |
96 | | | "DEF:xesta=$DB_FILE:established:MAX", |
97 | | | "DEF:xsyns=$DB_FILE:synsent:MAX", |
98 | | | "DEF:xsynr=$DB_FILE:synrecv:MAX", |
99 | | | "DEF:xfwt1=$DB_FILE:finwait1:MAX", |
100 | | | "DEF:xfwt2=$DB_FILE:finwait2:MAX", |
101 | | | "DEF:xtmwt=$DB_FILE:timewait:MAX", |
102 | | | "DEF:xclse=$DB_FILE:close:MAX", |
103 | | | "DEF:xclwt=$DB_FILE:closewait:MAX", |
104 | | | "DEF:xlack=$DB_FILE:lastack:MAX", |
105 | | | "DEF:xlstn=$DB_FILE:listen:MAX", |
106 | | | "DEF:xcsng=$DB_FILE:closing:MAX", |
107 | | | HotSaNICdiagram::insert_data("AREA" ,"alstn ilstn alstn xlstn alstn",$MODULECONFIG{COLOR_LISTEN} ,"listen ",$legends,$LEGEND,1), |
108 | | | HotSaNICdiagram::insert_data("STACK","asyns isyns asyns xsyns asyns",$MODULECONFIG{COLOR_SYNSENT} ,"syn sent ",$legends,$LEGEND,1), |
109 | | | HotSaNICdiagram::insert_data("STACK","asynr isynr asynr xsynr asynr",$MODULECONFIG{COLOR_SYNRECV} ,"syn received",$legends,$LEGEND,1), |
110 | | | HotSaNICdiagram::insert_data("STACK","aesta iesta aesta xesta aesta",$MODULECONFIG{COLOR_ESTABLISHED},"established ",$legends,$LEGEND,1), |
111 | | | HotSaNICdiagram::insert_data("STACK","afwt1 ifwt1 afwt1 xfwt1 afwt1",$MODULECONFIG{COLOR_FINWAIT1} ,"fin wait 1 ",$legends,$LEGEND,1), |
112 | | | HotSaNICdiagram::insert_data("STACK","aclwt iclwt aclwt xclwt aclwt",$MODULECONFIG{COLOR_CLOSEWAIT} ,"close wait ",$legends,$LEGEND,1), |
113 | | | HotSaNICdiagram::insert_data("STACK","afwt2 ifwt2 afwt2 xfwt2 afwt2",$MODULECONFIG{COLOR_FINWAIT2} ,"fin wait 2 ",$legends,$LEGEND,1), |
114 | | | HotSaNICdiagram::insert_data("STACK","alack ilack alack xlack alack",$MODULECONFIG{COLOR_LASTACK} ,"last ack ",$legends,$LEGEND,1), |
115 | | | HotSaNICdiagram::insert_data("STACK","atmwt itmwt atmwt xtmwt atmwt",$MODULECONFIG{COLOR_TIMEWAIT} ,"time wait ",$legends,$LEGEND,1), |
116 | | | HotSaNICdiagram::insert_data("STACK","acsng icsng acsng xcsng acsng",$MODULECONFIG{COLOR_CLOSING} ,"closing ",$legends,$LEGEND,1), |
117 | | | HotSaNICdiagram::insert_data("STACK","aclse iclse aclse xclse aclse",$MODULECONFIG{COLOR_CLOSE} ,"close ",$legends,$LEGEND,1), |
118 | | | HotSaNICdiagram::insert_data("STACK","aunkn iunkn aunkn xunkn aunkn",$MODULECONFIG{COLOR_UNKNOWN} ,"unknown ",$legends,$LEGEND,1), |
119 | | | HotSaNICdiagram::insert_lines(%MODULECONFIG)); |
120 | | | } |
121 | | | my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$name-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME); |
122 | | | HotSaNICdiagram::graph(%CONF); |
123 | | | } |
124 | | | print "\n"; |
125 | | | } |
126 | | | else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n\n"; } |
127 | | | } |
128 | | | exit 0; |
129 | | | |
130 | | | |