Nagios Plugin via CLI

Hi via wato I already intergrated some rules with the nagios plugin. can i know if via cli where is the file located. any idea?

If I understood you correctly you are asking where the excutables for your 630 nagios checks are located, right?

Basically they can be anywhere on the checkmk server, but usually they are located in either ~/local/lib/nagios/plugins or ~/lib/nagios/plugins within the site directory. If not, the Command line field of the rule must contain the full path. The online help of the rule says:

If in doubt, you must check all your Nagios rules.

2 Likes

when i run iget below image

Yes. This is the list of Nagios plugins that come with checkmk. What is your question? How can I help you?

I’m guessing @farhan wants a text list of all the command lines of the 630 nagios checks.

If you want a listing of all the Nagios rules, just go to Setup > Services > Other services > Integrate Nagios plugins. You will get listings per host folder.

When the command line doesn’t begin with a path, it runs a check from folders @Dirk mentioned. Otherwise a path is shown.

If you want those listings offline as text for analysis, or whatever, you can use a browser extension like Table Capture for Firefox, Chrome and Edge to copy tables as tab seperated data to clipboard.

A table like:
image

Can be copied with that browser extension to get something like this:

Actions	Conditions	Value	Description
		No conditions	Service description: SNMP Kyocera Model  <> Command line: check_snmp -H $HOSTADDRESS$  -o 1.3.6.1.2.1.25.3.2.1.3.1 -P 2c -C public	SNMP Kyocera Model
		No conditions	Service description: SNMP Kyocera Serial  <> Command line: check_snmp -H $HOSTADDRESS$  -o 1.3.6.1.4.1.1347.43.5.1.1.28.1 -P 2c -C public	SNMP Kyocera Serial
		No conditions	Service description: SNMP Kyocera Device  <> Command line: check_snmp -H $HOSTADDRESS$  -o 1.3.6.1.4.1.1347.43.5.1.1.29.1 -P 2c -C public	SNMP Kyocera Device
		No conditions	Service description: SNMP Kyocera System  <> Command line: check_snmp -H $HOSTADDRESS$  -o 1.3.6.1.4.1.1347.43.5.4.1.5.1.1 -P 2c -C public	SNMP Kyocera System

Put the data in your favourite spreadsheet tool, for filtering, or whatever you want to do with it.

2 Likes

in which folder and file i should get or paste the command line?

It’s not clear to me what you want to achieve.

If you take the example from @Yggy and want to run the command for the check_snmp check then you were already in the right folder. The Nagios plugin is in the directory that you showed in your screenshot. So

cd ~/lib/nagios/plugins 
./check_snmp -H $HOSTNAME$ ...

(Of course you must replace $HOSTNAME$ with the hostname that you want to check.)

because when i try to run vi / nano to check_snmp seems like the file is unwritebale

Yes, the file is read-only. You are not supposed to edit files in the ~/lib directory.

If you want to change the check_snmp file, then you must copy it from ~/lib/nagios/plugins to ~/local/lib/nagios/plugins (notice the local) and edit it there.

I see another question is
i have two type of rules to be created in check_snmp/nagios
which

  1. not required graph (command that use in gui as bellow)

while 2) required graph (command use as bellow)

is there any way if i proceed it via command line and can help to show little sample for it

I’m afraid I cannot help you. I don’t use Nagios plugins.

But I wonder why you do not put those complicated, overly long and unmaintainable

sh -c snmpwalk...|awk …; awk …; if … then … else …; awk …

commands into a script, put that script below ~/local/lib/nagios/plugins and then just call the script from your rule. That’s far easier plus you can call the script from the command line to check if it works properly.


I also wonder why there is a hardcoded IP address in the rule instead of the variables $HOSTNAME$ or $HOSTADDRESS$. If the rule matches multiple MODEMs in your folder Ulu… then they will all query the exact same IP address via snmpwalk. I’m not sure if that is intended but I do not know your environment, so maybe it’s right.