error in running python plugin

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
magpantayr
Posts: 17
Joined: Sun May 14, 2017 10:33 pm

error in running python plugin

Post by magpantayr »

Hello,

I am monitoring our NetAPp filers Storage consumption with netappfiler.py plugin and is running properly for months

But after I followed this guide coz I am trying to make my oracle monitoring work (https://assets.nagios.com/downloads/nag ... ios-XI.pdf),
suddenly all of my services that uses this python plugin encountered error ( see code below)

Code: Select all

(No output on stdout) stderr: /usr/local/nagios/libexec/check_netappfiler.py: line 6: import: command not found

/usr/local/nagios/libexec/check_netappfiler.py: line 7: import: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 8: import: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 9: import: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 13: RETURNSTRINGS: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 14: RETURNCODE: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 16: available_subsys: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 18: OIDs: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 19: Uptime:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 20: ONTAP_Version:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 21: Model:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 23: CPU_Arch:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 24: CPU_Time_Busy:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 25: CPU_Time_Idle:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 26: CPU_Context_Switches:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 28: Net_RcvdKB:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 29: Net_SentKB:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 30: Net64_RcvdKB:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 31: Net64_SentKB:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 32: Net_ifNumber:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 33: Net_ifIndex:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 34: Net_ifDescr:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 36: Global_Status:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 37: Global_Status_Message:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 38: Cache_Age:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 40: Env_Temp:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 41: Env_Failed_Fans:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 42: Env_Failed_Fans_Text:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 43: Env_Failed_PowerSup:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 44: Env_Failed_PowerSup_Text:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 45: NVRAM_Status:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 47: CP:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 48: CP_NV_Full:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 49: CP_Totals:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 50: CP_FS_Sync:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 52: Autosupport_Status:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 53: Autosupport_FailedSends:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 55: Disks_Total:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 56: Disks_Active:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 57: Disks_Reconstructing:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 58: Disks_ReconstParity:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 59: Disks_Scrubbing:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 60: Disks_Failed:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 61: Disks_Spare:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 62: Disks_ZeroDisks:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 63: Disks_Failed_Descr:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 65: df_Number:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 66: df_FS_Name:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 67: df_FS_Mounted_On:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 68: df_FS_kBAvail:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 69: df_FS_%Used:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 70: df_FS_INodeUsed:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 71: df_FS_INodeFree:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 72: df_FS_%INodeUsed:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 73: df_FS_kBTotal_High:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 74: df_FS_kBTotal_Low:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 75: df_FS_kBUsed_High:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 76: df_FS_kBUsed_Low:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 77: df_FS_kBAvail_High:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 78: df_FS_kBAvail_Low:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 79: df_FS_Status:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 80: df_FS_Type:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 81: df64_FS_kBTotal:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 82: df64_FS_kBUsed:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 83: df64_FS_kBAvail:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 85: License_SnapMirror:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 86: License_NFS:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 87: License_CIFS:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 88: License_vFiler:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 89: License_FCP:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 90: License_iSCSI:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 91: License_SnapVaultPrimary:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 92: License_SnapVaultSecondary:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 93: License_SIS:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 95: CIFS_Connected_Users:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 96: CIFS_Total_Ops:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 97: CIFS_Total_Calls:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 98: CIFS_Bad_Calls:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 99: CIFS_Get_Attrs:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 100: CIFS_Reads:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 101: CIFS_Writes:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 102: CIFS_Locks:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 103: CIFS_Opens:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 104: CIFS_DirOps:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 105: CIFS_Others:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 107: Cluster_Settings:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 108: Cluster_State:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 109: Cluster_InterconnectStatus:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 110: Cluster_CannotTakeOverCause:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 112: Snapmirror_On:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 113: Snapmirror_Index:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 114: Snapmirror_Src:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 115: Snapmirror_Dst:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 116: Snapmirror_Status:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 117: Snapmirror_State:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 118: Snapmirror_Lag:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 120: Snapvault_On:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 121: Snapvault_Index:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 122: Snapvault_Src:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 123: Snapvault_Dst:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 124: Snapvault_Status:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 125: Snapvault_State:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 126: Snapvault_Lag:: command not found
/usr/local/nagios/libexec/check_netappfiler.py: line 127: syntax error near unexpected token `}'
/usr/local/nagios/libexec/check_netappfiler.py: line 127: ` }'
I also attached the plugin I am using.

Thanks!
You do not have the required permissions to view the files attached to this post.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: error in running python plugin

Post by scottwilkerson »

This looks like it is not executing through python, or cannot determine the path to python from the shebang line

Code: Select all

/usr/bin/env python
Can you run

Code: Select all

