mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
- Use new official OCP ONL subtree.
- Implement the ONL Platform information subtrees
This commit is contained in:
@@ -14,6 +14,7 @@ packages:
|
||||
|
||||
files:
|
||||
builds/$BUILD_DIR/${TOOLCHAIN}/bin/onlp-snmpd: /usr/bin/onlp-snmpd
|
||||
${ONL}/packages/base/any/onlp-snmpd/bin/onl-snmpwalk : /usr/bin/onl-snmpwalk
|
||||
|
||||
init: ${ONL}/packages/base/any/onlp-snmpd/onlp-snmpd.init
|
||||
|
||||
|
||||
34
packages/base/any/onlp-snmpd/bin/onl-snmpwalk
Executable file
34
packages/base/any/onlp-snmpd/bin/onl-snmpwalk
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
############################################################
|
||||
SERVER=localhost
|
||||
ONL_TREE=.1.3.6.1.4.1.42623.1
|
||||
MIBS=OCP-ONL-PLATFORM-MIB:OCP-ONL-SENSOR-MIB
|
||||
MIB_ARGS="-m $MIBS"
|
||||
COMMUNITY=public
|
||||
ECHO=
|
||||
|
||||
while getopts "s:c:nvpd" opt; do
|
||||
case $opt in
|
||||
s)
|
||||
SERVER=$OPTARG;
|
||||
;;
|
||||
n)
|
||||
MIB_ARGS=
|
||||
;;
|
||||
c)
|
||||
COMMUNITY=$OPTARG;
|
||||
;;
|
||||
p)
|
||||
ONL_TREE="${ONL_TREE}.1"
|
||||
;;
|
||||
v)
|
||||
set -x
|
||||
;;
|
||||
d)
|
||||
# Just echo the command
|
||||
ECHO=echo
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
$ECHO snmpwalk $MIB_ARGS -v2c -c $COMMUNITY $SERVER $ONL_TREE
|
||||
@@ -3,7 +3,7 @@ include $(ONL)/make/any.mk
|
||||
MODULE := onlp-snmpd
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := onlp_snmp AIM OS snmp_subagent IOF
|
||||
DEPENDMODULES := onlp_snmp AIM OS snmp_subagent IOF onlplib
|
||||
DEPENDMODULE_HEADERS := onlp
|
||||
|
||||
include $(BUILDER)/dependmodules.mk
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2015 v=onl>
|
||||
*
|
||||
* Copyright 2015 Big Switch Networks, Inc.
|
||||
*
|
||||
*
|
||||
* Copyright 2015 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
@@ -30,23 +30,10 @@
|
||||
* ONLP-PLATFORM-MIBS.txt
|
||||
*/
|
||||
|
||||
/**
|
||||
* These are all currently defined as part of the Big Switch enterprise tree.
|
||||
*
|
||||
* In the future we should apply for an ONL Private Enterprise Number and
|
||||
* redefine these appropriately.
|
||||
*/
|
||||
|
||||
#define ONLP_SNMP_PLATFORM_INFORMATION_OID 1,3,6,1,4,1,37538,2,1000
|
||||
#define ONLP_SNMP_PLATFORM_INFORMATION_OID 1,3,6,1,4,1,42623,1,1
|
||||
#define ONLP_SNMP_PLATFORM_GENERAL_OID ONLP_SNMP_PLATFORM_INFORMATION_OID,1
|
||||
#define ONLP_SNMP_PLATFORM_SYSTEM_OID ONLP_SNMP_PLATFORM_GENERAL_OID,1
|
||||
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
|
||||
|
||||
#endif /* __ONLP_SNMP_PLATFORM_OIDS_H__ */
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2015 v=onl>
|
||||
*
|
||||
* Copyright 2015 Big Switch Networks, Inc.
|
||||
*
|
||||
*
|
||||
* Copyright 2015 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
@@ -27,17 +27,10 @@
|
||||
|
||||
/**
|
||||
* See:
|
||||
* ONLP-SENSOR-MIBS.txt
|
||||
* OCP-ONL-SENSOR-MIBS.txt
|
||||
*/
|
||||
|
||||
/**
|
||||
* These are all currently defined as part of the Big Switch enterprise tree.
|
||||
*
|
||||
* In the future we should apply for an ONL Private Enterprise Number and
|
||||
* redefine these appropriately.
|
||||
*/
|
||||
|
||||
#define ONLP_SNMP_SENSOR_OID 1,3,6,1,4,1,37538,2,3
|
||||
#define ONLP_SNMP_SENSOR_OID 1,3,6,1,4,1,42623,1,2
|
||||
|
||||
#define ONLP_SNMP_SENSOR_ENTRY 1
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2015 v=onl>
|
||||
*
|
||||
* Copyright 2015 Big Switch Networks, Inc.
|
||||
*
|
||||
*
|
||||
* Copyright 2015 Big Switch Networks, Inc.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <OS/os_time.h>
|
||||
|
||||
#include <onlp/sys.h>
|
||||
#include <onlp/thermal.h>
|
||||
#include <onlp/fan.h>
|
||||
#include <onlp/psu.h>
|
||||
@@ -1291,9 +1292,92 @@ void onlp_snmp_sensors_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
platform_string_register(int index, const char* desc, char* value)
|
||||
{
|
||||
oid tree[] = { 1, 3, 6, 1, 4, 1, 42623, 1, 1, 1, 1, 1};
|
||||
tree[11] = index;
|
||||
|
||||
if(!value || !value[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
char* s = aim_strdup(value);
|
||||
|
||||
netsnmp_handler_registration *reg =
|
||||
netsnmp_create_handler_registration(
|
||||
desc, NULL,
|
||||
tree, OID_LENGTH(tree),
|
||||
HANDLER_CAN_RONLY);
|
||||
netsnmp_watcher_info *winfo =
|
||||
netsnmp_create_watcher_info(
|
||||
s, strlen(s),
|
||||
ASN_OCTET_STR, WATCHER_FIXED_SIZE);
|
||||
netsnmp_register_watched_scalar( reg, winfo );
|
||||
}
|
||||
|
||||
void
|
||||
platform_int_register(int index, char* desc, int value)
|
||||
{
|
||||
oid tree[] = { 1, 3, 6, 1, 4, 1, 42623, 1, 1, 1, 1, 1};
|
||||
tree[11] = index;
|
||||
|
||||
int* v = aim_zmalloc(sizeof(value));
|
||||
*v = value;
|
||||
|
||||
netsnmp_register_int_instance(desc,
|
||||
tree,
|
||||
OID_LENGTH(tree),
|
||||
v, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
onlp_snmp_platform_init(void)
|
||||
{
|
||||
/**
|
||||
* This is the base of the platform:general:system tree
|
||||
*/
|
||||
onlp_sys_info_t si;
|
||||
if(onlp_sys_info_get(&si) >= 0) {
|
||||
|
||||
#define REGISTER_STR(_index, _field) \
|
||||
do { \
|
||||
platform_string_register(_index, #_field, (char*)si.onie_info._field); \
|
||||
} while(0)
|
||||
|
||||
#define REGISTER_INT(_index, _field) \
|
||||
do { \
|
||||
platform_int_register(_index, #_field, si.onie_info._field); \
|
||||
} while(0)
|
||||
|
||||
REGISTER_STR(1, product_name);
|
||||
REGISTER_STR(2, part_number);
|
||||
REGISTER_STR(3, serial_number);
|
||||
char* mstring = aim_fstrdup("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
|
||||
si.onie_info.mac[0], si.onie_info.mac[2], si.onie_info.mac[3],
|
||||
si.onie_info.mac[3], si.onie_info.mac[4], si.onie_info.mac[5]);
|
||||
platform_string_register(4, "mac", mstring);
|
||||
aim_free(mstring);
|
||||
|
||||
REGISTER_INT(5, mac_range);
|
||||
REGISTER_STR(6, manufacturer);
|
||||
REGISTER_STR(7, manufacture_date);
|
||||
REGISTER_STR(8, vendor);
|
||||
REGISTER_STR(9, platform_name);
|
||||
REGISTER_INT(10, device_version);
|
||||
REGISTER_STR(11, label_revision);
|
||||
REGISTER_STR(12, country_code);
|
||||
REGISTER_STR(13, diag_version);
|
||||
REGISTER_STR(14, service_tag);
|
||||
REGISTER_STR(15, onie_version);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
onlp_snmp_sensors_client(int enable, void* cookie)
|
||||
{
|
||||
onlp_snmp_sensors_init();
|
||||
onlp_snmp_platform_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user