Toon posts:

NetWare downtime statestieken.

Pagina: 1
Acties:

Verwijderd

Topicstarter
Hoi, ik ben een noob op het gebied van Novell NetWare maar zou graag willen weten of het op een eenvoudige manier mogelijk is om de log files zo te maken/lezen dat een beginner ze lezen kan? (ik ben voornamelijk genitreerd hoe lang hij down is geweest)

Ik heb al gezocht met de search maar kon niks vinden.

  • Koffie
  • Registratie: Augustus 2000
  • Laatst online: 08:31

Koffie

Koffiebierbrouwer

Braaimeneer

Define down :?
Als de server down is, kan 'ie ook nix loggen.
Over welke logfiles heb je het ?

Tijd voor een nieuwe sig..


  • The Gamblers
  • Registratie: Januari 2001
  • Laatst online: 22:52
Hoezo logt ie dan niet. Je kan in de file sys:vol$log.err precies zien wanneer de server gestart is..

Console Guy


  • Koffie
  • Registratie: Augustus 2000
  • Laatst online: 08:31

Koffie

Koffiebierbrouwer

Braaimeneer

Klopt, maar niet wanneer 'ie down was :P
Dit zul je das zelf moeten berkenenen aan de hand van de boot tijden.

Je zou dit kunnen proberen:

startlog.pl
code:
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/perl
# Perl script that writes a time stamp into a log file
# call from autoexec.ncf: perl startlog.pl --noscreen
# v0.10  30-Mar-2000  (c) G.Knauf, info@gknw.de

$file = '/etc/startlog.log';
$stamp = time();
$time = localtime($stamp);

open(LOG,">> $file") || die "cannot append to $file: $!";
print LOG "Restart: $time |$stamp\n";
close(LOG);

startstat.pl
code:
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
#!/usr/bin/perl
# Perl script that creates a table with server start times
# v0.30  30-Mar-2000  (c) G.Knauf, info@gknw.de

$file = '/etc/startlog.log';
$fbak = '/etc/startall.log';

if ($ENV{QUERY_STRING} eq "clearlog=") {
    &read_log;
    $lstamp = $log[$#log];
    $ltime = localtime($log[$#log]);
    open(LOG,"> $file") || die "cannot write $file: $!";
    print LOG "Restart: $ltime |$lstamp\n";
    close(LOG);
    if ($fbak ne '') {
        open(BAK,">> $fbak") || die "cannot write $fbak: $!";
        for $i (1..$#log) {
            $start = localtime($log[$i]);
            print BAK "Restart: $start |$log[$i]\n";
        }
        close (BAK);
    }
}

print <<EOM;
Content-type: text/html

<HTML>
<HEAD><TITLE>Server start and up times</TITLE></HEAD>
<BODY BGCOLOR="#ffffff">
<H2>Server start and up times: </H2>
<TABLE BORDER COLS=2 WIDTH="70%">
EOM

&read_log;
$stamp = time();
for $i (0..$#log) {
    $start = localtime($log[$i]);
    print "<tr><td><tt><center>$start</center></tt></td>";
    if ($i==$#log) {
        $upsec = $stamp - $log[$#log];
    } else {
        $upsec = $log[$i+1] - $log[$i];
    }
    &make_upstring;
    print "<td><tt><center>Uptime: $upstring</center></tt></td></tr>\n";
}
print <<EOM;
</TABLE>
<P><form method="GET" action="$0">
<input type=hidden name="clearlog" value="">
<input type="submit" value="clear log file">
</form></P>
</BODY></HTML>
EOM

exit;

sub read_log {
    undef @log;
    open(LOG,"< $file") || die "cannot read $file: $!";
    while (<LOG>) {
        chomp;
        @pair = split(/\|/);
        push (@log,$pair[1]);
    }
    close(LOG);
}

sub make_upstring {
    $updays=int($upsec/86400);
    $upsec-=$updays*86400;
    $uphours=int($upsec/3600);
    $upsec-=$uphours*3600;
    $upmin=int($upsec/60);
    $upsec-=$upmin*60;
    $upstring=sprintf("%5d %02d:%02d:%02d",$updays,$uphours,$upmin,$upsec);
}

Tijd voor een nieuwe sig..


Verwijderd

Topicstarter
Sorry, ik bedoelde dus NetWare. En dat ie nix kan loggen als ie down is snap ik ook nog. :) Ik zal het eens met dat script proberen. (al zal ik eerst moeten opzoeken hoe ik dat fix :))

  • Koffie
  • Registratie: Augustus 2000
  • Laatst online: 08:31

Koffie

Koffiebierbrouwer

Braaimeneer

Via Perl ;)

Maak de 2 genoemde bestanden aan, roep de eerste elke keer in je autoexec.ncf aan.
Voor de output van je log run je de 2e vanaf je webserver (ervan uitgaande dat je NW5 draait).

Tijd voor een nieuwe sig..


Verwijderd

Topicstarter
Op maandag 15 juli 2002 10:44 schreef Koffie het volgende:
Via Perl ;)

