Closed ddmo closed 4 years ago
Ok, after several attempts I insert all vars in bash_profile and it works. Thanks
Did you enter the lines that are displayed at the end of the pyenv installation process in your .bashrc? Good that you were able to solve your issues, sorry that I did not see them earlier.
Same problem here. Could you elaborate on what "inserting all vars" means? Did not work on pyenv's installation instructions, nor with copypasteing the .bashrc variables to .bash_profile.
.bash_profile:
export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init --path)"
if [ -f ~/.bashrc ]; then . ~/.bashrc fi
export ZBXDB_HOME=$HOME export ZBXDB_OUT=$ZBXDB_HOME/zbxdb_out; #make sure this reflects the out_dir parameter in the monitoring cfg files.) export PATH=$PATH:$HOME/zbxdb/bin
.bashrc:
if [ -f /etc/bashrc ]; then . /etc/bashrc fi
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]] then PATH="$HOME/.local/bin:$HOME/bin:$PATH" fi
export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)"
Am I missing something here?
Did you source the .bash_profile after adding the 3 lines for pyenv? (or did you logon again)
Yeah, I did. Pip install sqlparse tells me inside the virtualenv that sqlparse is installed etc.
I'll try to reinstall the whole thing and let you know if it persists. Just in case something went awry.
How does the crontab entry for zbxdb_starter look like?
Crontab seems fine since it runs the zbxdb_starter every minute. Copypasted straight from the manual.
The weird thing here is that running zbxdb.py -c etc/zbxdb.hostname.cfg by hand in the bin folder seems to work fine.
If it is running fine when interactive, check the crontab line for zbxdb_starter. It is important that it sources the .bash_profile before zbxdb_starter, otherwise the virtual environment function pyenv is not in the process environment.
The crontab lines are as follows:
Running on RHEL8.2.
Looks like OK. No complaints in log/zbxdb_starter.cron ?
zbxdb_starter.cron:
mon etc/zbxdb.hostname.cfg 1
The zbxdb.py process for this config is still running. Stop it first and check the output of the first execution after stopping the zbxdb.py process. You can use zbxdb_stop to stop the running processes. If you change the log into append it gives you a bit more time to check the log: . $HOME/.bash_profile;$HOME/zbxdb/bin/zbxdb_starter >>log/zbxdb_starter.cron 2>&1
Tried reinstalling the whole thing but the result is still the same. Tried zbxdb_stop, then add the append line to crontab and zbxdb_starter and after that it just appends the "mon etc/zbxdb.hostname.cfg 1" message every minute.
Zbxdb_starter.log only gives this:
Fri May 28 11:03:01 EEST 2021 Starting etc/zbxdb.hostname.cfg
Traceback (most recent call last):
File "/home/***/zbxdb/bin/zbxdb.py", line 39, in
When trying to import sqlparse from the virtual env like this:
cd zbxdb python
import sqlparse
It does not give any errors.
Pip list says that sqlparse is on version 0.4.1. Is that too new of a version?
I also have sqlparse 0.4.1 so that won't be the problem. python 3.9.2 ? I must confess that currently I have not the slightest idea what is wrong. If you followed https://github.com/ikzelf/zbxdb/blob/master/doc/getting_started.md, the setup part, it should work. Do you have a separate config file for pip in place? Your sqlparse shows up here: ls -ld ~/.pyenv/versions/3.9.2/envs/zbxdb-3.9.2/lib/python3.9/site-packages/sqlparse
Yep, followed the setup part and configured all prereqs and pyenv variables etc. Sqlparse shows on that dir. No additional pip configs.
Should this work on a RHEL8/CentOS platform or should I try installing this on Ubuntu/Debian/something else? SELinux is on permissive mode btw.
I had it running on both OSX, RHEL and CentOS, with recent releases. I am not aware of any issues here. Can you do such an import test started from cron? Put a little script in zbxdb/z.py with just the import and see what happens. Normall when addressing a script in a directory that has a venv assigned to it, the venv is auto activated. For some reason it looks like this is not happening in your case.
try
* * * * * . $HOME/.bash_profile;pyenv activate zbxdb-3.9.2;$HOME/zbxdb/bin/zbxdb_starter
in crontab. I don not know why but it is always ignoring the pyenv settings
Maybe file this as an issue with the pyenv maintainer? Good tip btw.
Is /usr/local/bin in your PATH when coming from crontab? This is where pyenv is installed.
Did you get this working?
OS ist CentOS7, pyenv ist installed to .pyenv in the profile/home of the zbxdb user. For all users, pyenv is NOT installed. And yes, it is working with my posted crontab-solutions. I did not find out what is getting wrong on CentOS 7. I try difference settings in .bashrc and .bash_profile but all will be ignored.
Installed a fresh OracleLinux 8.4 server and installed this there. Worked like a charm when using pyenv global zbxdb-3.9.2 instead of pyenv local zbxdb-3.9.2. I'll test that on the initial machine aswell.
What's the downside of using pyenv global? (Not a dev here. :))
The downside will be close to zero I guess (not a dev either ;-) ) but for me it looked cleaner to have this local. If your user is dedicated to running zbxdb the downside will even be closer to zero. The 'global' part is just for the user, not for the machine.
Hi, after installation and configuration I got this error in zbxdb_starter.log:
Pyton is properly configured (I suppose):
Whats wrong? Thanks a lot Stefano