You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2022-07-16 01:07:04

khvalera
Member
Registered: 2022-07-01
Posts: 23

Problem with duplicate serial numbers of Samsung monitors

I have a lot of Samsung monitors during the inventory program, it turned out that many have the same serial numbers. I read on the forum that I was not the only one who faced such a problem sad, but I did not find an adequate solution. As an option, it comes to mind to use: additional-content = file.json. Maybe there are more interesting suggestions? Just in case, I decided to check the correctness of the work glpi, compiled the edid-decode package and checked it, it turned out the serial number in the edid-decode program and glpi-inventory do not match, then I wrote a small parse_edid script on perl Parse::EDID that uses glpi-inventory and surprise in the parse_edid script
and edid-decode matched, it turns out that there is a bug in glpi-inventory?

#!/usr/bin/perl

use strict;
use English qw(-no_match_vars);
use Parse::EDID;

sub read_file {
    my ($file) = @_;
    local $RS;
    open (my $handle, '<', $file) or die "Can't open $file: $ERRNO";
    my $content = <$handle>;
    close $handle;
    return $content;
}

my $edid = read_file("/sys/class/drm/card0-HDMI-A-1/edid");
my $parsed_edid = parse_edid($edid);

print("manufacturer_name: $parsed_edid->{manufacturer_name}\n");
print("product_code: $parsed_edid->{product_code}\n");
print("serial_number: $parsed_edid->{serial_number}\n");
print("week: $parsed_edid->{week}\n");
print("year: $parsed_edid->{year}\n");
print("edid_version: $parsed_edid->{edid_version}\n");
print("edid_revision: $parsed_edid->{edid_revision}\n");
print("video_input_definition: $parsed_edid->{video_input_definition}\n");
print("max_size_horizontal: $parsed_edid->{max_size_horizontal}\n");
print("max_size_vertical: $parsed_edid->{max_size_vertical}\n");
print("gamma: $parsed_edid->{gamma}\n");
print("feature_support: $parsed_edid->{feature_support}\n");
print("established_timings: $parsed_edid->{established_timings}\n");
print("standard_timings: $parsed_edid->{standard_timings}\n");
print("monitor_details: $parsed_edid->{monitor_details}\n");
print("extension_flag: $parsed_edid->{extension_flag}\n");
print("checksum: $parsed_edid->{checksum}\n");
print("EISA_ID: $parsed_edid->{EISA_ID}\n");
print("VertRefresh: $parsed_edid->{VertRefresh}\n");
print("HorizSync: $parsed_edid->{HorizSync}\n");
# glpi-inventory --partial=monitor
[warning] You should execute this task as super-user
[info] New partial inventory from test-2022-07-16-01-36-11 for local0
[error] Can't open file /proc/1/environ: Permission denied
{
   "action": "inventory",
   "content": {
      "bios": {
         "bdate": "2018-05-02",
         "bmanufacturer": "American Megatrends Inc.",
         "bversion": "M.A0",
         "mmanufacturer": "Micro-Star International Co., Ltd.",
         "mmodel": "B350 GAMING PLUS (MS-7A34)",
         "smanufacturer": "Micro-Star International Co., Ltd.",
         "smodel": "MS-7A34"
      },
      "hardware": {
         "chassis_type": "Desktop",
         "dns": "192.168.1.1",
         "name": "test",
         "vmsystem": "Physical",
         "workgroup": "test.lan"
      },
      "monitors": [
         {
            "base64": "AP///////wBMLRgMS01BMCEaAQOAMBt4KtERpVVVoCgNUFS/74BxT4HAgQCBgJUAqcCzAAEBAjqAGHE4LUBYLEUA3QwRAAAeAR0AclHQHiBuKFUA3QwRAAAeAAAA/QAySx5REQAKICAgICAgAAAA/ABTMjJFMzkwCiAgICAgAeYCAxrxRpAEHxMSAyMJBweDAQAAZgMMABAAgAEdALxS0B4guChVQN0MEQAAHowK0JAgQDEgDEBVAN0MEQAAGIwK0Iog4C0QED6WAN0MEQAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyA==",
            "caption": "S22E390",
            "description": "33/2016",
            "manufacturer": "Samsung Electric Company",
            "serial": "30414d4b"
         }
      ],
      "versionclient": "GLPI-Inventory_v1.4"
   },
   "deviceid": "test-2022-07-16-01-36-11",
   "itemtype": "Computer",
   "partial": true
}
# ./parse_edid
manufacturer_name: SAM
product_code: 3096
serial_number: 809585995
week: 33
year: 2016
edid_version: 1
edid_revision: 3
video_input_definition: HASH(0x563ca5b81210)
max_size_horizontal: 47.7
max_size_vertical: 26.8
gamma: 120
feature_support: HASH(0x563ca5a794a8)
established_timings: ARRAY(0x563ca5b80240)
standard_timings: ARRAY(0x563ca5b81108)
monitor_details: 
extension_flag: 1
checksum: 230
EISA_ID: SAM0c18
VertRefresh: 50-75
HorizSync: 30-81
# edid-decode /sys/class/drm/card0-HDMI-A-1/edid
edid-decode (hex):

