Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a LastLogAcitivity check #99

Merged
merged 2 commits into from Mar 10, 2021
Merged

Conversation

languitar
Copy link
Owner

Parses a log file and uses that first timestamp found when iterating the
file starting from the last line.

Will fix #98

@languitar languitar added this to the next milestone Feb 10, 2021
@languitar languitar self-assigned this Feb 10, 2021
@languitar languitar force-pushed the feature/98-last-log-time-check branch from f3f9121 to 3e509b9 Compare February 10, 2021 21:50
@codecov
Copy link

codecov bot commented Feb 10, 2021

Codecov Report

Merging #99 (c34602b) into master (d18df28) will increase coverage by 0.03%.
The diff coverage is 98.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #99      +/-   ##
==========================================
+ Coverage   97.31%   97.34%   +0.03%     
==========================================
  Files          11       11              
  Lines        1153     1205      +52     
  Branches      128      137       +9     
==========================================
+ Hits         1122     1173      +51     
- Misses         21       22       +1     
  Partials       10       10              
Impacted Files Coverage Δ
src/autosuspend/checks/activity.py 96.47% <98.07%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d18df28...c34602b. Read the comment docs.

@languitar languitar force-pushed the feature/98-last-log-time-check branch from 3e509b9 to b76de5a Compare February 10, 2021 21:54
@languitar languitar marked this pull request as draft February 10, 2021 21:54
@languitar languitar force-pushed the feature/98-last-log-time-check branch from b76de5a to 1ca2d53 Compare February 10, 2021 22:11
@languitar
Copy link
Owner Author

@niram8 would you mind giving this check a try? This should solve your log file problem without a shell script.

@languitar languitar marked this pull request as ready for review February 10, 2021 22:12
@languitar languitar force-pushed the feature/98-last-log-time-check branch from 1ca2d53 to fe46e3f Compare February 10, 2021 22:16
@niram8
Copy link

niram8 commented Feb 12, 2021

@niram8 would you mind giving this check a try? This should solve your log file problem without a shell script.

I would be happy to test. I do not know how to do it. How can I update my current autosuspend installation to test the new feature? And how should the autosuspend config file look like?

Parses a log file and uses that first timestamp found when iterating the
file starting from the last line.

Will fix #98
@languitar languitar force-pushed the feature/98-last-log-time-check branch from fe46e3f to c34602b Compare February 13, 2021 13:51
@languitar
Copy link
Owner Author

How can I update my current autosuspend installation to test the new feature? And how should the autosuspend config file look like?

You need to install autosuspend from the development source to test this. Ideally, you deinstall the existing package before testing (you should back up your existing config file before doing that). I have updated the from-source installation instructions in the manual to make the installation of the update version more easy for you: https://autosuspend.readthedocs.io/en/latest/installation.html#manual-installation. Use feature/98-last-log-time-check as the branch name behind the @ character in the Git URL.

@niram8
Copy link

niram8 commented Feb 21, 2021

I got the following error while I tried to install the brannch feature/98-last-log-time-check:

root@nextcloud ~]# python3 -m venv /opt/autosuspend /opt/autosuspend/bin/pip install git+https://github.com/languitar/autosuspend.git@feature/98‐last‐log‐time‐check#egg=autosuspend[all]
Error: Unable to create directory '/opt/autosuspend/bin/pip'
[root@nextcloud ~]#

There is already a file "pip" in directory "/opt/autosuspend/bin/" but no directory "pip"

The process is difficult for me as a non-linux user

@languitar
Copy link
Owner Author

You have to execute the two lines in the instruction in two separate invocations, not a single one.

@niram8
Copy link

niram8 commented Feb 21, 2021

Still errors. Here the output:

[root@nextcloud ~]# python3 -m venv /opt/autosuspend
[root@nextcloud ~]# /opt/autosuspend/bin/pip install git+https://github.com/languitar/autosuspend.git@feature/98‐last‐log‐time‐check#egg=autosuspend[all]
Collecting autosuspend[all] from git+https://github.com/languitar/autosuspend.git@feature/98‐last‐log‐time‐check#egg=autosuspend[all]
  Cloning https://github.com/languitar/autosuspend.git (to revision feature/98‐last‐log‐time‐check) to /tmp/pip-install-9ijj39iv/autosuspend
  Did not find branch or tag 'feature/98‐last‐log‐time‐check', assuming revision or ref.
error: pathspec 'feature/98‐last‐log‐time‐check' did not match any file(s) known to git
Command "git checkout -q feature/98‐last‐log‐time‐check" failed with error code 1 in /tmp/pip-install-9ijj39iv/autosuspend
[root@nextcloud ~]#

