Go to All Forums

Getting '/bin/sh: 1: Syntax error: "(" unexpected' with mysql_monitoring plugin

For whatever reason my SQL monitoring stopped working about a month ago, and I've gone through email support but have had no results, looking to see if someone had the same issue.

I've repolled, reinstalled everything, etc

Attached below is the contents of mysql_monitoring.py and the output for running mysql_monitoring on my server.

Like (1) Reply
Replies (6)

Hi Auxilium,

Sorry for the inconvenience caused. 

While executing the mysql_monitoring plugin from agent, it throws error. Due to this plugin error "/bin/sh: 1: Syntax error: "(" unexpected' with mysql_monitoring plugin", plugin monitor was showing down.  

Please let us know the following things to debug the case further. 

1.  Did you update the mysql, python or software update in your server where MySQL is running?

2. What is python version and pymysql version installed in the MySQL server?

3. If possible, please share the agent logs as zip for analysis. 

Please reply to this thread, we are glad to help you to solve the Plugin monitor. 

Thanks,
Muralikrishnan
Product Manager
Like (0) Reply

  1. No updates
  2. Versions on Databases/Agent
    1. Python 3.8.10
    2. mysql  Ver 8.0.31 for Linux on x86_64 (MySQL Community Server - GPL)
  3. Logs attached as rar
Thanks for helping with this.
Attachments
logs.rar
Size: 17362.36 KB
Like (0) Reply

Hi Auxilium,


Thanks for your patience.


After analysing the logs, we suspect that Python path given in the mysql_monitoring.py was not correct. Due to that, Site24x7LinuxAgent, couldn't able to execute the plugin successfully and thrown the below error.

  1. mysql_monitoring.py 2023-01-12 16:34:53,679   Worker 3,  plugin out - {'result': False, 'timedout': False, 'error': '/bin/sh: 1: Syntax error: "(" unexpected\n', 'exit_code': 2} | error out - {'status': 0, 'msg': '/bin/sh: 1: Syntax error: "(" unexpected\n'}

To solve this issue, please follow the below steps.

1. Open the terminal, execute command "which python3". It will give result of python3 path.

2. Copy the path, open and edit the mysql_monitoring.py, in the first line of the script with shebang character "#!" replace the path with copied one. 


Eg : #!/usr/local/bin/python3


Once done, please wait for next data collection the plugin will be shown in the Site24x7 web client. To navigate Site24x7 portal -> Server -> Plugin Integration -> Check your MySQL monitor.


Suppose if there is no change in python3 path, for further analysis please execute the mysql_monitoring script manually as below format. This format is exactly how our Site24x7LinuxAgent executes the plugin, hence it will be helpful find exact error. 


./mysql_monitoring.py --host=“<hostname>“ --port="3306" --username="<username>" --password="<password>"


Note: The parameter should be same as configuration given in mysql_monitoring.cfg. 

Please post this script output in the community thread. We will help to analyse the issue. 


Regards,

Muralikrishnan

Product Manager

Site24x7


Like (0) Reply

Thanks for responding.

Python3 Path
  1. /opt/site24x7/monagent/plugins/mysql_monitoring$ which python3
  2. /usr/bin/python3
Cat output (only first line shown)
  1. /opt/site24x7/monagent/plugins/mysql_monitoring$ sudo cat mysql_monitoring.py
  2. #!/usr/bin/python3
So, running the script like "./mysql_monitoring..." outputs "-bash: ./mysql_monitoring.py: Permission denied". Running chmod +x mysql_monitoring.py the retrying results in:
  1. /usr/bin/python3: can't open file './mysql_monitoring.py': [Errno 13] Permission denied
Running it with "sudo python3..." results with
  1. /opt/site24x7/monagent/plugins/mysql_monitoring$ sudo python3 mysql_monitoring.py --host="******" --port="3306" --username="******" --password="*****"
  2. {
  3.     "aborted_clients": 196.0,
  4.     "aborted_connects": 798.0,
  5.     "application_queries": 227216274.0,
  6.     "applog": {
  7.         "logs_enabled": false
  8.     },
  9.     "blocks_not_flushed": 0.0,
  10.     "buffer_pool_pages_data": 1335054.0,
  11.     "buffer_pool_pages_dirty": 0.0,
  12.     "buffer_pool_pages_flushed": 95754693.0,
  13.     "buffer_pool_pages_free": 11100850.0,
  14.     "buffer_pool_pages_total": 12451840.0,
  15.     "buffer_pool_read_ahead": 188.0,
  16.     "buffer_pool_read_ahead_evicted": 0.0,
  17.     "buffer_pool_read_ahead_rnd": 0.0,
  18.     "buffer_pool_read_requests": 9412496811.0,
  19.     "buffer_pool_reads": 867169.0,
  20.     "buffer_pool_wait_free": 0.0,
  21.     "buffer_pool_write_requests": 3404102337.0,
  22.     "cached": 78.0,
  23.     "client_queries": 114663717.0,
  24.     "com_delete": 837494.0,
  25.     "com_insert": 22176798.0,
  26.     "com_rollback": 141964.0,
  27.     "com_update": 28832920.0,
  28.     "commit": 59219202.0,
  29.     "connected": 3.0,
  30.     "connection_errors_max_connections": 0.0,
  31.     "connection_usage": 0,
  32.     "created": 81.0,
  33.     "data_fsyncs": 193008294.0,
  34.     "data_length": 0,
  35.     "data_pending_fsyncs": 7640.0,
  36.     "data_pending_reads": 0.0,
  37.     "data_pending_writes": 0.0,
  38.     "data_reads": 912572.0,
  39.     "data_writes": 430637391.0,
  40.     "delete_multi": 0.0,
  41.     "disk_tables": 1110912.0,
  42.     "free_blocks": 0,
  43.     "free_memory": 0,
  44.     "full_join": 7588630.0,
  45.     "full_range_join": 0.0,
  46.     "handler_delete": 194630007.0,
  47.     "handler_rollback": 142036.0,
  48.     "handler_update": 48334612.0,
  49.     "handler_write": 347703094.0,
  50.     "heartbeat_required": "true",
  51.     "hits": 0,
  52.     "in_cache": 0,
  53.     "index_length": 0,
  54.     "insert_select": 0.0,
  55.     "inserts": 0,
  56.     "key_reads": 0.0,
  57.     "key_writes": 0.0,
  58.     "log_waits": 3554.0,
  59.     "log_write_requests": 2636084873.0,
  60.     "log_writes": 333052184.0,
  61.     "lowmem_prunes": 0,
  62.     "max_connections": 20480.0,
  63.     "max_data_length": 0,
  64.     "max_execution_time_exceeded": 0.0,
  65.     "max_used_connections": 92.0,
  66.     "merge_passes": 0.0,
  67.     "mysql_node_type": "Master",
  68.     "not_cached": 0,
  69.     "open_cache_hits": 336782017.0,
  70.     "open_cache_misses": 13678.0,
  71.     "open_cache_overflows": 1902.0,
  72.     "open_files": 31.0,
  73.     "open_files_usage": 0.002956390380859375,
  74.     "open_tables": 6379.0,
  75.     "os_log_fsyncs": 135622696.0,
  76.     "os_log_pending_fsyncs": 0.0,
  77.     "os_log_pending_writes": 0.0,
  78.     "os_log_written": 253805127680.0,
  79.     "pages_created": 3758934.0,
  80.     "pages_read": 908886.0,
  81.     "pages_written": 95754816.0,
  82.     "plugin_version": "3",
  83.     "prepared_stmt_count": 0.0,
  84.     "range": 0.0,
  85.     "range_check": 0.0,
  86.     "read_first": 58079045.0,
  87.     "read_key": 748834925.0,
  88.     "read_requests": 0.0,
  89.     "read_rnd": 257687939.0,
  90.     "read_rnd_next": 3704269399.0,
  91.     "reads": 0,
  92.     "received": 19295192604.0,
  93.     "replace_select": 0.0,
  94.     "row_length": 0,
  95.     "row_lock_time_avg": 0.0,
  96.     "row_lock_waits": 0.0,
  97.     "rows": 15154024.0,
  98.     "rows_count": 0,
  99.     "rows_deleted": 194481437.0,
  100.     "rows_inserted": 264154037.0,
  101.     "rows_read": 5456250067.0,
  102.     "rows_updated": 48052880.0,
  103.     "running": 0,
  104.     "scan": 2166064.0,
  105.     "select": 66020657.0,
  106.     "select_range": 0.0,
  107.     "select_scan": 74333740.0,
  108.     "sent": 33596630493.0,
  109.     "slave_running": 1,
  110.     "slow_queries": 0.0,
  111.     "table_locks_waited": 0.0,
  112.     "tmp_files": 151.0,
  113.     "tmp_tables": 43866226.0,
  114.     "total_blocks": 0,
  115.     "transactions": 59361166.0,
  116.     "units": {
  117.         "connection_usage": "%",
  118.         "data_length": "bytes",
  119.         "free_memory": "bytes",
  120.         "index_length": "bytes",
  121.         "max_data_length": "bytes",
  122.         "open_files_usage": "%",
  123.         "os_log_written": "bytes",
  124.         "received": "bytes",
  125.         "relay_log_space": "bytes",
  126.         "row_count": "units",
  127.         "row_length": "bytes",
  128.         "row_lock_time_avg": "ms",
  129.         "seconds_behind_master": "seconds",
  130.         "sent": "bytes",
  131.         "uptime": "seconds"
  132.     },
  133.     "update_multi": 0.0,
  134.     "uptime": 3370304.0,
  135.     "version": "8.0.31",
  136.     "write_requests": 0.0,
  137.     "writes": 51847212.0
  138. }

Like (0) Reply

Hi Auxilium,

Thanks for your response.

Could you please check the following in the SIte24x7 web client?

To see the plugin monitor, login to your Site24x7 account.

Navigate to Server > click the respective Server monitor > Plugin Integrations > click mysql_monitoring.py.

This will take you to the MySQL monitoring details page where you will be able to see the metrics.

If the mysql_monitoring.py monitor doesn't show any data, please click the Reregister Plugins button to resume the data collection of the plugin. On the next data collection event, you will be able to see the data.



Please let us know if you were able to troubleshoot and if you face further issues.

Thank you,

Suraj D
Site24x7 Team
Like (0) Reply

Suraj,
I have followed your instructions, but these actions have been done repeatedly.
There is still no change after following your most recent instructions.
Like (0) Reply

Was this post helpful?