You are not logged in.

#1 2015-01-09 00:13:54

RalphORama
Member
Registered: 2013-09-07
Posts: 8

Logging systemd journals since Logwatch can't

Hello!
In setting up my server, I've been trying to figure out how to email systemd logs to myself so I can keep an eye on sshd and other services. When I was using Ubuntu 14.04, I had logwatch do all this for me, but it appears that Logwatch has trouble with systemd on Arch. As per the wiki, I copied this python script, and replicated it in /root/systemdLog.py (for testing). However, when I try to run the python script using python systemdLog.py, I get the following error:

Traceback (most recent call last):
  File "systemd.py", line 3, in <module>
    from systemd import journal
  File "/root/systemd.py", line 3, in <module>
    from systemd import journal
ImportError: cannot import name 'journal'

I tried using the commands python2 and python3 as well, with the same result. How can I fix this error?

(Some other relavant info: the script's permissions are -rwxr--r-- 1 root root)

Offline

#2 2015-01-09 05:12:17

Stebalien
Member
Registered: 2010-04-27
Posts: 1,237
Website

Re: Logging systemd journals since Logwatch can't

Liar smile!  You didn't name your file /root/systemdLog.py, you named it /root/systemd.py and it's overriding the systemd module. Give it a different name.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

#3 2015-01-09 19:47:29

RalphORama
Member
Registered: 2013-09-07
Posts: 8

Re: Logging systemd journals since Logwatch can't

Oops, a critical mistake! I renamed the file, but now I'm getting the following error (for both python3 and python2):

Traceback (most recent call last):
  File "sendSystemdLogs.py", line 80, in <module>
    elif firewalldStart.match(entry['MESSAGE']):
NameError: name 'firewalldStart' is not defined

Offline

#4 2015-01-09 19:53:33

Stebalien
Member
Registered: 2010-04-27
Posts: 1,237
Website

Re: Logging systemd journals since Logwatch can't

RalphORama wrote:

Oops, a critical mistake! I renamed the file, but now I'm getting the following error (for both python3 and python2):

Traceback (most recent call last):
  File "sendSystemdLogs.py", line 80, in <module>
    elif firewalldStart.match(entry['MESSAGE']):
NameError: name 'firewalldStart' is not defined

That error message is pretty clear (hint: there's a bug in the script).


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

Board footer

Powered by FluxBB