Hello,
This may be documented somewhere but I am trying to run a plugin '.sh' (Bash) script -- check_snmp_printer (and named it with a .sh extension) from https://github.com/ynlamy/check_snmp_printer but I can't seem to run. Though I can see it with LS it reports...
bash: /usr/local/nagios/libexec/check_snmp_printer.sh: /bin/bash^M: bad interpreter: No such file or directory
However I have other .SH plugins that seem to work so I am missing something basic at the command line.
Also (probably a very silly question) but how do you single step through a pearl or bash script? What tools are available to do this?
Thanks,
Tom
How to run plugin at command line
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: How to run plugin at command line
Hi Tom,
First, use the Upload a Plugin feature from the Manage Plugins page in Nagios XI so the correct plugin permissions will get set automatically. To upload a plugin, go to Admin > System Extensions >Manage Plugins.
To test a plugin from the command line, follow the instructions are our knowledgebase:
Nagios XI - How To Test Check Commands From The Command-line
Lastly, to execute a bash script in debug mode, run following:
Let us know if you have any other questions or need further assistance.
First, use the Upload a Plugin feature from the Manage Plugins page in Nagios XI so the correct plugin permissions will get set automatically. To upload a plugin, go to Admin > System Extensions >Manage Plugins.
To test a plugin from the command line, follow the instructions are our knowledgebase:
Nagios XI - How To Test Check Commands From The Command-line
Lastly, to execute a bash script in debug mode, run following:
Code: Select all
bash -x your-script.sh
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
tmattingly
- Posts: 115
- Joined: Thu Oct 23, 2014 12:53 pm
Re: How to run plugin at command line
Thats good and I've been down that path. Apparently after some further testing I had opened up the file on my Windows 10 machine in Notepad++ but when I went to import it I didn't check the box 'Convert line endings' and that really through off Bash.
Tom
Tom
Re: How to run plugin at command line
That would do it.
FYI, you could check the line endings in Linux when you open your plugin in "vi", by typing:
and pressing "Enter". You should see:
If you see "dos", then you would need to convert it.
press Enter, then save the file and exit:
Let us know if it is OK to close this topic. Thanks!
FYI, you could check the line endings in Linux when you open your plugin in "vi", by typing:
Code: Select all
:set ff?Code: Select all
fileformat=unixCode: Select all
:set ff=unixCode: Select all
:wqBe sure to check out our Knowledgebase for helpful articles and solutions!
-
tmattingly
- Posts: 115
- Joined: Thu Oct 23, 2014 12:53 pm
Re: How to run plugin at command line
Last question, what is the best tools to use to debug a pearl or bash script?
Beyond that, YES close the thread.
Tom
Beyond that, YES close the thread.
Tom
Re: How to run plugin at command line
You can run a bash script with "-x", and perl script with "-d" in order to debug them.
Example:
Example:
Code: Select all
bash -x /path/to/bash_sciprt.sh
perl -d /path/to/perl_script.plBe sure to check out our Knowledgebase for helpful articles and solutions!