Project

General

Profile

Actions

Bug #6386

closed

Quote-Parsing bug in Smart Class Parameter Value

Added by   Zordrak over 10 years ago. Updated over 7 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
Parameters
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Using a zabbix_agent module that takes an array for zabbix_user_parameters that populates the user_parameters configuration file.

This is a valid array as used in puppet to configure the variable for monitoring MySQL with Zabbix:

[
  'mysql.uptime[*],mysqladmin -u$1 -p$2 status|cut -f2 -d":"|cut -f1 -d"T"',
  'mysql.threads[*],mysqladmin -u$1 -p$2 status|cut -f3 -d":"|cut -f1 -d"Q"',
  'mysql.questions[*],mysqladmin -u$1 -p$2 status|cut -f4 -d":"|cut -f1 -d"S"',
  'mysql.slowqueries[*],mysqladmin -u$1 -p$2 status|cut -f5 -d":"|cut -f1 -d"O"',
  'mysql.qps[*],mysqladmin -u$1 -p$2 status|cut -f9 -d":"',
  'mysql.status[*],mysqladmin -u$1 -p$2 extended-status | awk \'$$2 ~ /^$3$/ { if($$4 != "|") print $$4 }\'',
  'mysql.ping[*],mysqladmin -u$1 -p$2 ping | egrep alive | wc -l',
  'mysql.version,mysql -V',
  'mysql.slave[*],mysql -u$1 -p$2 -e "show slave status\G"| awk \'/$3:/ {print $NF}\' | sed s/Yes/1/ | sed s/No/0/',
]

When entered (no whitespace) as a default value for the parameter in the UI, the following error is generated:

(<unknown>): found unexpected ':' while scanning a plain scalar at line 1 column 624

It is failing to determine that the ' used in the awk statement is escaped by a \

This can be fixed by reversing the use of quotations, replacing ' with " and " with ' and escaping any existing "s. This is how the setting is detected if it is set in the module and then imported:

[
  "mysql.uptime[*],mysqladmin -u$1 -p$2 status|cut -f2 -d\":\"|cut -f1 -d\"T\"",
  "mysql.threads[*],mysqladmin -u$1 -p$2 status|cut -f3 -d\":\"|cut -f1 -d\"Q\"",
  "mysql.questions[*],mysqladmin -u$1 -p$2 status|cut -f4 -d\":\"|cut -f1 -d\"S\"",
  "mysql.slowqueries[*],mysqladmin -u$1 -p$2 status|cut -f5 -d\":\"|cut -f1 -d\"O\"",
  "mysql.qps[*],mysqladmin -u$1 -p$2 status|cut -f9 -d\":\"",
  "mysql.status[*],mysqladmin -u$1 -p$2 extended-status | awk '$$2 ~ /^$3$/ { if($$4 != \"|\") print $$4 }'",
  "mysql.ping[*],mysqladmin -u$1 -p$2 ping | egrep alive | wc -l",
  "mysql.version,mysql -V",
  "mysql.slave[*],mysql -u$1 -p$2 -e \"show slave status\\G\"| awk '/$3:/ {print $NF}' | sed s/Yes/1/ | sed s/No/0/" 
]

Despite using the original notation in the file, the reversed notation is displayed in the UI.

I do not believe the original notation is invalid and therefore it ought to be correctly parsed by the UI; or at least should be converted into the reversed notation as done when loaded via the module's own defaults.

Actions #1

Updated by Dominic Cleal over 10 years ago

  • Category changed from Web Interface to Parameters
  • Status changed from New to Feedback

Foreman's array syntax is JSON, which isn't the same as Puppet's DSL. The second syntax is correct JSON as it uses double quotes, but single quotes aren't valid for strings in JSON - only in Puppet's DSL. I think this is correct.

Actions #2

Updated by Anonymous over 7 years ago

  • Status changed from Feedback to Rejected

no bug.

Actions

Also available in: Atom PDF