After upgrading to NCPA 2.1.6 my .sh plugins started getting an error like this:
-bash-4.1$ /usr/local/nagios/libexec/check_ncpa.py -H sclppekbb003.tvlport.net -t wspwebfarm -M api/plugins/check_status_cassandra.sh -q "args=/apps02/tpworkdir/status.log,args= Cassandra_Cluster_Status"
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
OK: RTDP Cassandra_Cluster_Status is Up
Here is the execution of the test scrip and the script itself:
-bash-4.1$ /usr/local/nagios/libexec/check_ncpa.py -H shlgnwsad011.tvlport.net -t wspwebfarm -M api/plugins/check_test.sh
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
nagios
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
OK: Mounts are working
You have mail in /var/spool/mail/nagios
-bash-4.1$
test.sh
---------
#!/bin/bash
whoami
pwd
echo "OK: Mounts are working"
rc=0
exit $rc
NCPA 2.1.6 gives errors running shell scripts
Re: NCPA 2.1.6 gives errors running shell scripts
Can you post the ncpa.cfg file here so we can view it's settings?
What OS and Release is the NCPA agent running on?
Does /bin/bash exist?
If you change the first line of the script to
Does it pass?
What OS and Release is the NCPA agent running on?
Does /bin/bash exist?
If you change the first line of the script to
Code: Select all
#!/bin/shBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: NCPA 2.1.6 gives errors running shell scripts
I uploaded the ncpa.cfg; there are no other cfg files that we have created so no custom changes to the plain vanilla cfg.
Here is the /bin/sh
[nagios@shlgnwsad011 bin]$ pwd
/bin
[nagios@shlgnwsad011 bin]$ ll sh
lrwxrwxrwx 1 root root 4 Nov 14 2017 sh -> bash
[nagios@shlgnwsad011 bin]$
I changed the first line of the script to #!/bin/sh and received the same result:
-bash-4.1$ /usr/local/nagios/libexec/check_ncpa.py -H SHLGNWSAD011.TVLPORT.NET -t wspwebfarm -M plugins/check_test.sh
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
nagios
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
OK: Mounts are working
-bash-4.1$
Linux version:
[nagios@shlgnwsad011 tmp]$ uname -a
Linux shlgnwsad011.tvlport.net 2.6.32-642.15.1.el6.x86_64 #1 SMP Mon Feb 20 02:26:38 EST 2017 x86_64 x86_64 x86_64 GNU/Linux
Here is the /bin/sh
[nagios@shlgnwsad011 bin]$ pwd
/bin
[nagios@shlgnwsad011 bin]$ ll sh
lrwxrwxrwx 1 root root 4 Nov 14 2017 sh -> bash
[nagios@shlgnwsad011 bin]$
I changed the first line of the script to #!/bin/sh and received the same result:
-bash-4.1$ /usr/local/nagios/libexec/check_ncpa.py -H SHLGNWSAD011.TVLPORT.NET -t wspwebfarm -M plugins/check_test.sh
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
nagios
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
OK: Mounts are working
-bash-4.1$
Linux version:
[nagios@shlgnwsad011 tmp]$ uname -a
Linux shlgnwsad011.tvlport.net 2.6.32-642.15.1.el6.x86_64 #1 SMP Mon Feb 20 02:26:38 EST 2017 x86_64 x86_64 x86_64 GNU/Linux
You do not have the required permissions to view the files attached to this post.
Re: NCPA 2.1.6 gives errors running shell scripts
When the NCPA agent runs plugins, it runs them as the nagios user.
If that account has issues it that the home folder is missing, that would be one cause for the error.
Can you login to the server that is running the NCAP agent, run the commands and post the output?
Thanks
If that account has issues it that the home folder is missing, that would be one cause for the error.
Can you login to the server that is running the NCAP agent, run the commands and post the output?
Code: Select all
grep nag /etc/group
grep nag /etc/passwd
su - nagios
echo $HOMEBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: NCPA 2.1.6 gives errors running shell scripts
[c601018@shlgnwsad011 ~]$ grep nag /etc/group
nagcmd
249:
nagios
248:nagios
[c601018@shlgnwsad011 ~]$ grep nag /etc/passwd
nagios
498:249::/home/nagios:/bin/bash
[c601018@shlgnwsad011 ~]$ su - nagios
Password:
[c601018@shlgnwsad011 ~]$ sudo su - nagios
[nagios@shlgnwsad011 ~]$ echo $HOME
/home/nagios
[nagios@shlgnwsad011 ~]$
nagcmd
nagios
[c601018@shlgnwsad011 ~]$ grep nag /etc/passwd
nagios
[c601018@shlgnwsad011 ~]$ su - nagios
Password:
[c601018@shlgnwsad011 ~]$ sudo su - nagios
[nagios@shlgnwsad011 ~]$ echo $HOME
/home/nagios
[nagios@shlgnwsad011 ~]$
Re: NCPA 2.1.6 gives errors running shell scripts
Did you restart the ncpa_listener and ncpa_passive services after upgrading?
Code: Select all
service ncpa_listener restart
service ncpa_passive restartRe: NCPA 2.1.6 gives errors running shell scripts
i'll be damned, it helped! i was positive we did that during install so i need to talk to that person. thank you!
Re: NCPA 2.1.6 gives errors running shell scripts
No problem, glad to help! Am I okay to mark this as resolved and lock the topic or do you have any other related questions?
Re: NCPA 2.1.6 gives errors running shell scripts
yes, it is resolved for sure