nagios Check result path is not a valid directory - nagios

i'm getting error when i run below command
nagios3 -v /etc/nagios3/nagios.cfg
Error in configuration file '/etc/nagios3/nagios.cfg' - Line 469 (Check result path is not a valid directory) Error processing main config file
So i looked ls -l /var/lib/nagios3/
drwxr-x--- 3 nagios nagios 1024 Mar 14 21:13 spool
In this case, why i'm getting error? Probably i think my /var/lib/nagios3/spool/checkresult/check2JcDx5 file contains wrong line. And when i run below command, i get this output.
#cat check2JcDx5
file_time=1363378360
host_name=localhost
service_description=HTTP
check_type=0
check_options=0
scheduled_check=1
reschedule_check=1
latency=0.122000
start_time=1363378360.122234

Disable SELinux:
# getenforce
# setenforce 0
Edit /etc/selinux/config. Set SELINUX=disabled.

You may be able to install the nagios-selinux package to add the policy to run nagios in an selinux environment. Better than disabling your existing security.

Related

Warning: Return code of 127 for check of service was out of bounds. Make sure the plugin you're trying to run actually exists

I'm trying to use the phanton-js plugin for Nagios:
https://github.com/hggh/phantomjs-nagios
but despite me double checking the set-up, I'm getting
"Return code 127 is out of bounds : Plugin may be missing"
The plugin file exists in the plugins folder:
# stat /usr/lib64/nagios/plugins/check_http_load_time.rb
File: `/usr/lib64/nagios/plugins/check_http_load_time.rb'
Size: 9108 Blocks: 24 IO Block: 4096 regular file
Device: fc01h/64513d Inode: 275201 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
I can execute it when su'd to the nagios user locally:
-bash-4.1$ whoami
nagios
-bash-4.1$ /usr/lib64/nagios/plugins/phantomjs-nagios/check_http_load_time.rb -u https://google.com -w 2 -c 3
OK: https://google.com load time: 0.43
This is how it is defined in the checkcommands.cfg file:
define command {
command_name check_web_page_load_time
command_line $USER1$/check_http_load_time.rb -u $ARG1$ -w $ARG2$ -c $ARG3$
}
and this is the service definition
define service {
use generic-service
host_name test_host
service_description https://google.com web load time
check_command check_web_page_load_time!https://google.com!2!3
contact_groups support-emails
}
I've restarted nagios and confirmed that the config check passes.
Am I missing something obvious?
edit:
plugin file is located in 2 folders:
/usr/lib64/nagios/plugins/check_http_load_time.rb
and
/usr/lib64/nagios/plugins/phantomjs-nagios/check_http_load_time.rb
both files are identical, both can be executed by the nagios user successfully and neither location works with command definition. I tried calling it with full path and with the $USR1$ variable, which points to the standard location where all the other plugins are located
/usr/lib64/nagios/plugins/
Manged to eventually solve it. The error message was not very helpful, as problem was with the environment variables of the nagios user.
The original script had the following shebang:
#!/usr/bin/env ruby
After changing it to the actual location of ruby binary the script works:
#!/usr/local/rvm/rubies/ruby-2.5.1/bin/ruby
Still surprised that it worked when su'd to the Nagios user.

sh: 1: /my_path/ompi-1.1/compiler/ompi: permission denied when I run my C program

I have installed a software named "OMPi" (after make, it generated two executable file ompicc and ompi, and you can use ompicc -x file to do something, and ompi will be called by ompicc).
When I run the command ompicc ~/Documents/example.c in the directory "/my_path/ompi-1.1/compiler" (ompicc is here and ompi is in the sub_path "./ompi/"), an error occurred sh: 1: /my_path/ompi-1.1/compiler/ompi: permission denied. But when I ran the same command in any other directories, the error didn't occur.
sudo chmod 777 -R ompi-1.1 is no use.
I think it may be because the sub_path "./ompi/" get the same name with file ompi. So, I created a directory named "ompi/" in home_path, and then ran the above command. To my surprise, the error didn't occur. It seems that the error only occur when I run the command in the directory: /my_path/ompi-1.1/compiler/
information in terminal
From the looks of it (I have briefly checked ompi's source code), the ompi program is expected by ompicc to be in the same directory. It worked fine after you had created /ompi/ in home directory, because you still had executable of the same name in the same directory as ompicc. It doesn't work in the directory you specified because there's only one ompi there which is a directory.
Line that does the execution in ompicc.c (the constructed command is then ran by a system() call:
sprintf(cmd, "%s%s%s \"%s.pc\" __ompi__%s%s%s%s%s%s%s %s > \"%s\"%s",
usegdb ? "gdb " : "", /* Run gdb instead of running _ompi directly */
RealOmpiName,
usegdb ? " -ex 'set args" : "", /* Pass the arguments */
/* ...further arguments here... */
To confirm that RealOmpiName is 'ompi' i followed the program and
RealOmpiName is traced back to (through external symbol OmpiName)
Makefile.am:
-DOmpiName='"_#PACKAGE_TARNAME#"' \
Which then is used like this (to install the software):
cp -f ompi $(DESTDIR)$(bindir)/_#PACKAGE_TARNAME#
cp -f ompicc $(DESTDIR)$(bindir)/#PACKAGE_TARNAME#cc
I think the installer wouldn't put the two programs together if it didn't require the two to be in the same directory in the first place.
Solution: ompi and ompicc have to be in the same folder/directory.

How do I solve this path error when trying to run ANSYS with parallel processing using MPI?

I am currently attempting to write a batch file that will open ANSYS Autodyn using MPI on a virtual machine. Whenever I attempt to start the program however, I get the following message;
WARNING: No cached password or password provided.
use '-pass' or '-cache' to provide password
AVS/Express Developer Edition
Version: 8.0 fcs pc10_64
Project: C:\Program Files\ANSYS Inc\v162\aisol\AUTODYN
--- Error detected in: module: OMopen_file ---
can't find file with name: appl and suffix: v or vo in path: C:\Program
Files\ANSYS Inc\v162\aisol\AUTODYN\v;C:\Program Files\ANSYS
Inc\v162\aisol\AUTODYN;.
MPI Application rank 0 exited before MPI_Init() with status -1
The problem is caused by the fact that the path specified in the last paragraph there should be;
C:\Program Files\ANSYS Inc\v162\aisol\AUTODYN\winx64
The problem is that I cannot find the variable that specifies that path, and so I cannot change it. Does anyone know how to solve this problem? Or am I stuck using just one core for the time being?
The batch file code is;
set MPI_ROOT=C:\Program Files\ANSYS Inc\v162\commonfiles\MPI\Platform\9.1.2.1\winx64
"%MPI_ROOT%\bin\mpirun.exe" -mpi64 -prot -e MPI_WORKDIR="C:\Users\umjonesa\AppData\Roaming\Ansys\v162\AUTODYN" -f applfile.txt
PAUSE
That opens the .txt called applfile;
-e MPI_FLAGS=y0 -h localhost -np 1 "C:\Program Files\ANSYS Inc\v162\aisol\AUTODYN\winx64\autodyn.exe"
-h localhost -np 3 "C:\Program Files\ANSYS Inc\v162\aisol\AUTODYN\winx64\adslave.exe"
which should open an autodyn window with one master and three slaves.

Nagios: trying to run custom command return 126

I'm trying to get Nagios to execute a custom java command but I always get error 126.
[1360324906] Warning: Return code of 126 for check of service 'Java Process Test' on host 'localhost' was out of bounds.Make sure the plugin you're trying to run is executable.
Now I've checked few things but as I'm a newbie here I probably missed something.
Here few information about the environment:
-rwxr-xr-x. 1 root root 2938 Aug 17 15:39 check_wave
drwxr-xr-x. 2 root root 4096 Jan 13 15:08 eventhandlers
drwxr-xr-x. 2 root root 4096 Feb 7 17:22 jars
-rwxr-xr-x. 1 root root 38696 Aug 17 15:39 negate
-rwxr-xr-x. 1 root root 886 Feb 8 12:47 test_java_plugin.sh
test_java_plugin.sh is my test script and "jars" is the current dir where the jar is located
Scripts is this:
#!/bin/bash
#This will get the output of process
output=$(/usr/java/latest/bin/java -cp .:/usr/lib64/nagios/plugins/jars/SimpleNagiosPlugin.jar it.nagios.SimpleTest)
#This will catch the result returned by last process that is our java command
java_result=$?
echo "$java_result: $output"
exit $java_result
and is working perfectly when launched manually at console
[root#bw plugins]# ./test_java_plugin.sh
0: This is an OK message
Forgot to add command definition:
# 'test_java_plugin' command definition
define command{
command_name test_java_plugin
command_line $USER1$/test_java_plugin.sh
}
Also as as per request into comment I'm adding also the current java code of my test class
public static void main(String[] args) {
System.out.println("This is an OK message");
System.exit(0);
}
Just launching the command from a shell I got still 0:
[root#bw plugins]# /usr/java/latest/bin/java -cp .:/usr/lib64/nagios/plugins/jars/SimpleNagiosPlugin.jar it.nagios.SimpleTest
This is an OK message
[root#bw plugins]# echo $?
0
What else should I check to determine what is going wrong here?
I faced a similar issue and found that SELinux was blocking me. The same can be checked in /var/log/audit/audit.log
If you get denied errors for nagios_t/nagios_system_plugin_t, add them to the permissive list of selinux using the below command rather than turning it off completely
semanage permissive -a nagios_t
you should try to run test_java_plugin.sh as nagios user, you can give nagios a shell (temporary) . Take into account that the root environment is different from the nagios environment . When running test_java_plugin.sh as nagios , you can add "env > env_log_file" to see what is the environment during the run time.
Good luck.
Error 126 Means that the plugin was found but not executable.
You can try 2 things.
Try running the plugin as nagios user and check for the error.
or
This did work out for one issue i had. Try it out. hopefully it may work
/bin.bash -l -c "/#{path to plugin}/test_java_plugin.sh"

Backtrack 5 r3 "apt-get upgrade" error [NEED HELP]

root#bt:~# apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
smartphone-pentest-framework
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
1 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up w3af (1.2-bt2) ...
tar: pybloomfiltermmap-0.2.0.tar.gz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: Exiting with failure status due to previous errors
/var/lib/dpkg/info/w3af.postinst: line 4: cd: pybloomfiltermmap-0.2.0: No such file or directory
python: can't open file 'setup.py': [Errno 2] No such file or directory
svn: Working copy 'w3af' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
dpkg: error processing w3af (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
w3af
E: Sub-process /usr/bin/dpkg returned an error code (1)
root
I have copied and pasted the errors i get while updating the packing "smartphone-pentest-framework" above.
What is going wrong and what is the problem?
As you can see "/var/lib/dpkg/info/w3af.postinst: line 4: cd: pybloomfiltermmap-0.2.0: No such file or directory" so simple solution to change the download URL here is the trick they have a bug in their script as the repository moved to https://svn.code.sf.net/p/w3af/code/trunk
so simply edit w3af.postinst file (vi /var/lib/dpkg/info/w3af.postinst)
and replace old url with
https://svn.code.sf.net/p/w3af/code/trunk
save file and then run w3af setup again...

Resources