WhatsUp은 DB를 MSSQL 을 사용한다.
php환경에서 해당 데이터를 가져와서 활용하기 위해서는 PHP 에 FREE TDS 모듈을 이용해야 한다.
[root@localhost src]# wget http://pkgs.fedoraproject.org/repo/pkgs/freetds/freetds-0.82.tar.gz/3df6b2e83fd420e90f1becbd1162990a/freetds-0.82.tar.gz
[root@localhost src]# tar xvzf freetds-0.82.tar.gz
[root@localhost src]# cd freetds-0.82
[root@localhost freetds-0.82]# ./configure --prefix=/usr/local/freetds \
--with-tdsver=8.0 \
--enable-msdblib \
--enable-dbmfix \
--enable-shared \
--enable-static
--with-tdsver=8.0 \
--enable-msdblib \
--enable-dbmfix \
--enable-shared \
--enable-static
[root@localhost freetds-0.82]# make && make install
[root@localhost freetds-0.82]# vi /usr/local/freetds/etc/freetds.conf
----------------------------------------------------------------------------
[global]...
client charset = CP949 ; 어떤 시스템은 이 설정내용을 인식하지 못한다. 못하면 빼버린다.
...
----------------------------------------------------------------------------
php 설치 할때 -with-mssql=/usr/local/freetds
-----------------------------------------------------------------------------
연동 테스트
<?
$hostname = "123.123.123.1231433"; // 서버 ip
$username = "cy"; //db 접근 user
$password = "123123"; //db 접근 user password
$dbname = "WhatsUp"; //DB 이름
$mscon=MSSQL_CONNECT($hostname, $username, $password) or DIE("DATABASE FAILED TO RESPOND.");
mssql_select_db($dbname, $mscon) or DIE("Table unavailable");
$sql="select nDeviceID,sDisplayName,sStatus from Device where nWorstStateID like 10";
$result=mssql_query($sql, $mscon);
while ($row = mssql_fetch_row($result)) {
echo "<a target=blank href=http://test.com/NmConsole/Workspace/DeviceStatus/DeviceStatus.asp?nDeviceID=$row[0]>";
echo $row[1];
echo $row[2];
echo "</a><p>";
}
mssql_close($mscon);
?>
$hostname = "123.123.123.1231433"; // 서버 ip
$username = "cy"; //db 접근 user
$password = "123123"; //db 접근 user password
$dbname = "WhatsUp"; //DB 이름
$mscon=MSSQL_CONNECT($hostname, $username, $password) or DIE("DATABASE FAILED TO RESPOND.");
mssql_select_db($dbname, $mscon) or DIE("Table unavailable");
$sql="select nDeviceID,sDisplayName,sStatus from Device where nWorstStateID like 10";
$result=mssql_query($sql, $mscon);
while ($row = mssql_fetch_row($result)) {
echo "<a target=blank href=http://test.com/NmConsole/Workspace/DeviceStatus/DeviceStatus.asp?nDeviceID=$row[0]>";
echo $row[1];
echo $row[2];
echo "</a><p>";
}
mssql_close($mscon);
?>
반응형
'database > mysql' 카테고리의 다른 글
pt-table-checksum,sync 를 통한 mysql replication sync 체크 및 조절 (1) | 2016.06.05 |
---|---|
Mysql 5.7 replication (Master-Slave) on Centos7 (0) | 2016.06.04 |
centos7 mysql 5.6 install (0) | 2016.06.04 |
mysqldump 를 통한 mysql 백업,복구 (0) | 2016.05.23 |
XtraBackup install ,full backup (0) | 2016.05.14 |