Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python.d postgres unhandled exception #3614

Closed
peter92427 opened this issue Apr 9, 2018 · 22 comments · Fixed by #3621
Closed

Python.d postgres unhandled exception #3614

peter92427 opened this issue Apr 9, 2018 · 22 comments · Fixed by #3621
Labels
area/collectors Everything related to data collection collectors/python.d

Comments

@peter92427
Copy link

Hi, i'm hitting this error no matter what i setup in configuration. My system is Centos7, Python v 2.7, Netdata latest static binary version.

python.d ERROR: postgres: tcp: update() unhandled exception: int() argument must be a string or a number, not 'NoneType'

postgres.conf:

tcp:
    name     : 'local'
    database : 'postgres'
    user     : 'netdata'
    password : 'netdata'
    host     : 'localhost'
    port     : 5432
@ilyam8
Copy link
Member

ilyam8 commented Apr 9, 2018

hello

sudo su -s /bin/bash netdata
/usr/libexec/netdata/plugins.d/python.d.plugin 1 debug trace postgres

@peter92427
Copy link
Author

peter92427 commented Apr 10, 2018

sudo su -s /bin/bash netdata
bash-4.2$ /opt/netdata/usr/libexec/netdata/plugins.d/python.d.plugin 1 debug postgres
2018-04-10 06:52:24: python.d INFO: plugin: main: Using python 2
2018-04-10 06:52:25: python.d DEBUG: plugin: main: module load source: 'postgres' => [OK]
2018-04-10 06:52:25: python.d DEBUG: plugin: main: module load config: 'postgres' => [OK]
2018-04-10 06:52:25: python.d DEBUG: plugin: main: job initialization: 'postgres tcp' => ['OK']
2018-04-10 06:52:25: python.d DEBUG: plugin: main: job initialization: 'postgres tcpipv4' => ['OK']
2018-04-10 06:52:25: python.d DEBUG: plugin: main: module status: 'postgres' => [OK] (jobs: 2)
2018-04-10 06:52:25: python.d INFO: postgres: tcp: check() => [OK]
2018-04-10 06:52:25: python.d INFO: postgres: tcpipv4: check() => [DROPPED] (already served by another job)
CHART netdata.runtime_postgres_local '' 'Execution time for postgres_local' 'ms' 'python.d' netdata.pythond_runtime line 145000 1
DIMENSION run_time 'run time' absolute 1 1

2018-04-10 06:52:25: python.d DEBUG: postgres: tcp: create() => [OK] (charts: 75)
2018-04-10 06:52:25: python.d DEBUG: postgres: tcp: started, update frequency: 1, retries: 60
2018-04-10 06:52:25: python.d DEBUG: postgres: tcp: sleeping for 0.945709943771 to reach frequency of 1 sec
2018-04-10 06:52:26: python.d ERROR: postgres: tcp: update() unhandled exception: int() argument must be a string or a number, not 'NoneType'
2018-04-10 06:52:26: python.d DEBUG: postgres: tcp: update => [FAILED] (elapsed time: -, retries left: 59)
2018-04-10 06:52:26: python.d DEBUG: postgres: tcp: sleeping for 0.985641956329 to reach frequency of 1 sec
2018-04-10 06:52:27: python.d ERROR: postgres: tcp: update() unhandled exception: int() argument must be a string or a number, not 'NoneType'
2018-04-10 06:52:27: python.d DEBUG: postgres: tcp: update => [FAILED] (elapsed time: -, retries left: 58)
2018-04-10 06:52:27: python.d DEBUG: postgres: tcp: sleeping for 0.986407995224 to reach frequency of 1 sec
2018-04-10 06:52:28: python.d ERROR: postgres: tcp: update() unhandled exception: int() argument must be a string or a number, not 'NoneType'
2018-04-10 06:52:28: python.d DEBUG: postgres: tcp: update => [FAILED] (elapsed time: -, retries left: 57)
2018-04-10 06:52:28: python.d DEBUG: postgres: tcp: sleeping for 0.986704111099 to reach frequency of 1 sec

@peter92427
Copy link
Author

[root@tstsrv001 ~]# /opt/netdata/bin/netdata -v
netdata 1.10.0-18-gd453ba68_rolling

[root@tstsrv001 ~]# yum list installed python
Installed Packages
python.x86_64                                                                                2.7.5-48.el7
python-psycopg2.x86_64                                                                        2.7.4-1.rhel7

[root@tstsrv001 ~]# cat /etc/centos-release
CentOS Linux release 7.3.1611 (Core)

@ilyam8
Copy link
Member

ilyam8 commented Apr 10, 2018

please run it with trace flag

@peter92427
Copy link
Author

