mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #521 from laf/issue-463-2
Fixing mysql_strict issues / errors
This commit is contained in:
@@ -47,7 +47,7 @@ CREATE TABLE IF NOT EXISTS `storage` ( `storage_id` int(11) NOT NULL AUTO_INCREM
|
||||
CREATE TABLE IF NOT EXISTS `syslog` ( `device_id` int(11) DEFAULT NULL, `facility` varchar(10) DEFAULT NULL, `priority` varchar(10) DEFAULT NULL, `level` varchar(10) DEFAULT NULL, `tag` varchar(10) DEFAULT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `program` varchar(32) DEFAULT NULL, `msg` text, `seq` bigint(20) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`seq`), KEY `datetime` (`timestamp`), KEY `device_id` (`device_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE IF NOT EXISTS `toner` ( `toner_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL DEFAULT '0', `toner_index` int(11) NOT NULL, `toner_type` varchar(64) NOT NULL, `toner_oid` varchar(64) NOT NULL, `toner_descr` varchar(32) NOT NULL DEFAULT '', `toner_capacity` int(11) NOT NULL DEFAULT '0', `toner_current` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`toner_id`), KEY `device_id` (`device_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE IF NOT EXISTS `ucd_diskio` ( `diskio_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `diskio_index` int(11) NOT NULL, `diskio_descr` varchar(32) CHARACTER SET latin1 NOT NULL, PRIMARY KEY (`diskio_id`), KEY `device_id` (`device_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
CREATE TABLE IF NOT EXISTS `users` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `username` char(30) NOT NULL, `password` varchar(34) DEFAULT NULL, `realname` varchar(64) NOT NULL, `email` varchar(64) NOT NULL, `descr` char(30) NOT NULL, `level` tinyint(4) NOT NULL DEFAULT '0', `can_modify_passwd` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (`user_id`), UNIQUE KEY `username` (`username`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE IF NOT EXISTS `users` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `username` char(30) NOT NULL, `password` varchar(34) DEFAULT NULL, `realname` varchar(64) NOT NULL, `email` varchar(64) NOT NULL, `descr` varchar(200) DEFAULT NULL, `level` tinyint(4) NOT NULL DEFAULT '0', `can_modify_passwd` tinyint(4) NOT NULL DEFAULT '1', PRIMARY KEY (`user_id`), UNIQUE KEY `username` (`username`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE IF NOT EXISTS `users_prefs` ( `user_id` int(16) NOT NULL, `pref` varchar(32) NOT NULL, `value` varchar(128) NOT NULL, PRIMARY KEY (`user_id`), UNIQUE KEY `user_id.pref` (`user_id`,`pref`), KEY `pref` (`pref`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE IF NOT EXISTS `vlans` ( `vlan_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) DEFAULT NULL, `vlan_vlan` int(11) DEFAULT NULL, `vlan_domain` text, `vlan_descr` text, PRIMARY KEY (`vlan_id`), KEY `device_id` (`device_id`,`vlan_vlan`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE IF NOT EXISTS `vminfo` ( `id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `vm_type` varchar(16) NOT NULL DEFAULT 'vmware', `vmwVmVMID` int(11) NOT NULL, `vmwVmDisplayName` varchar(128) NOT NULL, `vmwVmGuestOS` varchar(128) NOT NULL, `vmwVmMemSize` int(11) NOT NULL, `vmwVmCpus` int(11) NOT NULL, `vmwVmState` varchar(128) NOT NULL, PRIMARY KEY (`id`), KEY `device_id` (`device_id`), KEY `vmwVmVMID` (`vmwVmVMID`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
@@ -78,7 +78,7 @@ CREATE TABLE IF NOT EXISTS `perf_times` ( `type` varchar(8) NOT NULL, `doing`
|
||||
## 0.10.7.1
|
||||
CREATE TABLE IF NOT EXISTS `device_graphs` ( `device_id` int(11) NOT NULL, `graph` varchar(32) COLLATE utf8_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
CREATE TABLE IF NOT EXISTS `graph_types` ( `graph_type` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `graph_subtype` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `graph_section` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `graph_descr` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `graph_order` int(11) NOT NULL, KEY `graph_type` (`graph_type`), KEY `graph_subtype` (`graph_subtype`), KEY `graph_section` (`graph_section`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
INSERT INTO `graph_types` (`graph_type`, `graph_subtype`, `graph_section`, `graph_descr`, `graph_order`) VALUES('device', 'bits', 'netstats', 'Total Traffic', 0),('device', 'hr_users', 'system', 'Users Logged In', 0),('device', 'ucd_load', 'system', 'Load Averages', 0),('device', 'ucd_cpu', 'system', 'Detailed Processor Usage', 0),('device', 'ucd_memory', 'system', 'Detailed Memory Usage', 0),('device', 'netstat_tcp', 'netstats', 'TCP Statistics', 0),('device', 'netstat_icmp_info', 'netstats', 'ICMP Informational Statistics', 0),('device', 'netstat_icmp_stat', 'netstats', 'ICMP Statistics', 0),('device', 'netstat_ip', 'netstats', 'IP Statistics', 0),('device', 'netstat_ip_frag', 'netstats', 'IP Fragmentation Statistics', 0),('device', 'netstat_udp', 'netstats', 'UDP Statistics', 0),('device', 'netstat_snmp', 'netstats', 'SNMP Statistics', 0),('device', 'temperatures', 'system', 'Temperatures', 0),('device', 'mempools', 'system', 'Memory Pool Usage', 0),('device', 'processors', 'system', 'Processor Usage', 0),('device', 'storage', 'system', 'Filesystem Usage', 0),('device', 'hr_processes', 'system', 'Running Processes', 0),('device', 'uptime', 'system', 'System Uptime', ''),('device', 'ipsystemstats_ipv4', 'netstats', 'IPv4 Packet Statistics', 0),('device', 'ipsystemstats_ipv6_frag', 'netstats', 'IPv6 Fragmentation Statistics', 0),('device', 'ipsystemstats_ipv6', 'netstats', 'IPv6 Packet Statistics', 0),('device', 'ipsystemstats_ipv4_frag', 'netstats', 'IPv4 Fragmentation Statistics', 0),('device', 'fortigate_sessions', 'firewall', 'Active Sessions', ''), ('device', 'screenos_sessions', 'firewall', 'Active Sessions', ''), ('device', 'fdb_count', 'system', 'MAC Addresses Learnt', '0'),('device', 'cras_sessions', 'firewall', 'Remote Access Sessions', 0);
|
||||
INSERT INTO `graph_types` (`graph_type`, `graph_subtype`, `graph_section`, `graph_descr`, `graph_order`) VALUES('device', 'bits', 'netstats', 'Total Traffic', 0),('device', 'hr_users', 'system', 'Users Logged In', 0),('device', 'ucd_load', 'system', 'Load Averages', 0),('device', 'ucd_cpu', 'system', 'Detailed Processor Usage', 0),('device', 'ucd_memory', 'system', 'Detailed Memory Usage', 0),('device', 'netstat_tcp', 'netstats', 'TCP Statistics', 0),('device', 'netstat_icmp_info', 'netstats', 'ICMP Informational Statistics', 0),('device', 'netstat_icmp_stat', 'netstats', 'ICMP Statistics', 0),('device', 'netstat_ip', 'netstats', 'IP Statistics', 0),('device', 'netstat_ip_frag', 'netstats', 'IP Fragmentation Statistics', 0),('device', 'netstat_udp', 'netstats', 'UDP Statistics', 0),('device', 'netstat_snmp', 'netstats', 'SNMP Statistics', 0),('device', 'temperatures', 'system', 'Temperatures', 0),('device', 'mempools', 'system', 'Memory Pool Usage', 0),('device', 'processors', 'system', 'Processor Usage', 0),('device', 'storage', 'system', 'Filesystem Usage', 0),('device', 'hr_processes', 'system', 'Running Processes', 0),('device', 'uptime', 'system', 'System Uptime', 0),('device', 'ipsystemstats_ipv4', 'netstats', 'IPv4 Packet Statistics', 0),('device', 'ipsystemstats_ipv6_frag', 'netstats', 'IPv6 Fragmentation Statistics', 0),('device', 'ipsystemstats_ipv6', 'netstats', 'IPv6 Packet Statistics', 0),('device', 'ipsystemstats_ipv4_frag', 'netstats', 'IPv4 Fragmentation Statistics', 0),('device', 'fortigate_sessions', 'firewall', 'Active Sessions', 0), ('device', 'screenos_sessions', 'firewall', 'Active Sessions', 0), ('device', 'fdb_count', 'system', 'MAC Addresses Learnt', 0),('device', 'cras_sessions', 'firewall', 'Remote Access Sessions', 0);
|
||||
CREATE TABLE IF NOT EXISTS `vminfo` (`id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `vmwVmVMID` int(11) NOT NULL, `vmwVmDisplayName` varchar(128) NOT NULL, `vmwVmGuestOS` varchar(128) NOT NULL, `vmwVmMemSize` int(11) NOT NULL, `vmwVmCpus` int(11) NOT NULL, `vmwVmState` varchar(128) NOT NULL, PRIMARY KEY (`id`), KEY `device_id` (`device_id`), KEY `vmwVmVMID` (`vmwVmVMID`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE IF NOT EXISTS `cef_switching` ( `device_id` int(11) NOT NULL, `entPhysicalIndex` int(11) NOT NULL, `afi` varchar(4) COLLATE utf8_unicode_ci NOT NULL, `cef_index` int(11) NOT NULL, `cef_path` varchar(16) COLLATE utf8_unicode_ci NOT NULL, `drop` int(11) NOT NULL, `punt` int(11) NOT NULL, `punt2host` int(11) NOT NULL, `drop_prev` int(11) NOT NULL, `punt_prev` int(11) NOT NULL, `punt2host_prev` int(11) NOT NULL,`updated` INT NOT NULL , `updated_prev` INT NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
UPDATE sensors SET sensor_class='frequency' WHERE sensor_class='freq';
|
||||
|
||||
@@ -100,13 +100,13 @@ function auth_usermanagement()
|
||||
return 1;
|
||||
}
|
||||
|
||||
function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd='1')
|
||||
function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd=1, $description ="", $twofactor=0)
|
||||
{
|
||||
if (!user_exists($username))
|
||||
{
|
||||
$hasher = new PasswordHash(8, FALSE);
|
||||
$encrypted = $hasher->HashPassword($password);
|
||||
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd), 'users');
|
||||
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -114,7 +114,8 @@ function adduser($username, $password, $level, $email = "", $realname = "", $can
|
||||
|
||||
function user_exists($username)
|
||||
{
|
||||
return @dbFetchCell("SELECT COUNT(*) FROM users WHERE username = ?", array($username));
|
||||
$return = @dbFetchCell("SELECT COUNT(*) FROM users WHERE username = ?", array($username));
|
||||
return $return;
|
||||
}
|
||||
|
||||
function get_userlevel($username)
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
<?php
|
||||
|
||||
if(isset($_POST['create-default'])) {
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%devices.status != "1" && %devices.disabled = "0" && %devices.ignore = "0"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'name' => 'Devices up/down');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%devices.uptime < "300" && %devices.disabled = "0" && %devices.ignore = "0"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'name' => 'Device rebooted');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerState != "established"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'name' => 'BGP Session down');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'name' => 'BGP Session establised');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%ports.ifOperStatus != "up" && %ports.ifAdminStatus = "up" && %ports.deleted = "0" && %ports.ignore = "0" && %ports.disabled = "0"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'name' => 'Port status up/down');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '((%ports.ifInOctets_rate*8)/%ports.ifSpeed)*100 >= 80', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'name' => 'Port utilisation over threshold');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'name' => 'Sensor over limit');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'name' => 'Sensor under limit');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%devices.status != "1" && %devices.disabled = "0" && %devices.ignore = "0"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Devices up/down');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%devices.uptime < "300" && %devices.disabled = "0" && %devices.ignore = "0"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Device rebooted');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerState != "established"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session down');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%bgpPeers.bgpPeerFsmEstablishedTime < "300" && %bgpPeers.bgpPeerState = "established"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'BGP Session establised');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%ports.ifOperStatus != "up" && %ports.ifAdminStatus = "up" && %ports.deleted = "0" && %ports.ignore = "0" && %ports.disabled = "0"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"1","delay":"300"}', 'disabled' => 0, 'name' => 'Port status up/down');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '((%ports.ifInOctets_rate*8)/%ports.ifSpeed)*100 >= 80', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Port utilisation over threshold');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor over limit');
|
||||
$default_rules[] = array('device_id' => '-1', 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, 'name' => 'Sensor under limit');
|
||||
foreach( $default_rules as $add_rule ) {
|
||||
dbInsert($add_rule,'alert_rules');
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
|
||||
|
||||
$health = dbFetchCell("SELECT COUNT(*) FROM storage WHERE device_id = '" . $device['device_id'] . "'") +
|
||||
dbFetchCell("SELECT COUNT(sensor_id) FROM sensors WHERE device_id = '" . $device['device_id'] . "'") +
|
||||
dbFetchCell("SELECT COUNT(*) FROM mempools WHERE device_id = '" . $device['device_id'] . "'") +
|
||||
dbFetchCell("SELECT COUNT(*) FROM processors WHERE device_id = '" . $device['device_id'] . "'");
|
||||
|
||||
if ($health)
|
||||
|
||||
@@ -43,11 +43,17 @@ foreach (explode("\n", $ipNetToMedia_data) as $data)
|
||||
dbUpdate(array('mac_address' => $clean_mac), 'ipv4_mac', 'port_id=? AND ipv4_address=?',array($interface['port_id'],$ip));
|
||||
echo(".");
|
||||
}
|
||||
else
|
||||
elseif (isset($interface['port_id']))
|
||||
{
|
||||
echo("+");
|
||||
#echo("Add MAC $mac\n");
|
||||
dbInsert(array('port_id' => $interface['port_id'], 'mac_address' => $clean_mac, 'ipv4_address' => $ip), 'ipv4_mac');
|
||||
$insert_data = array(
|
||||
'port_id' => $interface['port_id'],
|
||||
'mac_address' => $clean_mac,
|
||||
'ipv4_address' => $ip
|
||||
);
|
||||
|
||||
dbInsert($insert_data, 'ipv4_mac');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
$entity_array = snmpwalk_cache_twopart_oid($device, "entAliasMappingIdentifier", $entity_array, "ENTITY-MIB:IF-MIB");
|
||||
|
||||
foreach ($entity_array as $entPhysicalIndex => $entry) {
|
||||
|
||||
|
||||
$entPhysicalDescr = $entry['entPhysicalDescr'];
|
||||
$entPhysicalContainedIn = $entry['entPhysicalContainedIn'];
|
||||
$entPhysicalClass = $entry['entPhysicalClass'];
|
||||
@@ -30,10 +30,16 @@
|
||||
$entPhysicalAlias = $entry['entPhysicalAlias'];
|
||||
$entPhysicalAssetID = $entry['entPhysicalAssetID'];
|
||||
|
||||
if (isset($entity_array['$entPhysicalIndex']['0']['entAliasMappingIdentifier'])) { $ifIndex = $entity_array['$entPhysicalIndex']['0']['entAliasMappingIdentifier']; }
|
||||
if (isset($entity_array[$entPhysicalIndex]['0']['entAliasMappingIdentifier'])) {
|
||||
$ifIndex = $entity_array[$entPhysicalIndex]['0']['entAliasMappingIdentifier'];
|
||||
}
|
||||
|
||||
if (!strpos($ifIndex, "fIndex") || $ifIndex == "") { unset($ifIndex); }
|
||||
list(,$ifIndex) = explode(".", $ifIndex);
|
||||
if (!strpos($ifIndex, "fIndex") || $ifIndex == "") {
|
||||
unset($ifIndex);
|
||||
} else {
|
||||
$ifIndex_array = explode(".", $ifIndex);
|
||||
$ifIndex = $ifIndex_array[1];
|
||||
}
|
||||
|
||||
if ($entPhysicalVendorTypes[$entPhysicalVendorType] && !$entPhysicalModelName)
|
||||
{
|
||||
@@ -47,10 +53,52 @@
|
||||
$entPhysical_id = dbFetchCell("SELECT entPhysical_id FROM `entPhysical` WHERE device_id = ? AND entPhysicalIndex = ?",array($device['device_id'], $entPhysicalIndex));
|
||||
|
||||
if ($entPhysical_id) {
|
||||
dbUpdate(array('entPhysicalIndex' => $entPhysicalIndex, 'entPhysicalDescr' => $entPhysicalDescr, 'entPhysicalClass' => $entPhysicalClass, 'entPhysicalName' => $entPhysicalName, 'entPhysicalModelName' => $entPhysicalModelName, 'entPhysicalSerialNum' => $entPhysicalSerialNum, 'entPhysicalContainedIn' => $entPhysicalContainedIn, 'entPhysicalMfgName' => $entPhysicalMfgName, 'entPhysicalParentRelPos' => $entPhysicalParentRelPos, 'entPhysicalVendorType' => $entPhysicalVendorType, 'entPhysicalHardwareRev' => $entPhysicalHardwareRev, 'entPhysicalFirmwareRev' => $entPhysicalFirmwareRev, 'entPhysicalSoftwareRev' => $entPhysicalSoftwareRev, 'entPhysicalIsFRU' => $entPhysicalIsFRU, 'entPhysicalAlias' => $entPhysicalAlias, 'entPhysicalAssetID' => $entPhysicalAssetID), 'entPhysical', 'device_id=? AND entPhysicalIndex=?',array($device['device_id'],$entPhysicalIndex));
|
||||
$update_data = array(
|
||||
'entPhysicalIndex' => $entPhysicalIndex,
|
||||
'entPhysicalDescr' => $entPhysicalDescr,
|
||||
'entPhysicalClass' => $entPhysicalClass,
|
||||
'entPhysicalName' => $entPhysicalName,
|
||||
'entPhysicalModelName' => $entPhysicalModelName,
|
||||
'entPhysicalSerialNum' => $entPhysicalSerialNum,
|
||||
'entPhysicalContainedIn' => $entPhysicalContainedIn,
|
||||
'entPhysicalMfgName' => $entPhysicalMfgName,
|
||||
'entPhysicalParentRelPos' => $entPhysicalParentRelPos,
|
||||
'entPhysicalVendorType' => $entPhysicalVendorType,
|
||||
'entPhysicalHardwareRev' => $entPhysicalHardwareRev,
|
||||
'entPhysicalFirmwareRev' => $entPhysicalFirmwareRev,
|
||||
'entPhysicalSoftwareRev' => $entPhysicalSoftwareRev,
|
||||
'entPhysicalIsFRU' => $entPhysicalIsFRU,
|
||||
'entPhysicalAlias' => $entPhysicalAlias,
|
||||
'entPhysicalAssetID' => $entPhysicalAssetID
|
||||
);
|
||||
dbUpdate($update_data, 'entPhysical', 'device_id=? AND entPhysicalIndex=?',array($device['device_id'],$entPhysicalIndex));
|
||||
echo(".");
|
||||
} else {
|
||||
dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $entPhysicalIndex, 'entPhysicalDescr' => $entPhysicalDescr,'entPhysicalClass' => $entPhysicalClass, 'entPhysicalName' => $entPhysicalName, 'entPhysicalModelName' => $entPhysicalModelName, 'entPhysicalSerialNum' => $entPhysicalSerialNum, 'entPhysicalContainedIn' => $entPhysicalContainedIn, 'entPhysicalMfgName' => $entPhysicalMfgName, 'entPhysicalParentRelPos' => $entPhysicalParentRelPos, 'entPhysicalVendorType' => $entPhysicalVendorType, 'entPhysicalHardwareRev' => $entPhysicalHardwareRev, 'entPhysicalFirmwareRev' => $entPhysicalFirmwareRev, 'entPhysicalSoftwareRev' => $entPhysicalSoftwareRev, 'entPhysicalIsFRU' => $entPhysicalIsFRU, 'entPhysicalAlias' => $entPhysicalAlias, 'entPhysicalAssetID' => $entPhysicalAssetID, 'ifIndex' => $ifIndex), 'entPhysical');
|
||||
$insert_data = array(
|
||||
'device_id' => $device['device_id'],
|
||||
'entPhysicalIndex' => $entPhysicalIndex,
|
||||
'entPhysicalDescr' => $entPhysicalDescr,
|
||||
'entPhysicalClass' => $entPhysicalClass,
|
||||
'entPhysicalName' => $entPhysicalName,
|
||||
'entPhysicalModelName' => $entPhysicalModelName,
|
||||
'entPhysicalSerialNum' => $entPhysicalSerialNum,
|
||||
'entPhysicalContainedIn' => $entPhysicalContainedIn,
|
||||
'entPhysicalMfgName' => $entPhysicalMfgName,
|
||||
'entPhysicalParentRelPos' => $entPhysicalParentRelPos,
|
||||
'entPhysicalVendorType' => $entPhysicalVendorType,
|
||||
'entPhysicalHardwareRev' => $entPhysicalHardwareRev,
|
||||
'entPhysicalFirmwareRev' => $entPhysicalFirmwareRev,
|
||||
'entPhysicalSoftwareRev' => $entPhysicalSoftwareRev,
|
||||
'entPhysicalIsFRU' => $entPhysicalIsFRU,
|
||||
'entPhysicalAlias' => $entPhysicalAlias,
|
||||
'entPhysicalAssetID' => $entPhysicalAssetID
|
||||
);
|
||||
|
||||
if (!empty($ifIndex)) {
|
||||
$insert_data['ifIndex'] = $ifIndex;
|
||||
}
|
||||
|
||||
dbInsert($insert_data, 'entPhysical');
|
||||
echo("+");
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ function discover_device($device, $options = NULL)
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
|
||||
|
||||
// If we've specified a module, use that, else walk the modules array
|
||||
if ($options['m'])
|
||||
{
|
||||
@@ -158,9 +158,30 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
|
||||
list($high_limit, $low_limit) = array($low_limit, $high_limit);
|
||||
}
|
||||
|
||||
$insert = array('poller_type' => $poller_type, 'sensor_class' => $class, 'device_id' => $device['device_id'], 'sensor_oid' => $oid, 'sensor_index' => $index, 'sensor_type' => $type, 'sensor_descr' => $descr,
|
||||
'sensor_divisor' => $divisor, 'sensor_multiplier' => $multiplier, 'sensor_limit' => $high_limit, 'sensor_limit_warn' => $warn_limit, 'sensor_limit_low' => $low_limit,
|
||||
'sensor_limit_low_warn' => $low_warn_limit, 'sensor_current' => $current, 'entPhysicalIndex' => $entPhysicalIndex, 'entPhysicalIndex_measured' => $entPhysicalIndex_measured );
|
||||
$insert = array(
|
||||
'poller_type' => $poller_type,
|
||||
'sensor_class' => $class,
|
||||
'device_id' => $device['device_id'],
|
||||
'sensor_oid' => $oid,
|
||||
'sensor_index' => $index,
|
||||
'sensor_type' => $type,
|
||||
'sensor_descr' => $descr,
|
||||
'sensor_divisor' => $divisor,
|
||||
'sensor_multiplier' => $multiplier,
|
||||
'sensor_limit' => $high_limit,
|
||||
'sensor_limit_warn' => $warn_limit,
|
||||
'sensor_limit_low' => $low_limit,
|
||||
'sensor_limit_low_warn' => $low_warn_limit,
|
||||
'sensor_current' => $current,
|
||||
'entPhysicalIndex' => $entPhysicalIndex,
|
||||
'entPhysicalIndex_measured' => $entPhysicalIndex_measured
|
||||
);
|
||||
|
||||
foreach ($insert as $key => $val_check){
|
||||
if (!isset($val_check)) {
|
||||
unset($insert[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$inserted = dbInsert($insert, 'sensors');
|
||||
|
||||
@@ -334,7 +355,7 @@ function sensor_limit($class, $current)
|
||||
function check_valid_sensors($device, $class, $valid, $poller_type = 'snmp')
|
||||
{
|
||||
$entries = dbFetchRows("SELECT * FROM sensors AS S, devices AS D WHERE S.sensor_class=? AND S.device_id = D.device_id AND D.device_id = ? AND S.poller_type = ?", array($class, $device['device_id'], $poller_type));
|
||||
|
||||
|
||||
if (count($entries))
|
||||
{
|
||||
foreach ($entries as $entry)
|
||||
@@ -374,13 +395,29 @@ function discover_juniAtmVp(&$valid, $port_id, $vp_id, $vp_descr)
|
||||
function discover_link($local_port_id, $protocol, $remote_port_id, $remote_hostname, $remote_port, $remote_platform, $remote_version)
|
||||
{
|
||||
global $config, $debug, $link_exists;
|
||||
|
||||
|
||||
if ($debug) {
|
||||
echo("\n");
|
||||
var_dump($local_port_id, $protocol, $remote_port_id, $remote_hostname, $remote_port, $remote_platform, $remote_version);
|
||||
}
|
||||
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM `links` WHERE `remote_hostname` = ? AND `local_port_id` = ? AND `protocol` = ? AND `remote_port` = ?",
|
||||
array($remote_hostname, $local_port_id, $protocol, $remote_port)) == "0")
|
||||
{
|
||||
$insert_data = array(
|
||||
'local_port_id' => $local_port_id,
|
||||
'protocol' => $protocol,
|
||||
'remote_hostname' => $remote_hostname,
|
||||
'remote_port' => $remote_port,
|
||||
'remote_platform' => $remote_platform,
|
||||
'remote_version' => $remote_version
|
||||
);
|
||||
|
||||
if (!empty($remote_port_id)) {
|
||||
$insert_data['remote_port_id'] = $remote_port_id;
|
||||
}
|
||||
|
||||
$inserted = dbInsert(array('local_port_id' => $local_port_id,'protocol' => $protocol,'remote_port_id' => $remote_port_id,'remote_hostname' => $remote_hostname,
|
||||
'remote_port' => $remote_port,'remote_platform' => $remote_platform,'remote_version' => $remote_version), 'links');
|
||||
$inserted = dbInsert($insert_data, 'links');
|
||||
|
||||
echo("+"); if ($debug) { echo("( $inserted inserted )"); }
|
||||
}
|
||||
@@ -393,7 +430,16 @@ function discover_link($local_port_id, $protocol, $remote_port_id, $remote_hostn
|
||||
}
|
||||
else
|
||||
{
|
||||
$updated = dbUpdate(array('remote_port_id' => $remote_port_id, 'remote_platform' => $remote_platform, 'remote_version' => $remote_version), 'links', '`id` = ?', array($data['id']));
|
||||
$update_data = array(
|
||||
'remote_platform' => $remote_platform,
|
||||
'remote_version' => $remote_version
|
||||
);
|
||||
|
||||
if (!empty($remote_port_id)) {
|
||||
$update_data['remote_port_id'] = $remote_port_id;
|
||||
}
|
||||
|
||||
$updated = dbUpdate($update_data, 'links', '`id` = ?', array($data['id']));
|
||||
echo("U"); if ($debug) { echo("( $updated updated )"); }
|
||||
}
|
||||
}
|
||||
@@ -428,20 +474,45 @@ function discover_processor(&$valid, $device, $oid, $index, $type, $descr, $prec
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
if ($debug) { echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n"); }
|
||||
if ($debug) {
|
||||
echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n");
|
||||
}
|
||||
|
||||
if ($descr)
|
||||
{
|
||||
$descr = trim(str_replace("\"", "", $descr));
|
||||
if (dbFetchCell("SELECT COUNT(processor_id) FROM `processors` WHERE `processor_index` = ? AND `device_id` = ? AND `processor_type` = ?",array($index,$device['device_id'], $type)) == '0')
|
||||
{
|
||||
$inserted = dbInsert(array('entPhysicalIndex' => $entPhysicalIndex, 'hrDeviceIndex' => $hrDeviceIndex, 'device_id' => $device['device_id'],'processor_descr' => $descr, 'processor_index' => $index, 'processor_oid' => $oid, 'processor_usage' => $current, 'processor_type' => $type, 'processor_precision' => $precision), 'processors');
|
||||
$insert_data = array(
|
||||
'device_id' => $device['device_id'],
|
||||
'processor_descr' => $descr,
|
||||
'processor_index' => $index,
|
||||
'processor_oid' => $oid,
|
||||
'processor_usage' => $current,
|
||||
'processor_type' => $type,
|
||||
'processor_precision' => $precision
|
||||
);
|
||||
if (!empty($hrDeviceIndex)) {
|
||||
$insert_data['hrDeviceIndex'] = $hrDeviceIndex;
|
||||
}
|
||||
if( !empty($entPhysicalIndex) ) {
|
||||
$insert_data['entPhysicalIndex'] = $entPhysicalIndex;
|
||||
}
|
||||
|
||||
$inserted = dbInsert($insert_data, 'processors');
|
||||
echo("+");
|
||||
log_event("Processor added: type ".mres($type)." index ".mres($index)." descr ". mres($descr), $device, 'processor', $inserted);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo(".");
|
||||
dbUpdate(array('processor_descr' => $descr, 'processor_oid' => $oid, 'processor_precision' => $precision), 'processors', '`device_id`=? AND `processor_index`=? AND `processor_type`=?',array($device['device_id'],$index,$type));
|
||||
$update_data = array(
|
||||
'processor_descr' => $descr,
|
||||
'processor_oid' => $oid,
|
||||
'processor_usage' => $current,
|
||||
'processor_precision' => $precision
|
||||
);
|
||||
dbUpdate($update_data, 'processors', '`device_id`=? AND `processor_index`=? AND `processor_type`=?',array($device['device_id'],$index,$type));
|
||||
if ($debug) { print $query . "\n"; }
|
||||
}
|
||||
$valid[$type][$index] = 1;
|
||||
@@ -451,20 +522,54 @@ function discover_processor(&$valid, $device, $oid, $index, $type, $descr, $prec
|
||||
function discover_mempool(&$valid, $device, $index, $type, $descr, $precision = "1", $entPhysicalIndex = NULL, $hrDeviceIndex = NULL)
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
if ($debug) { echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n"); }
|
||||
|
||||
if ($debug) {
|
||||
echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n");
|
||||
}
|
||||
|
||||
#FIXME implement the mempool_perc, mempool_used, etc.
|
||||
if ($descr)
|
||||
{
|
||||
if (dbFetchCell("SELECT COUNT(mempool_id) FROM `mempools` WHERE `mempool_index` = ? AND `device_id` = ? AND `mempool_type` = ?",array($index,$device['device_id'], $type)) == '0')
|
||||
{
|
||||
$inserted = dbInsert(array('entPhysicalIndex' => $entPhysicalIndex, 'hrDeviceIndex' => $hrDeviceIndex, 'device_id' => $device['device_id'],'mempool_descr' => $descr, 'mempool_index' => $index, 'mempool_type' => $type, 'mempool_precision' => $precision), 'mempools');
|
||||
$insert_data = array(
|
||||
'device_id' => $device['device_id'],
|
||||
'mempool_descr' => $descr,
|
||||
'mempool_index' => $index,
|
||||
'mempool_type' => $type,
|
||||
'mempool_precision' => $precision,
|
||||
'mempool_perc' => 0,
|
||||
'mempool_used' => 0,
|
||||
'mempool_free' => 0,
|
||||
'mempool_total' => 0
|
||||
);
|
||||
|
||||
if (!empty($entPhysicalIndex)) {
|
||||
$insert_data['entPhysicalIndex'] = $entPhysicalIndex;
|
||||
}
|
||||
|
||||
if (!empty($hrDeviceIndex)) {
|
||||
$insert_data['hrDeviceIndex'] = $hrDeviceIndex;
|
||||
}
|
||||
|
||||
$inserted = dbInsert($insert_data, 'mempools');
|
||||
echo("+");
|
||||
log_event("Memory pool added: type ".mres($type)." index ".mres($index)." descr ". mres($descr), $device, 'mempool', $inserted);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo(".");
|
||||
dbUpdate(array('mempool_descr' => $descr, 'entPhysicalIndex' => $entPhysicalIndex, 'hrDeviceIndex' => $hrDeviceIndex), 'mempools', 'device_id=? AND mempool_index=? AND mempool_type',array($device['device_id'],$index,$type));
|
||||
$update_data['mempool_descr'] = $descr;
|
||||
|
||||
if (!empty($entPhysicalIndex)) {
|
||||
$update_data['entPhysicalIndex'] = $entPhysicalIndex;
|
||||
}
|
||||
|
||||
if (!empty($hrDeviceIndex)) {
|
||||
$update_data['hrDeviceIndex'] = $hrDeviceIndex;
|
||||
}
|
||||
|
||||
dbUpdate($update_data, 'mempools', 'device_id=? AND mempool_index=? AND mempool_type=?',array($device['device_id'],$index,$type));
|
||||
if ($debug) { print $query . "\n"; }
|
||||
}
|
||||
$valid[$type][$index] = 1;
|
||||
|
||||
@@ -31,7 +31,7 @@ if (is_array($hrDevices))
|
||||
}
|
||||
else
|
||||
{
|
||||
$inserted_rows = dbInsert(array('hrDeviceIndex' => mres($hrDevice['hrDeviceIndex']), 'device_id' => mres($device['device_id']), 'hrDeviceType' => mres($hrDevice['hrDeviceType']),'hrDeviceDescr' => mres($hrDevice['hrDeviceDescr']), 'hrDeviceStatus' => mres($hrDevice['hrDeviceStatus']), 'hrDeviceErrors' => mres($hrDevice['hrDeviceErrors'])), 'hrDevice');
|
||||
$inserted_rows = dbInsert(array('hrDeviceIndex' => mres($hrDevice['hrDeviceIndex']), 'device_id' => mres($device['device_id']), 'hrDeviceType' => mres($hrDevice['hrDeviceType']),'hrDeviceDescr' => mres($hrDevice['hrDeviceDescr']), 'hrDeviceStatus' => mres($hrDevice['hrDeviceStatus']), 'hrDeviceErrors' => (int) mres($hrDevice['hrDeviceErrors'])), 'hrDevice');
|
||||
echo("+");
|
||||
if ($debug) { print_r($hrDevice); echo("$inserted_rows row inserted"); }
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ if ($device['os_group'] == "cisco" || $device['os'] == "acsw")
|
||||
|
||||
if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "")
|
||||
{
|
||||
discover_processor($valid['processor'], $device, $usage_oid, $index, "cpm", $descr, "1", $entry['juniSystemModuleCpuUtilPct'], $entPhysicalIndex, NULL);
|
||||
discover_processor($valid['processor'], $device, $usage_oid, $index, "cpm", $descr, "1", $usage, $entPhysicalIndex, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// FIXME - dbFacile and fewer SNMP_GETs
|
||||
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ? AND `sensor_class` = 'temperature' AND (`sensor_type` = 'cisco-entity-sensor' OR `sensor_type` = 'entity-sensor'",array($device['device_id'])) == "0" && ($device['os_group'] == "cisco"))
|
||||
if (dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ? AND `sensor_class` = 'temperature' AND (`sensor_type` = 'cisco-entity-sensor' OR `sensor_type` = 'entity-sensor')",array($device['device_id'])) == "0" && ($device['os_group'] == "cisco"))
|
||||
{
|
||||
echo("CISCO-ENVMON-MIB: ");
|
||||
$oids = snmp_walk($device, ".1.3.6.1.4.1.9.9.13.1.3.1.2", "-Osqn", "CISCO-ENVMON-MIB");
|
||||
@@ -24,6 +24,10 @@ if (dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ? AND `senso
|
||||
$descr = str_replace("temperature", "", $descr);
|
||||
$descr = str_replace("temperature", "", $descr);
|
||||
$descr = trim($descr);
|
||||
|
||||
if (!is_numeric($temperature)) {
|
||||
$temperature = stristr($temperature, " degrees", true);
|
||||
}
|
||||
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'cisco', $descr, '1', '1', NULL, NULL, NULL, NULL, $temperature);
|
||||
}
|
||||
|
||||
@@ -55,16 +55,16 @@ foreach ($device['vlans'] as $domain_id => $vlans)
|
||||
'port_id' => $port['port_id'],
|
||||
'vlan' => $vlan_id);
|
||||
|
||||
$db_a = array('baseport' => $vlan_port_id,
|
||||
'priority' => $vlan_port['dot1dStpPortPriority'],
|
||||
'state' => $vlan_port['dot1dStpPortState'],
|
||||
'cost' => $vlan_port['dot1dStpPortPathCost']);
|
||||
$db_a['baseport'] = $vlan_port_id;
|
||||
$db_a['priority'] = isset($vlan_port['dot1dStpPortPriority']) ? $vlan_port['dot1dStpPortPriority'] : 0;
|
||||
$db_a['state'] = isset($vlan_port['dot1dStpPortState']) ? $vlan_port['dot1dStpPortState'] : "unknown";
|
||||
$db_a['cost'] = isset($vlan_port['dot1dStpPortPathCost']) ? $vlan_port['dot1dStpPortPathCost'] : 0;
|
||||
|
||||
$from_db = dbFetchRow("SELECT * FROM `ports_vlans` WHERE device_id = ? AND port_id = ? AND `vlan` = ?", array($device['device_id'], $port['port_id'], $vlan_id));
|
||||
|
||||
|
||||
if ($from_db['port_vlan_id'])
|
||||
{
|
||||
dbUpdate($db_a, 'ports_vlans', "`port_vlan_id` = ?", $from_db['port_vlan_id']);
|
||||
dbUpdate($db_a, 'ports_vlans', "`port_vlan_id` = ?", array($from_db['port_vlan_id']));
|
||||
echo("Updated");
|
||||
} else {
|
||||
dbInsert(array_merge($db_w, $db_a), 'ports_vlans');
|
||||
|
||||
@@ -31,8 +31,20 @@ foreach (dbFetchRows("SELECT * FROM mempools WHERE device_id = ?", array($device
|
||||
}
|
||||
rrdtool_update($mempool_rrd,"N:".$mempool['used'].":".$mempool['free']);
|
||||
|
||||
$mempool['state'] = array('mempool_used' => $mempool['used'], 'mempool_perc' => $percent, 'mempool_free' => $mempool['free'],
|
||||
'mempool_total' => $mempool['total'], 'mempool_largestfree' => $mempool['largestfree'], 'mempool_lowestfree' => $mempool['lowestfree']);
|
||||
$mempool['state'] = array(
|
||||
'mempool_used' => $mempool['used'],
|
||||
'mempool_perc' => $percent,
|
||||
'mempool_free' => $mempool['free'],
|
||||
'mempool_total' => $mempool['total']
|
||||
);
|
||||
|
||||
if (!empty($mempool['largestfree'])) {
|
||||
$mempool['state']['mempool_largestfree'] = $mempool['largestfree'];
|
||||
}
|
||||
|
||||
if (!empty($mempool['lowestfree'])) {
|
||||
$mempool['state']['mempool_lowestfree'] = $mempool['lowestfree'];
|
||||
}
|
||||
|
||||
if ($config['memcached']['enable'])
|
||||
{
|
||||
|
||||
@@ -430,6 +430,12 @@ foreach ($ports as $port)
|
||||
$memcache->set('port-'.$port['port_id'].'-state', $port['state']);
|
||||
}
|
||||
|
||||
foreach ($port['update'] as $key => $val_check){
|
||||
if (!isset($val_check)) {
|
||||
unset($port['update'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Update Database
|
||||
if (count($port['update']))
|
||||
{
|
||||
|
||||
8
sql-schema/040.sql
Normal file
8
sql-schema/040.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
ALTER TABLE `devices` CHANGE `agent_uptime` `agent_uptime` INT( 11 ) NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `devices` CHANGE `type` `type` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '';
|
||||
ALTER TABLE `ports` CHANGE `ifVrf` `ifVrf` INT( 11 ) NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `storage` CHANGE `storage_free` `storage_free` BIGINT( 20 ) NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `storage` CHANGE `storage_used` `storage_used` BIGINT( 20 ) NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `storage` CHANGE `storage_perc` `storage_perc` INT NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `processors` CHANGE `entPhysicalIndex` `entPhysicalIndex` INT( 11 ) NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `hrDevice` CHANGE `hrDeviceErrors` `hrDeviceErrors` INT( 11 ) NOT NULL DEFAULT '0';
|
||||
Reference in New Issue
Block a user