2009年8月15日 @ 19:11時点の記事です。

パソコンがいっぱいで何が入ってるのかわからないので、会社で使っているQND(資産管理ツール)を導入してみようと。
QNDは有償なのでフリーでないかと探したところ、OCS Inventory NGとGLPIを発見。
OCS Inventory NG・・・デフォルトで日本語対応していないがエージェント機能があり、自動収集してきてくれる(QNDのエージェントと同等と思われる)。
Windows日本語版から資産を登録しようとすると日本語が文字化けを起こす。
GLPI・・・デフォルトで日本語対応しているが、エージェント機能が無い。 これらの長所(エージェント・日本語デフォルト)を組み合わせて使う事にする。
インストールはすぐできるので、後日記載。
OCS Inventory NGで、Windows日本語版から資産を登録しようとすると日本語が文字化けを起こすので、要修正。
忘れると色々と面倒くさいので、今のうちに記載しておく。

(1)OCS Inventory NGの修正(元:http://forums.ocsinventory-ng.org/viewtopic.php?id=603

/usr/lib/perl5/site_perl/5.8.8/Apache/Ocsinventory.pm
----------------------------------------------------------
  if(!$inflated){
    &_log(506,'handler','Compress stage');
    return &_end(APACHE_SERVER_ERROR);
  }
}
$CURRENT_CONTEXT{'DATA'} = \$inflated;
###追加開始############################
use Encode;
$inflated =~ s/encoding="ISO-8859-1"/encoding="Shift-JIS"/g;
Encode::from_to($inflated,'shiftjis','euc-jp');
Encode::from_to($inflated,'euc-jp','shiftjis');
###追加終了############################
##########################
# Parse the XML request
# Retrieving xml parsing options if needed &_get_xml_parser_opt( \%XML_PARSER_OPT ) unless %XML_PARSER_OPT;  ----------------------------------------------------------


(2)shift_jis対応(元:http://homepage3.nifty.com/hippo2000/perltips/xml/xmlenc.htm

・wgetでhttp://homepage3.nifty.com/hippo2000/perltips/xml/Encoding.tar.gzをダウンロードする。 
・圧縮ファイル内のEncoding/mkenc内のmkenc.plを/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/XML/Parser/Encodingsへコピーする。 
・perl mvenc.pl x-sjis-cp932 shift-jisを実行する。 
・[root@hanzou008 Encodings]# ls -ltr
合計 380
-rw-r--r-- 1 root root 18202 7月 27 2003 x-sjis-unicode.enc
-rw-r--r-- 1 root root 18202 7月 27 2003 x-sjis-jisx0221.enc
-rw-r--r-- 1 root root 18202 7月 27 2003 x-sjis-jdk117.enc
-rw-r--r-- 1 root root 20368 7月 27 2003 x-sjis-cp932.enc
-rw-r--r-- 1 root root 37890 7月 27 2003 x-euc-jp-unicode.enc
-rw-r--r-- 1 root root 37890 7月 27 2003 x-euc-jp-jisx0221.enc
-rw-r--r-- 1 root root 1072 7月 27 2003 windows-1250.enc
-rw-r--r-- 1 root root 1072 7月 27 2003 iso-8859-9.enc
-rw-r--r-- 1 root root 1072 7月 27 2003 iso-8859-8.enc
-rw-r--r-- 1 root root 1072 7月 27 2003 iso-8859-7.enc
-rw-r--r-- 1 root root 1072 7月 27 2003 iso-8859-5.enc
-rw-r--r-- 1 root root 1072 7月 27 2003 iso-8859-4.enc
-rw-r--r-- 1 root root 1072 7月 27 2003 iso-8859-3.enc
-rw-r--r-- 1 root root 1072 7月 27 2003 iso-8859-2.enc
-rw-r--r-- 1 root root 45802 7月 27 2003 euc-kr.enc
-rw-r--r-- 1 root root 40706 7月 27 2003 big5.enc
-rw-r--r-- 1 root root 1946 7月 27 2003 README
-rw-r--r-- 1 root root 4821 7月 27 2003 Japanese_Encodings.msg
-rw-r--r-- 1 root root 1072 7月 27 2003 windows-1252.enc
-rw-r--r-- 1 root root 1352 8月 15 18:18 mkenc.pl
-rw-r--r-- 1 root root 20368 8月 15 18:20 shift-jis.enc

(3)エージェントインストール済のWindows端末から

"C:\Program Files\OCS Inventory Agent\ocsinventory.exe" /SERVER:OCSInventoryNGサーバのIP /PNUM:OCSInventoryNGサーバへアクセスするためのポート番号 /NPO /DEBUGを実行。
これで文字化けせずに格納される。

(2009/08/15 20:52 以下追記)

GLPIへ連携したとき、文字化けを起こすので次の対策を行う。

  1. glpiインストールディレクトリ/inc配下のocsng.class.phpを変更する
    ---------------------------------------------------------------------
    if ($CFG_GLPI["ocs_mode"])
    {
      $data = getOcsConf($ID);
      $this->dbhost = $data["ocs_db_host"];
      $this->dbuser = $data["ocs_db_user"];
      $this->dbpassword = rawurldecode($data["ocs_db_passwd"]);
      $this->dbdefault = $data["ocs_db_name"];
      $this->dbenc="UTF-8";
      parent::__construct();
    }
    ---------------------------------------------------------------------

  2. ソフトウェアの文字化けを直す。
    glpiインストールディレクトリ/inc配下のdbmysql.class.phpを変更する
---------------------------------------------------------------------
function connect(){
  $this->connected=false;
  $this->dbh = @mysql_connect($this->dbhost, $this->dbuser, rawurldecode($this->dbpassword)) or $this->error = 1;
  if ($this->dbh){
    // connexion ok
    @mysql_query("SET NAMES '" . (isset($this->dbenc) ? $this->dbenc : "UTF-8") . "'",$this->dbh);
    $select= mysql_select_db($this->dbdefault) or $this->error = 1;
    if ($select){
      // select ok
      $this->connected=true;
    }else{
      // select wrong $this->connected=false;
    }
  } else { 
    // connexion wrong $this->connected=false;
  }
}
---------------------------------------------------------------------
※"utf8"で直す、と記載しているサイトがあるが、ダメ(文字化けを起こす)だった。

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-07-05 (火) 11:46:08 (2852d)