-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitor_openhab.pl
executable file
·52 lines (39 loc) · 1.36 KB
/
monitor_openhab.pl
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
#!/usr/bin/perl
use strict;
my $commandline;
my @output;
my $file;
my $line;
my $directory;
# Devel
# $commandline = "cat /root/openhab-2015-08-02.log | egrep 'DefaultResourceDescription|ModelRepositoryImpl.*empty' | egrep 'ERROR|WARN'";
# Produktion
$commandline = "logtail /var/log/openhab/openhab*.log | egrep 'DefaultResourceDescription|ModelRepositoryImpl.*empty' | egrep 'ERROR|WARN'";
@output = `$commandline`;
# 2015-08-02 09:26:03.614 WARN o.o.m.c.i.ModelRepositoryImpl[:58]- Configuration model 'temp_humidity.rules' is either empty or cannot be parsed correctly!
# 2015-08-02 09:27:55.986 ERROR o.e.x.r.i.DefaultResourceDescription[:75]- test2.sitemap (No such file or directory)
# at org.eclipse.xtext.resource.impl.DefaultResourceDescription.computeExportedObjects(DefaultResourceDescription.java:73)
foreach (@output)
{
if (/ModelRepositoryImpl/)
{
$line = $_;
$line =~ m/.*model \'(.*)\' is either.*/;
$file = $1;
# print "$file\n";
}
if (/DefaultResourceDescription/)
{
$line = $_;
$line =~ m/.*DefaultResourceDescription\[:\d+\]- (.*) \(.*/;
$file = $1;
# print "$file\n";
}
$file =~ m/.*\.(.*)/;
$directory = $1;
# sitemap -> sitemaps
# persist -> persistence
$directory =~ s/sitemap/sitemaps/;
$directory =~ s/persist/persistence/;
system("touch /etc/openhab/configurations/$directory/$file\n");
}