A lot of things happen if I use "master" instead of "eature/98‐last‐log‐time‐check"
/opt/autosuspend/bin/pip install git+https://github.com/languitar/autosuspend.git@master#egg=autosuspend[all]
But still a lot of erros. I can past the outpout if appropriate

@languitar
Copy link
Owner Author

That is very strange. I just copy and pasted your git URL and it doesn't work. When I build the URL on my own it works. Looks like there is some invisible control character inside. Please try this one:

git+https://github.com/languitar/autosuspend.git@feature/98-last-log-time-check#egg=autosuspend[all]

@niram8
Copy link

niram8 commented Feb 22, 2021

Still error:

[root@nextcloud ~]# python3 -m venv /opt/autosuspend
[root@nextcloud ~]# https://github.com/languitar/autosuspend.git@feature/98-last-log-time-check#egg=autosuspend%5Ball%5D
sh: 1: https://github.com/languitar/autosuspend.git@feature/98-last-log-time-check#egg=autosuspend%5Ball%5D: not found
[root@nextcloud ~]# git+https://github.com/languitar/autosuspend.git@feature/98-last-log-time-check#egg=autosuspend[all]
sh: 1: git+https://github.com/languitar/autosuspend.git@feature/98-last-log-time-check#egg=autosuspend[all]: not found
[root@nextcloud ~]#

@languitar
Copy link
Owner Author

That was only the URL, not the whole command to execute.

python3 -m venv /opt/autosuspend

/opt/autosuspend/bin/pip install git+https://github.com/languitar/autosuspend.git@feature/98-last-log-time-check#egg=autosuspend[all]

That's what you need to execute.

@niram8
Copy link

niram8 commented Feb 22, 2021

Run through. But a lot of error messages in the output , see attached file (hope it works how I attached the file)
Sorry for the inconvenience while testing. My linux skills are really basic and I do not understand what is behind the scene with this command

autosuspend-2021-02-21_error5.txt

@languitar
Copy link
Owner Author

Ah, you are missing the python development headers. That prevents a native dependency from compiling. Do the following to install them:

apt-get install python3-dev build-essential

Maybe that's enough to make things work.

@niram8
Copy link

niram8 commented Feb 22, 2021

Apparently not so eay. See attached file.
autosuspend-2021-02-22_error6.txt

@languitar
Copy link
Owner Author

Do you want to continue? [Y/n] Abort.

You didn't complete the package installation but cancelled it.

@niram8
Copy link

niram8 commented Feb 22, 2021

Sorry I forgot the -y parameter (apt-get install python3-dev build-essential) Otherwise it does not work on my system (forwhatever reason)
But apparently still something is missing. See attached file
autosuspend-2021-02-22_error7.txt

@languitar
Copy link
Owner Author

At least yet another missing package for enabling compilation:

apt-get install -y pkg-config python3-wheel

Maybe afterwards it gets further.

@niram8
Copy link

niram8 commented Feb 24, 2021

Still error.
autosuspend-2021-02-24_error8.txt
Apparently still not all packages installed. What do I need totally?

@languitar
Copy link
Owner Author

I suspect you need to install dbus-1-dev

@niram8
Copy link

niram8 commented Mar 1, 2021

Which package should I install? I looked on the web but cannot identify it. Maybe you could give me the complete apt-get install command.

@languitar
Copy link
Owner Author

apt-get install -y dbus-1-dev

?

@niram8
Copy link

niram8 commented Mar 2, 2021

This gives the error: Unable to locate package dbus-1-dev

@languitar
Copy link
Owner Author

I am not sure on what Linux distribution you are running. Maybe the package is called libdbus-1-dev on your system.

@niram8
Copy link

niram8 commented Mar 2, 2021

My linux distribution is: turnkey-nextcloud-16.0-buster-amd64
It should be the latest Debian Buster

But I think I give it up. I cannot manage the manual install

I further installed:
apt-get install -y libdbus-1-dev
apt-get install -y glib-2.0
apt-get install -y libglib2.0

Still errors (see attached file)
autosuspend-2021-03-02_error12.txt

@languitar
Copy link
Owner Author

That's normal. You do not have the development headers for some packages which need to be installed before the autosuspend installation can succeed. The pattern is always the same. In case something is missing the appropriate -dev package needs to be installed. Your suspicion with libglib2.0 was correct already, but for compilation to succeed, you always need the package version with the -dev postfix. So in this case libglib2.0-dev

@languitar
Copy link
Owner Author

I'll just merge this for now. In my test cases this works. If something doesn't work as expected once this is released, please open an new issue.

@languitar languitar merged commit 86ef70a into master Mar 10, 2021
@languitar languitar deleted the feature/98-last-log-time-check branch March 10, 2021 11:18
@github-actions
Copy link

🎉 This PR is included in version 3.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Activity check based on parsing last access times from a log file
2 participants