Maak de 2 genoemde bestanden aan, roep de eerste elke keer in je autoexec.ncf aan.
Voor de output van je log run je de 2e vanaf je webserver (ervan uitgaande dat je NW5 draait).
Dankje, maar leest ie dan niet elke keer als ik de client start? Ik zou graag de downtime van de server willen weten. (die ligt er nogal vaak uit maar onze systeemleverancier zegt van niet) Ow en is het dat sctipt ook mogelijk om terug te kijken? (+/- een maand of 3)

  • Koffie
  • Registratie: Augustus 2000
  • Laatst online: 08:31

Koffie

Koffiebierbrouwer

Braaimeneer

Met dit script schrijf je dus in een logfile elke keer weg wanneer de server boot.
Met het 2e script krijg je daar een nette HTML tabel van.
Als je dat combineert met een link naar je ABEND.LOG , ben je al een heel eind.
code:
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/perl
# Perl script that scans vol$log.err for last mount time, then scans
# abend.log to determine if abends occured after last start.
# Script uses Date::Parse for parsing the time strings from log files
# you could get it at CPAN: http://search.cpan.org/search?dist=TimeDate
# Script uses Mail::Sendmail for sending mail which is part of NetWare Perl #331
# or you could get it at CPAN: http://search.cpan.org/search?dist=Mail-Sendmail
# if you have older Perl, you should update to minimum #331:
# you could get it at CPAN: http://www.cpan.org/ports/index.html#netware
# install the script as cron job with: perl abendchk.pl -c[2,3,4,6,0]
# v0.10  08-Dez-2000  (c) info@gknw.de

use Getopt::Std;
use Date::Parse;
use Mail::Sendmail;

getopts('dhlmf:c:');

inst_cron() if ($opt_c);

$to = 'admin@your.domain';
$smtp = 'mail.your.domain';
#$from = "admin\@$host";

$vfile = '/vol$log.err';
$afile = '/system/abend.log';
$cfile = '/etc/abendchk.log';

$stamp = time();
$time = localtime($stamp);

if (-e $cfile) {
    $start = find_lasttime($cfile);
    print "Last abendchk: $start ->",scalar localtime($start),"\n\n" if ($opt_d);
} else {
    $start = read_vlog($vfile);
    $upsec = $stamp - $start;
    print "Server uptime: ",&make_upstring(),"\n\n" if ($opt_d);
}

if (-e $afile) {
    $astat = (stat($afile))[9];
    print "Test FileDate: $astat -> ",scalar localtime($astat),"\n" if ($opt_d);
    if ($start < $astat) {
        $new = 1;
    }
}

$abend = read_alog($afile);
if ($start < $abend) {
    print "\rThere were abends after last server start at ",scalar localtime($start),"\n";
    $new = 1;
}
print "Server: $host\n" if ($opt_d);

$opt_d=0;
if ($opt_d) {
    for (@abends) {print $_;};
}
update_log($cfile) if (!$opt_l);

#---------------------------------------------------
if (!$opt_m && $new) {
  $from = "admin\@$host" if (!$from);
  $realname = 'Service Auto Mailer';
  $from = "\"$realname\" <$from>";
  $reply = 'NO_REPLY!@NO_REPLY!';
  $subject = "ALERT: Abend report from $host";
  $message = "Service Mail:\n$subject at $time\n\n";
  for (@abends) {$message .= $_;};

  %mail = ( To  => $to,
      From    => $from,
      Subject => $subject,
      Message => $message,
      Smtp    => $smtp
    );
  if (sendmail %mail) {
    print "\r$0: Mail sent OK.\n";
  } else {
    print "\rError sending mail: $Mail::Sendmail::error \n";
  }
}
exit;

#---------------------------------------------------