00 ff ff ff ff ff ff 00 4c 2d 18 0c 4b 4d 41 30
02 1c 01 03 80 30 1b 78 2a d1 11 a5 55 55 a0 28
0d 50 54 bf ef 80 71 4f 81 c0 81 00 81 80 95 00
a9 c0 b3 00 01 01 02 3a 80 18 71 38 2d 40 58 2c
45 00 dd 0c 11 00 00 1e 01 1d 00 72 51 d0 1e 20
6e 28 55 00 dd 0c 11 00 00 1e 00 00 00 fd 00 32
4b 1e 51 11 00 0a 20 20 20 20 20 20 00 00 00 fc
00 53 32 32 45 33 39 30 0a 20 20 20 20 20 01 03

02 03 1a f1 46 90 04 1f 13 12 03 23 09 07 07 83
01 00 00 66 03 0c 00 10 00 80 01 1d 00 bc 52 d0
1e 20 b8 28 55 40 dd 0c 11 00 00 1e 8c 0a d0 90
20 40 31 20 0c 40 55 00 dd 0c 11 00 00 18 8c 0a
d0 8a 20 e0 2d 10 10 3e 96 00 dd 0c 11 00 00 18
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c8

----------------

Block 0, Base EDID:
  EDID Structure Version & Revision: 1.3
  Vendor & Product Identification:
    Manufacturer: SAM
    Model: 3096
    Serial Number: 809585995
    Made in: week 2 of 2018
  Basic Display Parameters & Features:
    Digital display
    Maximum image size: 48 cm x 27 cm
    Gamma: 2.20
    DPMS levels: Off
    RGB color display
    First detailed timing is the preferred timing
  Color Characteristics:
    Red  : 0.6474, 0.3330
    Green: 0.3320, 0.6259
    Blue : 0.1562, 0.0517
    White: 0.3125, 0.3291

Offline

#2 2022-07-16 01:10:20

khvalera
Member
Registered: 2022-07-01
Posts: 23

Re: Problem with duplicate serial numbers of Samsung monitors

On all monitors of the same model, all data is identical, only the checksum value is different

Offline

#3 2022-07-16 23:49:19

khvalera
Member
Registered: 2022-07-01
Posts: 23

Re: Problem with duplicate serial numbers of Samsung monitors

Unfortunately for the additional-content parameter, the following code does not work correctly:

{
    "content": {
      "monitors": [
         {
            "serial": "123"
         }
      ]
      }
}

I do not understand how to overcome the problem with duplicates sad

Does anyone have any thoughts?

Offline

#4 2022-07-19 16:59:21

ComLu
Member
Registered: 2020-01-28
Posts: 65

Re: Problem with duplicate serial numbers of Samsung monitors

is this the same problem?
forum.glpi-project.org/viewtopic.php?id=280010

Offline

#5 2022-07-21 16:14:49

khvalera
Member
Registered: 2022-07-01
Posts: 23

Re: Problem with duplicate serial numbers of Samsung monitors

ComLu wrote:

is this the same problem?
forum.glpi-project.org/viewtopic.php?id=280010

I read this before, there is no answer here how to fix the problem

Offline

#6 2022-07-21 16:20:14

khvalera
Member
Registered: 2022-07-01
Posts: 23

Re: Problem with duplicate serial numbers of Samsung monitors

This is why glpi for monitors gets an invalid serial number:
Screen.pm

 
   # There are two different serial numbers in EDID
    # - a mandatory 4 bytes numeric value
    # - an optional 13 bytes ASCII value
    # We use the ASCII value if present, the numeric value as an hex string
    # unless for a few list of known exceptions deserving specific handling
    # References:
    # http://forge.fusioninventory.org/issues/1607
    # http://forge.fusioninventory.org/issues/1614
    if ($self->{edid}->{serial_number2} && $self->{edid}->{serial_number2}->[0]) {
        $self->{_serial} = $self->{edid}->{serial_number2}->[0];
    } else {
        $self->{_serial} = sprintf("%08x", $self->{edid}->{serial_number});
    }

