Page 1 of 1

[SOLVED] Check_cisco Syntax Error

Posted: Sun Nov 18, 2018 10:46 am
by Yooshi
Hello,

I try to setup a Nagios but i've some issue to monitore my Cisco devices.

I've download this plugin : https://github.com/ranl/monitor-utils/b ... k-cisco.pl

This plugin is stored in /usr/local/nagios/libexec and name "check_cisco_int.pl" (chmod 777)

I've configured my command.cfg like this :

Code: Select all

define command {

    command_name    check_cisco_int.pl
    command_line $USER1$/check_cisco_int.pl -H $HOSTADDRESS$
}
And my switch.cfg like this :

Code: Select all

# Define the switch that we'll be monitoring

define host {

    use                     generic-switch                      ; Inherit default values from a template
    host_name               xxxxxx                     ; The name we're giving to this switch
    alias                   xxxxxx              ; A longer name associated with the switch
    address                 xxxxxxx                       ; IP address of the switch
    hostgroups              switches                            ; Host groups this switch is associated with
}

Code: Select all

# Create a new hostgroup for switches

define hostgroup {

    hostgroup_name          switches                            ; The name of the hostgroup
    alias                   Network Switches                    ; Long name of the group
}

Code: Select all

define service {

    use                     generic-service                     ; Inherit values from a template
    host_name               xxxxx
    service_description     Port 49 Link Status
    check_command           check_cisco_int.pl! -C xxxxx -t int -i GigabitEthernet1/0/49
}
When i try to execute this in CLI its works perfectly :

Code: Select all

root@xxxxxx:/usr/local/nagios/libexec# ./check_cisco_int.pl -H xxxxx -C xxxxxx -t int -i GigabitEthernet1/0/49
OK: GigabitEthernet1/0/49 -> up | int=1
But on the web console i obtain a Syntax Error :

Code: Select all

Syntax Error !
check-cisco.pl
-H = Ip/Dns Name of the Switch
-C = SNMP Community
-t = Check type
temp - Temperature
fan - Fan Fail
ps - Power Supply Fail
cpu - CPU Load
mem - Memory
module	- Module Health
freeint - Free eth interfaces for X days (-d)
int - Interface Operation Stat (use with -i or -o)
-w = Warning Value
-c = Critical Value
-d = number of days that the ethernet interface hasn't change state, default is 14 (only for -t freeint)
-i = Interface Name (only for -t int)
-o = Interface OID (only for -t int)
Nothing wrong with :

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Someone can help me with that ?

Thanks!!

Re: Check_cisco Syntax Error

Posted: Mon Nov 19, 2018 10:02 am
by lmiltchev
The name of the plugin as shown in the error is different than the example you showed us previously...
Syntax Error !
check-cisco.pl
root@xxxxxx:/usr/local/nagios/libexec# ./check_cisco_int.pl -H xxxxx -C xxxxxx -t int -i GigabitEthernet1/0/49
OK: GigabitEthernet1/0/49 -> up | int=1
Is this a typo? Is your command named "check_cisco_int.pl" or "check-cisco.pl"?

You are running the check from the command line as root. Can you try running it as the nagios user?

Code: Select all

su - nagios
/usr/local/nagios/libexec/check_cisco_int.pl -H xxxxx -C xxxxxx -t int -i GigabitEthernet1/0/49
Does it work?

Re: Check_cisco Syntax Error

Posted: Mon Nov 19, 2018 1:49 pm
by Yooshi
check-cisco.pl is the original name of the plugin but its just a name, the script works independently of the name of the script, its just a name of what we call in command line.

If isn't, the command line should be not working i guess.

I've rename this script like this cause i use it for monitore the ports of my cisco devices.

The command line works well with nagios's user to.

I've made some modification to my configuration and now its working fine but i still dont understand why and how.... :lol:

I configured my switch.cfg like this :

Code: Select all

define service {

    use                     generic-service                     ; Inherit value$
    host_name               xxxxxxx
    service_description     Port 1/0/49 Link Status
    check_command           check_cisco_int! -t int -i GigabitEthernet1/0/49
}
and my command.cfg like this :

Code: Select all

define command {

    command_name    check_cisco_int
    command_line $USER1$/check_cisco_int -H $HOSTADDRESS$ -C xxxxxx $ARG1$
}
I can't understand why he works like this and not without the "-H $HOSTADDRESS$ -C xxxxxx" in command.cfg but directly in my switch.cfg like "check_cisco_int! -H xxxxx -C xxxxx -t int -i GigabitEthernet1/0/49"

And i can't understand what is this $ARG1$ and how he works... i put it here i don't know why like a flash of genius :lol:

Thanks for your answer !!

Re: Check_cisco Syntax Error

Posted: Mon Nov 19, 2018 2:19 pm
by scottwilkerson
$ARG1$ id everything after the first ! here and before the 2nd ! (if you had a 2nd !)

Code: Select all

check_command           check_cisco_int! -t int -i GigabitEthernet1/0/49
So, with the above check_command, nagios will execute the following

Code: Select all

/usr/local/nagios/libexec/check_cisco_int -H xxx.xxx.xxx.xxx -C xxxxxx -t int -i GigabitEthernet1/0/49

Re: Check_cisco Syntax Error

Posted: Sat Nov 24, 2018 8:23 am
by Yooshi
Sorry for the late of reply.

Thanks a lot scottwilkerson for ur answer, I understand better how use the ARG !!

My problem is solved ! Thanks all !!!

Re: Check_cisco Syntax Error

Posted: Mon Nov 26, 2018 7:59 am
by scottwilkerson
Yooshi wrote:Sorry for the late of reply.

Thanks a lot scottwilkerson for ur answer, I understand better how use the ARG !!

My problem is solved ! Thanks all !!!
Great!

Locking topic