OCSのレポート画面で『Operating System』欄が『Linux』になる問題

CentOS6系だと『Operating System』欄が『Linux』になってしまう問題の対処法のメモです。


CentOS5系だと、
CentOS release 5.7 (Final)
と表示されます。


Fedoraでも
Fedora release 17 (Beefy Miracle)
と表示されます。

正しくCentOS6.2と表示されていない


どうも正しく表示させるには
redhat-lsb.x86_64
というパッケージが必要な模様です。


CentOS6.2にはこのredhat-lsbがインストールされていませんでした。
正しく表示されているCentOS5.7ではredhat-lsbが入っていましたが、
Fedoraではインストールされていませんでした。

Fedoraではどうやら、↓ここで

/usr/share/perl5/vendor_perl/Ocsinventory/Agent/Backend/OS/Linux/Distro/NonLSB/Fedora.pm

/etc/redhat-releaseを見るように変更をかけている模様です。

対処法1

同じように

/usr/share/perl5/vendor_perl/Ocsinventory/Agent/Backend/OS/Linux/Distro/NonLSB/CentOS.pm

を作ってやったところ正しく表示されるようになりました。

package Ocsinventory::Agent::Backend::OS::Linux::Distro::NonLSB::CentOS;
use strict;

sub check {-f "/etc/centos-release"}

#####
sub findRelease {
  my $v;

  open V, "</etc/centos-release" or warn;
  chomp ($v=<V>);
  close V;
  $v;
}

sub run {
  my $params = shift;
  my $inventory = $params->{inventory};

  my $OSComment;
  chomp($OSComment =`uname -v`);

  $inventory->setHardware({
      OSNAME => findRelease(),
      OSCOMMENTS => "$OSComment"
    });
}



1;


するとちゃんと
CentOS release 6.2 (Final)
と表示されました。

正しくCentOS6.2と表示されました!



対処法2

↑のスクリプトをおかないパターンで
redhat-lsb.x86_64
をインストールしてやると、ちゃんと
CentOS release 6.2 (Final)
と表示されました。


このredhat-lsb.x86_64をインストールすることで、
lsb_releaseというコマンドが使えるようになります。

lsb_releaseコマンドのヘルプ

FSG lsb_release v2.0 prints certain LSB (Linux Standard Base) and
Distribution information.

Usage: lsb_release [OPTION]...
With no OPTION specified defaults to -v.

Options:
  -v, --version
    Display the version of the LSB specification against which the distribution is compliant.
  -i, --id
    Display the string id of the distributor.
  -d, --description
    Display the single line text description of the distribution.
  -r, --release
    Display the release number of the distribution.
  -c, --codename
    Display the codename according to the distribution release.
  -a, --all
    Display all of the above information.
  -s, --short
    Use short output format for information requested by other options (or version if none).
  -h, --help
    Display this message.


コマンドの表示結果

[root@test ~]# lsb_release -a
LSB Version:     :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:     CentOS
Description:     CentOS release 6.2 (Final)
Release:     6.2
Codename:     Final
[root@test ~]#



redhat-lsb.x86_64をインストールしようとするとけっこう依存が多く色んなパッケージが入ります。

========================================================================================================================
 Package                               Arch                Version                            Repository           Size
========================================================================================================================
Installing:
 redhat-lsb                            x86_64              4.0-7.el6.centos                   base                 11 k
