Fix potential Postgres insert failure (#306)
Some devices can contain random non-utf8 data in syscontact and syslocation, making the insert fail with "ERROR: invalid byte sequence for encoding "UTF8" on discovery. Work around this with Encode::decode.
This commit is contained in:
committed by
Oliver Gorwits
parent
96a3313fb7
commit
0737914af5
@@ -144,7 +144,7 @@ sub store_device {
|
||||
|
||||
my @properties = qw/
|
||||
snmp_ver
|
||||
description uptime contact name location
|
||||
description uptime name
|
||||
layers ports mac
|
||||
ps1_type ps2_type ps1_status ps2_status
|
||||
fan slots
|
||||
@@ -157,6 +157,9 @@ sub store_device {
|
||||
|
||||
$device->set_column( model => Encode::decode('UTF-8', $snmp->model) );
|
||||
$device->set_column( serial => Encode::decode('UTF-8', $snmp->serial) );
|
||||
$device->set_column( contact => Encode::decode('UTF-8', $snmp->contact) );
|
||||
$device->set_column( location => Encode::decode('UTF-8', $snmp->location) );
|
||||
|
||||
|
||||
$device->set_column( snmp_class => $snmp->class );
|
||||
$device->set_column( last_discover => \'now()' );
|
||||
|
||||
Reference in New Issue
Block a user