]> Pileus Git - ~andy/fetchmail/blob - contrib/fetchmailnochda.pl
Remove comment that confuses splint.
[~andy/fetchmail] / contrib / fetchmailnochda.pl
1 #!/usr/bin/perl
2
3 # User contribution to fetchmail by Torsten Mueller torsten@archesoft.de
4 # v1.1 22/may/2001
5
6 # the reason for this script is to check, if fetchmail (in daemon mode) works
7 # you should have perl and the perlmodule File::Compare installed
8 # File::Compare you can find at http://www.cpan.org/
9
10 # installation:
11 # edit the config part of this script
12 # create a cronjob , the time it should run should be higher than the pollintervall !!
13
14 # possible problems:
15 # you have set the cron intervall to short
16 # the script doesn't have permissions to write to directories or to execute fetchmail
17 # you didn't start fetchmail in daemon mode but use cron to fetch mail
18 # you can't read my english
19
20 # how does it work
21 # really simple, the script checks, if there was a change to the logfile of fetchmail
22 # to find this out, the script makes a backup of the original logfile and compares 
23 # the size of the original and the backup logfile
24 # i know it's a dirty way, but hey, it works ...
25  
26 use File::Compare;
27
28 # config
29 # where lives fetchmail on your system
30 $fetchmail = '/usr/bin/fetchmail';
31 # where should be the logfile for fetchmail
32 $fetchmaillog = '/var/log/fetchmail.log';
33 # where could the script write the backup of the logfile
34 $fetchmailwatch = '/var/log/fetchmailwatch';
35 # after how many seconds fetchmail should get mail, the poll intervall
36 $fetchmailtime = '3600';
37 # which config file should fetchmail use for retrieval
38 $fetchmailconf = '/root/.fetchmailrc';
39 # where lives your cp program 
40 $copycp = 'cp';
41 #end config
42
43 if (!(-e "$fetchmaillog")) {
44 # es existiert keine logdatei von fetchmail
45 # there isn't a logfile of fetchmail
46 print "There seems to be a problem with the fetchmail daemon\n
47 I couldn't find a logfile of fetchmail.\n
48 I try to stop and to start fetchmail in daemon mode.\n
49 If you get this mail more then once, then check your system !\n
50 ------------------------------------------------------------\n
51 Es ist ein Fehler aufgetreten bei der Ueberwachung des fetchmail Daemons\n
52 Es existiert keine Logdatei. Ich versuche jetzt fetchmail zu stoppen und neu zu \n
53 starten. Sollte das Problem nochmal auftreten, dann genaue Systeminspektion !\n
54 ------------------------------------------------------------\n
55 Das fetchmail Ueberwachungsscript Copyright 2001 by T. Mueller torsten\@archesoft.de\n\n";
56
57 system "$fetchmail -q";
58 sleep 3 ;
59 system "$fetchmail -f $fetchmailconf -d $fetchmailtime -L $fetchmaillog";
60 sleep 2 ;
61
62 }
63
64 if (!(-e "$fetchmailwatch")) {
65 # die kopie der logdatei existiert nicht
66 # the copy of the original logfile doesn't exists
67 print "There seems to be a problem with the fetchmail daemon\n
68 I couldn't find the copy of the original logfile of fetchmail.\n
69 If this is this the first run of this script, then this is no problem!\n
70 If you get this mail more then once, then check your system !\n
71 ------------------------------------------------------------\n
72 Es ist ein Fehler aufgetreten bei der Ueberwachung des fetchmail Daemons\n
73 Es existiert keine Kopie der Logdatei. Wenn das Script das erste Mal aufgerufen wurde,\n
74 dann ist dies kein Problem. Sollte dieses Problem nochmal auftreten, dann genaue Systeminspektion !\n
75 ------------------------------------------------------------\n
76 Das fetchmail Ueberwachungsscript Copyright 2001 by T. Mueller torsten\@archesoft.de\n\n";
77 &copylog;
78 exit; }
79
80
81 $vergleich = compare("$fetchmaillog","$fetchmailwatch");
82
83 if ($vergleich == -1) {
84 # irgendein fehler ist aufgetreten
85 # unknown error
86 print "There seems to be a problem with the fetchmail daemon or this script\n
87 I don't know, why this error happens.
88 Please check the script and your system
89 ------------------------------------------------------------\n
90 Es ist ein Fehler aufgetreten bei der Ueberwachung des fetchmail Daemons\n
91 Bitte die notwendigen Schritte unternehmen, z.B. Festplattenspeicherplatz pruefen\n
92 noch eine kommt.\n
93 ------------------------------------------------------------\n
94 Das fetchmail Ueberwachungsscript Copyright 2001 by T. Mueller torsten\@archesoft.de\n\n";
95 }
96
97
98 if ($vergleich == 0) {
99 # dateien sind gleich also also eine aktion starten
100 # the copy and the original logfile have the same size
101 print "There seems to be a problem with the fetchmail daemon\n
102 The logfile seems the be the same as the last logfile i have seen.
103 That could mean, that fetchmail hangs, or permissionproblems or disk full.
104 I try to stop and to start fetchmail in daemon mode.\n
105 If you get this mail more then once, then check your system !\n
106 ------------------------------------------------------------\n
107 Scheinbar gab es ein Problem mit dem Programm fetchmail\n
108 Die Logdatei war identisch mit der Logdatei beim  letzten Lauf diese Scriptes\n
109 Daraus schlussfolgere ich, dass nichts mehr geloggt wurde -> fetchmail hat ein Problem\n
110 Ich habe fetchmail versucht zu stoppen, und wieder neu zu starten.\n
111 Sollte diese Mail heute noch mehrfach erscheinen, dann ist eine genauere Inspektion\n
112 der Umstaende notwendig. Ist dies die erste Mail, dann einfach mal abwarten, ob\n
113 noch eine kommt.\n
114 ------------------------------------------------------------\n
115 Das fetchmail Ueberwachungsscript Copyright 2001 by T. Mueller torsten\@archesoft.de\n\n";
116
117 system "$fetchmail -q";
118 sleep 3 ;
119 system "$fetchmail -f $fetchmailconf -d $fetchmailtime -L $fetchmaillog";
120 sleep 2 ;
121
122 }
123
124
125 &copylog;
126
127 sub copylog {
128 system "$copycp $fetchmaillog $fetchmailwatch";
129 }
130
131