So, the title pretty much says it. I'm trying to customize several plugins for nagios and several of them have to be in python.
I'm running Centos 6.5, Python 2.6.6, and Nagios Core 3.5.1
I've installed nagios and python use the yum repository, and everything works when run from the command line, even as the nagios user. I can get bash scripts to run from the nagios system just fine, but even trying to wrap the python in a bash script doesn't work. Whatever I run, even something as simple as
echo `/usr/bin/python --version`
returns an empty or null string.
It also apparently exits with status zero (even when the run code should have produced something else) no matter what I do. This problem appears to be specific to Python and not have anything to do with basic permissions. It might have something to do with ACLs, though I have no idea what. Does anyone have any ideas for what might be going wrong?
Nagios can display some really odd behaviors when things exit with an unknown status and no output. It turns out that a good first debugging step is to try adding something like
<command> 2>&1
or
echo `<command> 2>&1`
to your plugin call to check what stderr is telling you.
Related
I'm running the command
make config=default_config.mk task
with task being different tasks I can run. The entire program is pretty dated with very little support. The 'default_config.mk' file lets you change directorys, after that the programm is supposed to work.
It turns out the makefile runs the default-python. The Makefile basically runs a bunch of different .py-files.
I've already created an alias for python3 which works in the terminal, but not when I run the program. I've now created a new Makerun-file and changed every python to python3. Apart from that and adding '#!/bin/bash' to the first line (to make it executable?) it should be the same file.
Now, I keep getting the error
make: *** No rule to make target `task'. Stop.
Does anyone have an idea?
Thank you
Edit:
So I've managed to install Psycopg2 to Python 2.7, now it throws an error for the command:
python SciGRID.py --dbpwrd $(postgres_password)
Error:
SciGRID.py: error: --dbpwrd option requires an argument
The Programm is supposed to run on Python 2.7. I think the best way would be to change the Makefile, but that's when the error "no rule..." appears. If I use the default Makefile I basically keep running into errors as its pretty dated. Why is it not accepting the edited makefile?
I'm writing my first complete python project with Vim. As I was modifying a
file I accidentally hit several keys that I can't find back and I get this
prompt:
I didn't know it was possible to get this kind of help on a module I am
writing and I have no idea how I got it, so my question is:
What command or tools allows to generate this kind on module information?
Several notes
The command is not a Vim command because the ouput was in an external
shell (so I probably use an equivalent to :![command].
I don't have any Vim plugin related to python installed so it was probably not generated by a plugin.
The command wasn't issued in an interactive python prompt since I started my vim from my bash prompt.
I have not idea of how many keystrokes I used.
My Vim command history and my bash history doesn't have a trace of what
happened.
I'm using zsh and oh-my-zshell
I know that this question might sound silly but I have no idea of which tool can do that and I have no mean to find what sequence of keystrokes I used.
You can use pydoc command to get module help
pydoc requests
if you are using the interactive python shell, you can use the help function:
>>> import requests
>>> help(requests.get)
it work on class instance too
I'm wanting to open a terminal from a Python script (not one marked as executable, but actually doing python3 myscript.py to run it), have the terminal run commands, and then keep the terminal open and let the user type commands into it.
EDIT (as suggested): I am primarily needing this for Linux (I'm using Xubuntu, Ubuntu and stuff like that). It would be really nice to know Windows 7/8 and Mac methods, too, since I'd like a cross-platform solution in the long-run. Input for any system would be appreciated, however.
Just so people know some useful stuff pertaining to this, here's some code that may be difficult to come up with without some research. This doesn't allow user-input, but it does keep the window open. The code is specifically for Linux:
import subprocess, shlex;
myFilePathString="/home/asdf asdf/file.py";
params=shlex.split('x-terminal-emulator -e bash -c "python3 \''+myFilePathString+'\'; echo \'(Press any key to exit the terminal emulator.)\'; read -n 1 -s"');
subprocess.call(params);
To open it with the Python interpreter running afterward, which is about as good, if not better than what I'm looking for, try this:
import subprocess, shlex;
myFilePathString="/home/asdf asdf/file.py";
params=shlex.split('x-terminal-emulator -e bash -c "python3 -i \''+myFilePathString+'\'"');
subprocess.call(params);
I say these examples may take some time to come up with because passing parameters to bash, which is being opened within another command can be problematic without taking a few steps. Plus, you need to know to use to quotes in the right places, or else, for example, if there's a space in your file path, then you'll have problems and might not know why.
EDIT: For clarity (and part of the answer), I found out that there's a standard way to do this in Windows:
cmd /K [whatever your commands are]
So, if you don't know what I mean try that and see what happens. Here's the URL where I found the information: http://ss64.com/nt/cmd.html
I normally program in Java, but started learning Python for a course I'm taking.
I couldn't really start the first exercise because the command
python count_freqs.py gene.train > gene.counts
didn't work, I keep getting "incorrect syntax" messages. I tried solving this looking at dozens of forums but nothing works, and I'm going crazy.
import count_freqs
ran without errors, but I can't do anything with it. When I try running something involving the file gene.train I get "gene is not defined".
Can anyone tell me what I'm doing wrong? Thanks.
type which python at the command prompt to see if the python executable is in your path. If not it either isn't installed or you need to amend your path to include it.
on Windows you can type echo %%PATH%% at the command prompt. It will give you at list of all the directories the shell search for programs to run. By default Python 3.3 will be installed on C:\Python33.
I'm not a programmer or anything like that, but I recently installed some python scripts and I'm struggling to execute them as part of a workflow on startup. I run an automator workflow that executes these three separate commands:
python /Applications/Sick-Beard/Sickbeard.py --daemon
python /Applications/CouchPotatoServer/CouchPotato.py --daemon
python /Applications/Headphones/Headphones.py --daemon
I can run these commands in a terminal window without any problem. However, when executing the commands as a single workflow or even three separate ones in quick succession, it always yields the follow error.
I'm at my wits end. Your help is very appreciated. The same error is caused when I create .plit LaunchAgents.
Thanks in advance, your help is more than appreciated. I had to put this on pastebin because I kept on getting formatting errors.
http://pastebin.com/qb65Mc53