Installing for dependencies:
 cdparanoia-libs                       x86_64              10.2-5.1.el6                       base                 47 k
 cups                                  x86_64              1:1.4.2-50.el6_4.4                 update              2.3 M
 cvs                                   x86_64              1.11.23-15.el6                     base                711 k
 foomatic                              x86_64              4.0.4-1.el6_1.1                    base                251 k
 foomatic-db                           noarch              4.0-7.20091126.el6                 base                980 k
 foomatic-db-filesystem                noarch              4.0-7.20091126.el6                 base                4.4 k
 foomatic-db-ppds                      noarch              4.0-7.20091126.el6                 base                 19 M
 gettext                               x86_64              0.17-16.el6                        base                1.8 M
 ghostscript                           x86_64              8.70-15.el6_4.1                    update              4.4 M
 ghostscript-fonts                     noarch              5.50-23.1.el6                      base                751 k
 gstreamer                             x86_64              0.10.29-1.el6                      base                764 k
 gstreamer-plugins-base                x86_64              0.10.29-2.el6                      base                940 k
 gstreamer-tools                       x86_64              0.10.29-1.el6                      base                 23 k
 iso-codes                             noarch              3.16-2.el6                         base                2.4 M
 lcms-libs                             x86_64              1.19-1.el6                         base                100 k
 libXfont                              x86_64              1.4.5-2.el6                        base                136 k
 libXtst                               x86_64              1.2.1-2.el6                        base                 29 k
 libXv                                 x86_64              1.0.7-2.el6                        base                 24 k
 libXxf86vm                            x86_64              1.1.2-2.el6                        base                 22 k
 libfontenc                            x86_64              1.0.5-2.el6                        base                 24 k
 libgudev1                             x86_64              147-2.46.el6                       base                 60 k
 libmng                                x86_64              1.0.10-4.1.el6                     base                165 k
 libogg                                x86_64              2:1.1.4-2.1.el6                    base                 21 k
 liboil                                x86_64              0.3.16-4.1.el6                     base                121 k
 libtheora                             x86_64              1:1.1.0-2.el6                      base                129 k
 libvisual                             x86_64              0.4.0-9.1.el6                      base                135 k
 libvorbis                             x86_64              1:1.2.3-4.el6_2.1                  base                168 k
 make                                  x86_64              1:3.81-20.el6                      base                389 k
 mesa-dri-drivers                      x86_64              9.0-0.8.el6_4.3                    update              4.1 M
 mesa-dri-filesystem                   x86_64              9.0-0.8.el6_4.3                    update               45 k
 mesa-dri1-drivers                     x86_64              7.11-8.el6                         base                3.8 M
 mesa-libGL                            x86_64              9.0-0.8.el6_4.3                    update              162 k
 mesa-libGLU                           x86_64              9.0-0.8.el6_4.3                    update              225 k
 openjpeg-libs                         x86_64              1.3-9.el6_3                        base                 59 k
 patch                                 x86_64              2.6-6.el6                          base                 90 k
 pax                                   x86_64              3.4-10.1.el6                       base                 69 k
 perl-CGI                              x86_64              3.51-131.el6_4                     update              208 k
 perl-ExtUtils-MakeMaker               x86_64              6.55-131.el6_4                     update              292 k
 perl-ExtUtils-ParseXS                 x86_64              1:2.2003.0-131.el6_4               update               44 k
 perl-Test-Harness                     x86_64              3.17-131.el6_4                     update              230 k
 perl-Test-Simple                      x86_64              0.92-131.el6_4                     update              111 k
 perl-devel                            x86_64              4:5.10.1-131.el6_4                 update              421 k
 phonon-backend-gstreamer              x86_64              1:4.6.2-26.el6_4                   update              126 k
 poppler                               x86_64              0.12.4-3.el6_0.1                   base                557 k
 poppler-data                          noarch              0.4.0-1.el6                        base                2.2 M
 poppler-utils                         x86_64              0.12.4-3.el6_0.1                   base                 73 k
 portreserve                           x86_64              0.0.4-9.el6                        base                 23 k
 qt                                    x86_64              1:4.6.2-26.el6_4                   update              3.9 M
 qt-sqlite                             x86_64              1:4.6.2-26.el6_4                   update               51 k
 qt-x11                                x86_64              1:4.6.2-26.el6_4                   update               12 M
 qt3                                   x86_64              3.3.8b-30.el6                      base                3.5 M
 redhat-lsb-compat                     x86_64              4.0-7.el6.centos                   base                 10 k
 redhat-lsb-core                       x86_64              4.0-7.el6.centos                   base                 25 k
 redhat-lsb-graphics                   x86_64              4.0-7.el6.centos                   base                 13 k
 redhat-lsb-printing                   x86_64              4.0-7.el6.centos                   base                 11 k
 urw-fonts                             noarch              2.4-10.el6                         base                3.1 M
 xml-common                            noarch              0.6.3-32.el6                       base                9.5 k
 xorg-x11-font-utils                   x86_64              1:7.2-11.el6                       base                 75 k

Transaction Summary
========================================================================================================================
Install      59 Package(s)

Total download size: 72 M
Installed size: 202 M


[root@test ~]# rpm -ql redhat-lsb-core-4.0-7.el6.centos.x86_64
/bin/redhat_lsb_init
/etc/lsb-release
/etc/lsb-release.d
/etc/lsb-release.d/base-4.0-amd64
/etc/lsb-release.d/base-4.0-noarch
/etc/lsb-release.d/core-4.0-amd64
/etc/lsb-release.d/core-4.0-noarch
/etc/redhat-lsb
/etc/redhat-lsb/lsb_killproc
/etc/redhat-lsb/lsb_log_message
/etc/redhat-lsb/lsb_pidofproc
/etc/redhat-lsb/lsb_start_daemon
/lib/lsb
/lib/lsb/init-functions
/lib64/ld-lsb-x86-64.so.3
/usr/bin/lsb_release
/usr/lib/lsb
/usr/lib/lsb/install_initd
/usr/lib/lsb/remove_initd
/usr/sbin/redhat_lsb_trigger.x86_64
/usr/share/man/man1/lsb_release.1.gz