why the code is converted I can not understand, because the links do not work.

Offline

#7 2022-07-21 17:36:12

khvalera
Member
Registered: 2022-07-01
Posts: 23

Re: Problem with duplicate serial numbers of Samsung monitors

if the serial number of the monitor is still displayed incorrectly, I suggest adding checksum to the serial number

--- a/lib/GLPI/Agent/Tools/Screen.pm<-->2022-07-01 12:21:44.000000000 +0300
+++ b/lib/GLPI/Agent/Tools/Screen.pm<-->2022-07-21 18:21:57.332275628 +0300
@@ -29,7 +29,7 @@
     if ($self->{edid}->{serial_number2} && $self->{edid}->{serial_number2}->[0]) {
         $self->{_serial} = $self->{edid}->{serial_number2}->[0];
     } else {
-        $self->{_serial} = sprintf("%08x", $self->{edid}->{serial_number});
+        $self->{_serial} = sprintf("%08x", $self->{edid}->{serial_number} . $self->{edid}->{checksum});
     }
.
     # Setup manufacturer

Offline

#8 2022-08-05 14:42:54

gbougard
Moderator
From: Montpellier, France
Registered: 2021-07-21
Posts: 537
Website

Re: Problem with duplicate serial numbers of Samsung monitors

Hi,

"30414d4b" is indeed "809585995" but in hexadecimal. The problem here is still Samsung does many wrong things with their serial. We still have some logic to compute Samsung monitor serial numbers for some specific models (see GLPI/Agent/Tools/Screen/Samsung.pm file).

SAM0c18 is not supported by this file. I can add a third rule in the Samsung.pm file to return the decimal integer for such model. Do you have other models with the same problem ?

To override using additional-content option, I think you should have put all the expected content as the monitors node is a list:

{
    "content": {
      "monitors": [
         {
            "caption": "S22E390",
            "description": "33/2016",
            "manufacturer": "Samsung Electric Company",
            "serial": "809585995"
         }
      ]
      }
}

GLPI-Agent developer from Teclib' and GLPI-Network team
Previously FusionInventory-Agent maintainer

Offline

#9 2022-08-05 14:49:14

gbougard
Moderator
From: Montpellier, France
Registered: 2021-07-21
Posts: 537
Website

Re: Problem with duplicate serial numbers of Samsung monitors

Sinon, voici le patch que je vais plutôt appliquer sur Samsung.pm:

diff --git a/lib/GLPI/Agent/Tools/Screen/Samsung.pm b/lib/GLPI/Agent/Tools/Screen/Samsung.pm
index fbe979886..56905d29f 100644
--- a/lib/GLPI/Agent/Tools/Screen/Samsung.pm
+++ b/lib/GLPI/Agent/Tools/Screen/Samsung.pm
@@ -9,6 +9,8 @@ use parent 'GLPI::Agent::Tools::Screen';
 my $eisa_id_match = qr/0572|0694|06b9|0833|0835|0978|09c6|09c7|0b66|0bc9|0c7b|0ca3|0ca5|0d1a|0e0f|0e1e/ ;
 # For this model, prefix is in reverse order
 my $eisa_id_match_2 = qr/0e5a$/ ;
+# For this model, the serial should be a decimal, not in hexadecimal
+my $eisa_id_match_3 = qr/0c18$/ ;
 
 sub serial {
     my ($self) = @_;
@@ -16,6 +18,7 @@ sub serial {
     # Revert serial and altserial when eisa_id matches
     return $self->_altserial if ($self->eisa_id =~ $eisa_id_match);
     return $self->_altserial_2 if ($self->eisa_id =~ $eisa_id_match_2);
+    return $self->_altserial_3 if ($self->eisa_id =~ $eisa_id_match_3);
 
     return $self->{_serial};
 }
@@ -60,4 +63,10 @@ sub _altserial_2 {
         $serial2 ;
 }
 
+sub _altserial_3 {
+    my ($self) = @_;
+
+    return $self->{edid}->{serial_number};
+}
+
 1;

GLPI-Agent developer from Teclib' and GLPI-Network team
Previously FusionInventory-Agent maintainer

Offline

#10 2022-08-08 10:50:49

MarvinKen
Banned
From: Bulgaria
Registered: 2019-06-30
Posts: 7

Re: Problem with duplicate serial numbers of Samsung monitors

I am using mc2xml with schedules direct.  It does not have the format of s00e00.  I know this works for the TV section but does it still work for the recordings page.

Offline

Board footer

Powered by FluxBB