From a82d81eb375bb40bcf4cf31ff8a56e0b7cd4bba9 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Thu, 10 Jun 2010 19:46:55 +0000 Subject: [PATCH] add device serial number into database, for devices not having entity mib git-svn-id: http://www.observium.org/svn/observer/trunk@1133 61d68cd4-352d-0410-923a-c4978735b2b8 --- database-update.sql | 1 + poll-device.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/database-update.sql b/database-update.sql index c2e76dc4ca..abf621e766 100644 --- a/database-update.sql +++ b/database-update.sql @@ -9,3 +9,4 @@ ALTER TABLE `ports` ADD `port_descr_type` VARCHAR( 32 ) NULL DEFAULT NULL AFTE CREATE TABLE `frequency` ( `freq_id` int(11) NOT NULL auto_increment, `device_id` int(11) NOT NULL default '0', `freq_oid` varchar(64) NOT NULL, `freq_index` varchar(8) NOT NULL, `freq_type` varchar(32) NOT NULL, `freq_descr` varchar(32) NOT NULL default '', `freq_precision` int(11) NOT NULL default '1', `freq_current` float default NULL, `freq_limit` float default NULL, `freq_limit_low` float default NULL, PRIMARY KEY (`freq_id`), KEY `freq_host` (`device_id`)) ENGINE=MyISAM AUTO_INCREMENT=189 DEFAULT CHARSET=latin1; ALTER TABLE `temperature` CHANGE `temp_index` `temp_index` int(11) NOT NULL; CREATE TABLE `current` ( `current_id` int(11) NOT NULL auto_increment, `device_id` int(11) NOT NULL default '0', `current_oid` varchar(64) NOT NULL, `current_index` varchar(8) NOT NULL, `current_type` varchar(32) NOT NULL, `current_descr` varchar(32) NOT NULL default '', `current_precision` int(11) NOT NULL default '1', `current_current` float default NULL, `current_limit` float default NULL, `current_limit_warn` float default NULL, `current_limit_low` float default NULL, PRIMARY KEY (`current_id`), KEY `current_host` (`device_id`)) ENGINE=MyISAM AUTO_INCREMENT=189 DEFAULT CHARSET=latin1; +ALTER TABLE `devices` ADD `serial` text default NULL; diff --git a/poll-device.php b/poll-device.php index 9c15d742ac..598ad62cc5 100755 --- a/poll-device.php +++ b/poll-device.php @@ -175,6 +175,12 @@ while ($device = mysql_fetch_array($device_query)) { unset( $update ) ; unset( $seperator) ; + if ( $serial && $serial != $device['serial'] ) { + $poll_update .= $poll_separator . "`serial` = '".mres($serial)."'"; + $poll_separator = ", "; + eventlog("Serial -> $serial", $device['device_id']); + } + if ( $sysContact && $sysContact != $device['sysContact'] ) { $poll_update .= $poll_separator . "`sysContact` = '".mres($sysContact)."'"; $poll_separator = ", ";