sub read_vlog {
    my ($file)=@_;
    my $stamp,$temp;
    open(LOG,$file) || die "cannot read $file: $!";
    while (<LOG>) {
        chomp;

        next if (!/^Volume SYS mounted on \w+,\s(.+)./);
        $temp = $1;
        $temp =~ s/\./\:/g; # replace . with : for str2time()
        $stamp = Date::Parse::str2time($temp);

        # if (/Volume SYS mounted on \w+, (\w+ \d+, \d+\ +\d+:\d+:\d+ \w+)./) {
        # if (/Volume SYS mounted on \w+, (.+)./) {

        # print "\n$_\n" if ($opt_d);
        print "$temp -> $stamp -> ",scalar localtime($stamp),"\n" if ($opt_d);
    }
    close(LOG);
    print "\n" if ($opt_d);
    return $stamp;
}

sub read_alog {
    my ($file)=@_;
    my $stamp,$temp;
    open(LOG,$file) || die "cannot read $file: $!";
    while (<LOG>) {
        chomp;
        next if (!/^Server (\w+) halted \w+,\s(.+)/);
        # print "$2\n" if ($opt_d);
        $host = $1;
        $temp = $2;
        $temp =~ s/\./\:/g; # replace . with : for str2time()
        $stamp = Date::Parse::str2time($temp);
        next if ($start > $stamp);
        push (@abends,("*" x 60)."\n");
        push (@abends,"$_\n");
        $line = <LOG>;
        push (@abends,$line);
        while (<LOG>) {
            next if (!/^Running process:/);
            push (@abends,$_);
            last;
        }
        print "$temp -> $stamp -> ",scalar localtime($stamp),"\n" if ($opt_d);
    }
    close(LOG);
    print "\n" if ($opt_d);
    return $stamp;
}

sub make_upstring {
    $updays=int($upsec/86400);
    $upsec-=$updays*86400;
    $uphours=int($upsec/3600);
    $upsec-=$uphours*3600;
    $upmin=int($upsec/60);
    $upsec-=$upmin*60;
    $upstring=sprintf("%5d %02d:%02d:%02d",$updays,$uphours,$upmin,$upsec);
}

sub find_lasttime {
    my ($file)=@_;
    my $stamp;
    open(LOG,$file) || die "cannot open $file: $!";
    while (<LOG>) {
        if (/^\.+|(\d+)$/) {
            $stamp = $1;
        }
    }
    close(LOG);
    return $stamp;
}

sub update_log {
    my ($file)=@_;
    open(LOG,">> $file") || die "cannot append to $file: $!";
    print LOG "AbendChk: $time |$stamp\n";
    close(LOG);
}

sub inst_cron {
    if ($opt_c eq '2') {
        # The following command executes the script at 04:00 and 16:00 every day.
        $croncmd = "0 4,16 * * * perl $0 --noscreen";
    } elsif ($opt_c eq '3') {
        # The following command executes the script at 04.00, 12:00, 20:00 every day.
        $croncmd = "0 4,12,20 * * * perl $0 --noscreen";
    } elsif ($opt_c eq '4') {
        # The following command executes the script at 04.00, 10:00, 16:00, 22:00 every day.
        $croncmd = "0 4,10,16,22 * * * perl $0 --noscreen";
    } elsif ($opt_c eq '6') {
        # The following command executes the script at 04:00, 08:00, 12:00, 16:00, 20:00, 00.00 every day.
        $croncmd = "0 4,8,12,16,20,0 * * * perl $0 --noscreen";
    } elsif ($opt_c eq '0') {
        # The following command executes the script every 6 minutes (only for testing!)
        $croncmd = '0,6,12,18,24,30,36,42,48,54 * * * * perl $0 --noscreen';
    } else {
        # The following command executes the script at 04:00 every day.
        $croncmd = "0 4 * * * perl $0 --noscreen";
    }
    $file = '/etc/crontab';
    open(OUT, ">> $file") or die "Couldn't open $file: $!";
    print OUT "$croncmd\n";
    close(OUT) or die "Couldn't close $file: $!";
    print "Cron command successfully added to $file.\n";
    exit;
}

Dit zijn dus gewoon wat samples.
Maar als je gewoon de code doorleest, snao je de bedoeling en kun je de scripts naar eigen smaak aanpassen.

Tijd voor een nieuwe sig..


Verwijderd

Topicstarter
Mmmh, en ik dacht dat er een simpel tooltje voor was..:'( naja ik zal het maar eens met perl proberen.

  • Koffie
  • Registratie: Augustus 2000
  • Laatst online: 08:31

Koffie

Koffiebierbrouwer

Braaimeneer

Het laatste script gebruikt allemaal sendmail zooi, kun je er zo uitslopen.
Dan nog denk ik dat het allemaal bij elkaar veel minder regels code is dan een eventueel bestaand tooltje :)

Tijd voor een nieuwe sig..

Pagina: 1