2018-04-10 07:44:30: python.d ERROR: postgres: tcp: update() unhandled exception: int() argument must be a string or a number, not 'NoneType'
2018-04-10 07:44:30: python.d ERROR: postgres: tcp: Traceback (most recent call last):
  File "/opt/netdata/usr/libexec/netdata/python.d/python_modules/bases/FrameworkServices/SimpleService.py", line 181, in run
    updated = self.update(interval=job.SINCE_UPDATE)
  File "/opt/netdata/usr/libexec/netdata/python.d/python_modules/bases/FrameworkServices/SimpleService.py", line 207, in update
    data = self.get_data()
  File "/opt/netdata/usr/libexec/netdata/python.d/python_modules/bases/FrameworkServices/SimpleService.py", line 259, in get_data
    return self._get_data()
  File "/opt/netdata/usr/libexec/netdata/python.d/postgres.chart.py", line 529, in _get_data
    self.query_stats_(cursor, query, metrics)
  File "/opt/netdata/usr/libexec/netdata/python.d/postgres.chart.py", line 554, in query_stats_
    self.data[dimension_id] = int(row[metric])
TypeError: int() argument must be a string or a number, not 'NoneType'

@ilyam8
Copy link
Member

ilyam8 commented Apr 10, 2018

thx
@anayrat
Looks like one of metrics is None
https://github.com/firehol/netdata/blob/master/python.d/postgres.chart.py#L554

Do you want to debug it? (what metric)
if this makes no sense we can just fix it (if row[metric] != None!)

@peter92427
Copy link
Author

Whatever would be the most universal solution for the plugin. If you think it would be valuable info we can debug further.

@ilyam8
Copy link
Member

ilyam8 commented Apr 10, 2018

Well, lets check what metric is None

Please change
https://github.com/firehol/netdata/blob/master/python.d/postgres.chart.py#L554

to

if row[metric] is None:
    self.debug("Row {0}\nMetric {1}".format(row, metric))
    continue
self.data[dimension_id] = int(row[metric])

edited

@peter92427
Copy link
Author

2018-04-10 12:16:34: python.d ERROR: postgres: tcp: update() unhandled exception: tuple index out of range
2018-04-10 12:16:34: python.d ERROR: postgres: tcp: Traceback (most recent call last):
  File "/opt/netdata/usr/libexec/netdata/python.d/python_modules/bases/FrameworkServices/SimpleService.py", line 181, in run
    updated = self.update(interval=job.SINCE_UPDATE)
  File "/opt/netdata/usr/libexec/netdata/python.d/python_modules/bases/FrameworkServices/SimpleService.py", line 207, in update
    data = self.get_data()
  File "/opt/netdata/usr/libexec/netdata/python.d/python_modules/bases/FrameworkServices/SimpleService.py", line 259, in get_data
    return self._get_data()
  File "/opt/netdata/usr/libexec/netdata/python.d/postgres.chart.py", line 529, in _get_data
    self.query_stats_(cursor, query, metrics)
  File "/opt/netdata/usr/libexec/netdata/python.d/postgres.chart.py", line 555, in query_stats_
    self.debug("Row {1}\nMetric {2}".format(row, metric))
IndexError: tuple index out of range

@ilyam8
Copy link
Member

ilyam8 commented Apr 10, 2018

@peter92427 ops, sorry, should be Row {0}\nMetric {1}, not Row {1}\nMetric {2} 😢

@peter92427
Copy link
Author

No worries. :) So, what are we searching for? I get loads of data now...

@ilyam8
Copy link
Member

ilyam8 commented Apr 10, 2018

self.debug("Row {0}\nMetric {1}".format(row, metric))

output

@peter92427
Copy link
Author

peter92427 commented Apr 10, 2018

I think I found something:

2018-04-10 12:41:00: python.d DEBUG: postgres: tcp: Row ['barman_receive_wal', Decimal('0'), Decimal('0'), Decimal('13928504'), None]
Metric replay_delta

@ilyam8
Copy link
Member

ilyam8 commented Apr 10, 2018

there must be two lines
Row ...
Metric ...

@peter92427
Copy link
Author

You're right, i've updated the previous comment.

@ilyam8
Copy link
Member

ilyam8 commented Apr 10, 2018

@peter92427
fixed in #3621

btw does it work after #3614 (comment) ?
Do you see it on dashboard?

@peter92427
Copy link
Author

Hi, i've updated to the latest code. Debug mode on cli runs fine now, however i do not see postgresql on dashboard.

@ilyam8
Copy link
Member

ilyam8 commented Apr 10, 2018

all erros in error.log

goto netdata log dir

  1. cp /dev/null error.log
  2. restart netdata.service
  3. grep postgres error.log

@peter92427
Copy link
Author

False alert, there were multiple netdata processes left from previous testing... The dashboard is now visible for the first time. :)
There are some messages in error log:

2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.db_stat_tuple_write' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.db_stat_temp_files' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.db_stat_connections' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.table_count' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.db_stat_blks' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.index_count' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.db_stat_temp_bytes' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.standby_delta' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.db_stat_transactions' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.table_size' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.db_stat_tuple_returned' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.replication_slot' was suppressed due to non updating
2018-04-10 13:58:31: python.d ERROR: postgres: tcp: chart 'postgres_local.index_size' was suppressed due to non updating

@ilyam8
Copy link
Member

ilyam8 commented Apr 10, 2018

...was suppressed due to non updating

that's ok

@peter92427
Copy link
Author

Allright, thanks for all the help and speedy response. :D Have a nice day!

@ktsaou
Copy link
Member

ktsaou commented Apr 10, 2018

merged it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/collectors Everything related to data collection collectors/python.d
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants