plugin:mikrotik - PHP escape character

General discussion about Plugins for Cacti

Moderators: Moderators, Developers

Post Reply
Author
Message
User avatar
proohu01
Posts: 45
Joined: Mon Dec 20, 2004 3:13 am
Location: The Netherlands

plugin:mikrotik - PHP escape character

#1 Post by proohu01 » Thu Oct 24, 2013 12:55 am

Dear Cacti users,

I am using http://docs.cacti.net/plugin:mikrotik#mikrotik with cacti Version 0.8.8b.

I am seeing the following on the cacti.log file
10/24/2013 07:25:01 AM - SPINE: Poller[0] Host[798] Description[APXXX001] ERROR: Empty result [APXXX001.bla.local]: '/usr/bin/snmpwalk APXXX001.bla.local -Cc -v 1 -c nevermind 1.3.6.1.2.1.4.22.1.2 | /bin/wc -l | /bin/awk \'{printf$0}\''
10/24/2013 07:25:01 AM - SPINE: Poller[0] Host[798] Description[APXXX001] ERROR: Empty result [APXXX001.bla.local]: '/usr/bin/snmpwalk APXXX001.bla.local -Cc -v 1 -c nevermind .1.3.6.1.4.1.14988.1.1.1.2.1.3 | /bin/wc -l | /bin/awk \'{printf$0}\''
I found out that the problem is with the \'{printf$0}\' bit. I should be '{printf$0}'

When I look at the "Console -> Data Input Methods -> Unix - Count Oids", the input string says: "/usr/bin/snmpwalk <ip> -Cc -v <ver> -c <comm> <oid> | /bin/wc -l | /bin/awk '{printf$0}'". The PHP escape characters are added automatically by Cacti in a later stage but should not end up at the final prompt as it does now.

Can someone provide a workaround or even a fix for this problem?
Cacti Version - 0.8.8b
CentOS 6.4

User avatar
proohu01
Posts: 45
Joined: Mon Dec 20, 2004 3:13 am
Location: The Netherlands

Re: plugin:mikrotik - PHP escape character

#2 Post by proohu01 » Tue Oct 29, 2013 12:41 am

:o Anyone...
Please...

This is a new and fresh installation of Cacti and CentOS. I have a ton of plugins installed so far and everything seems oke except for the problem mentioned above.
Cacti Version - 0.8.8b
CentOS 6.4

User avatar
proohu01
Posts: 45
Joined: Mon Dec 20, 2004 3:13 am
Location: The Netherlands

Re: plugin:mikrotik - PHP escape character

#3 Post by proohu01 » Tue Oct 29, 2013 6:04 am

I fixed it myself the dirty way :-?

Placed a bash script in the cacti scripts directory.

Code: Select all

#!/bin/bash
#
# Cacti Data Input Method: Unix - Count Oids
# Origional command: /usr/bin/snmpwalk <ip> -Cc -v <ver> -c <comm> <oid> | /bin/wc -l | /bin/awk '{printf$0}'

export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"

/usr/bin/snmpwalk $1 -Cc -v $2 -c $3 $4 | /bin/wc -l | /bin/awk '{printf$0}'
Then, changed the "Unix - Count Oids" to

Code: Select all

"bash <path_cacti>/scripts/unix_count_oids_fix.sh <ip> <ver> <comm> <oid>"
Cacti Version - 0.8.8b
CentOS 6.4

grillotron
Posts: 2
Joined: Mon Jul 18, 2016 7:41 am

Re: plugin:mikrotik - PHP escape character

#4 Post by grillotron » Fri Sep 09, 2016 3:32 am

Gracias :lol: me sirvió

Post Reply