python /usr/local/nagios/libexec/check_netappfiler.py
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
magpantayr
Posts: 17
Joined: Sun May 14, 2017 10:33 pm

Re: error in running python plugin

Post by magpantayr »

Hello,

Putting python in the start did work. I just updated the command and included it.

Thanks for the support.

ANyways, do I need to include python in all my future commands that uses python?
Is there anyway I can fix the python not executing from the shebang line?

Thanks again!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: error in running python plugin

Post by scottwilkerson »

magpantayr wrote:ANyways, do I need to include python in all my future commands that uses python?
Is there anyway I can fix the python not executing from the shebang line?
The alternative is to put the full path to python in the shebang line, you can get it by running

Code: Select all

# which python
/usr/bin/python
Then change the shebang to

Code: Select all

#!/usr/bin/python
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
magpantayr
Posts: 17
Joined: Sun May 14, 2017 10:33 pm

Re: error in running python plugin

Post by magpantayr »

Hello,

Thanks for this! I've updated the python script.

I also noticed that my Oracle plugin did not work also (it is also using the /usr/bin/env) at the command line.

This is also working before

Code: Select all

/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64 $USER1$/check_oracle_health $ARG1$ --tablespace $ARG2$
Result:

Code: Select all

(No output on stdout) stderr:
I think all my commands that using /usr/bin/env is not working properly. How can I check this?

Thanks!
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: error in running python plugin

Post by lmiltchev »

It's possible that you have a broken symlink. Can you show us the output of the following commands?

Code: Select all

which env
ls -lL /usr/bin/env
env | grep -i oracle
Be sure to check out our Knowledgebase for helpful articles and solutions!
magpantayr
Posts: 17
Joined: Sun May 14, 2017 10:33 pm

Re: error in running python plugin

Post by magpantayr »

Hello,

This is the output:

Code: Select all

[root@CBAS035A ~]# which env
/usr/bin/env
[root@CBAS035A ~]# ls -lL /usr/bin/env
-rwxr-xr-x. 1 root root 0 Mar  4 16:46 /usr/bin/env
[root@CBAS035A ~]# env | grep -i oracle
[root@CBAS035A ~]#
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: error in running python plugin

Post by lmiltchev »

You will need to add the ORACLE_HOME and the LD_LIBRARY_PATH to your environment. If you haven't upgraded the oracle client, e.g. you are still using 12.1 and these paths didn't change:

Code: Select all

LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib 
ORACLE_HOME=/usr/lib/oracle/12.1/client64
you could run:

Code: Select all

export ORACLE_HOME=/usr/lib/oracle/12.1/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
In order to make the change permanent, you could place a script, named oracle.sh in /etc/profile.d, which contains the same commands:

Code: Select all

export ORACLE_HOME=/usr/lib/oracle/12.1/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
Reboot, and check to see if oracle home and library paths are added to your environment:

Code: Select all

env | grep -i oracle
Are you still using the 12.1 client? What is the output of the following command?

Code: Select all

ls -la /usr/lib/oracle/
Be sure to check out our Knowledgebase for helpful articles and solutions!
magpantayr
Posts: 17
Joined: Sun May 14, 2017 10:33 pm

Re: error in running python plugin

Post by magpantayr »

Done running the export command and creating oracle.sh inside the /etc/profile.d

But after reboot, I run the env | grep -i oracle but no output

Code: Select all

[root@CBAS035A ~]# env | grep -i oracle
[root@CBAS035A ~]#
But the export seems to be working

Code: Select all

[root@CBAS035A ~]# echo $LD_LIBRARY_PATH
/usr/lib/oracle/12.1/client64/lib
[root@CBAS035A ~]# echo $ORACLE_HOME
/usr/lib/oracle/12.1/client64
and yes, I still using oracle 12.1 client

Code: Select all

[root@CBAS035A /]# ls -la /usr/lib/oracle/
total 4
drwxr-xr-x   3 root root   18 Oct 11 13:20 .
dr-xr-xr-x. 32 root root 4096 Oct 11 13:20 ..
drwxr-xr-x   3 root root   22 Oct 11 13:20 12.1
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: error in running python plugin

Post by lmiltchev »

But after reboot, I run the env | grep -i oracle but no output
This is strange as the oracle home and library path were set in your environment... Anyway, can show us the actual check run from the command line along with the output of it?

Note: I believe you need to have " --mode <arg>" added to your command, for example:

Code: Select all

/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64 /usr/local/nagios/libexec/check_oracle_health --connect 'x.x.x.x:1521/xxx' --username '<username>' --password <password>' --mode tablespace-usage --tablespace USERS
If the command fails, try adding "-v" at the end for increased verbosity, and show the output.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked