I am trying to configure telegraf to collect snmp data. But getting below error :
2022-03-12T11:17:58Z W! [inputs.snmp] module miblist.txt could not be loaded
2022-03-12T11:17:58Z E! [telegraf] Error running agent: could not initialize input inputs.snmp: initializing table interface: translating: Could not find module named IF-MIB
"snmpwalk" is working fine here.
Sample output snmpwalk :
root#netopslab:/etc/telegraf/telegraf.d# snmpwalk -v 2c -c public 172.30.1.100
SNMPv2-MIB::sysDescr.0 = STRING: Cisco IOS XR Software (Cisco IOS XRv Series), Version 6.1.3[Default]
Copyright (c) 2017 by Cisco Systems, Inc.
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.9.1.613
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (164173) 0:27:21.73
SNMPv2-MIB::sysContact.0 = STRING:
SNMPv2-MIB::sysName.0 = STRING: IOSXR-TEST.ios-xr.local
SNMPv2-MIB::sysLocation.0 = STRING:
SNMPv2-MIB::sysServices.0 = INTEGER: 78
IF-MIB::ifNumber.0 = INTEGER: 5
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifIndex.3 = INTEGER: 3
IF-MIB::ifIndex.4 = INTEGER: 4
IF-MIB::ifIndex.5 = INTEGER: 5
IF-MIB::ifIndex.6 = INTEGER: 6
IF-MIB::ifDescr.2 = STRING: Null0
IF-MIB::ifDescr.3 = STRING: GigabitEthernet0/0/0/0
IF-MIB::ifDescr.4 = STRING: GigabitEthernet0/0/0/1
Related
I have incoming BLE beacon data from a gateway in the following format:
{"msg":"advData","gmac":"94A408B02508","obj":
[
{"type":32,"dmac":"AC233FE0784F","data1":"0201060303F1FF1716E2C56DB5DFFB48D2B060D0F5A71096E000000000C564","rssi":-45,"time":"2022-10-13 02:46:24"},
{"type":32,"dmac":"AC233FE078A1","data1":"0201060303F1FF1716E2C56DB5DFFB48D2B060D0F5A71096E000000000C564","rssi":-42,"time":"2022-10-13 02:46:26"}
]
}
and I want to extract the attributes gmac, dmac, rssi, and process attribute data1 and ingest these into influxdb via a telegraf config file.
I can successfully ingest gmac, dmac, and rssi using the below telegraf config:
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "json_v2"
tagexclude = ["topic"]
[[inputs.mqtt_consumer.json_v2]]
measurement_name = "a"
timestamp_path = "obj.#.time"
timestamp_format = "unix"
[[inputs.mqtt_consumer.json_v2.tag]]
path = "gmac"
rename = "g"
[[inputs.mqtt_consumer.json_v2.tag]]
path = "obj.#.dmac"
rename = "d"
[[inputs.mqtt_consumer.json_v2.field]]
path = "obj.#.rssi"
type = "int"
rename = "r"
However, I'm not sure how to process the data1 attribute where I need to (1) extract characters 15 and 16 and convert this from a hexadecimal value to an integer, and (2) extract characters 13 and 14 and convert each hexadecimal value to an integer before combining them together as a float (character 13 is the whole number component, character 14 is the decimal component).
Can anybody provide some guidance here?
Many thanks!
Got it working thanks to some help over at Influx Community, I've pasted the relevant section of the telegraf config file if this is of help to anyone else:
data_format = "json_v2"
tagexclude = ["topic"]
[[inputs.mqtt_consumer.json_v2]]
measurement_name = "a"
timestamp_path = "obj.#.time"
timestamp_format = "unix"
[[inputs.mqtt_consumer.json_v2.tag]]
path = "gmac"
# g is gateway MAC address
rename = "g"
[[inputs.mqtt_consumer.json_v2.tag]]
path = "obj.#.dmac"
# d is beacon MAC address
rename = "d"
[[inputs.mqtt_consumer.json_v2.field]]
path = "obj.#.rssi"
type = "int"
# r is RSSI of beacon
rename = "r"
[[inputs.mqtt_consumer.json_v2.field]]
path = "obj.#.data1"
data_type = "string"
[[processors.starlark]]
namepass = ["a"]
source = '''
def apply(metric):
data1 = metric.fields.pop("data1")
tempWhole = int("0x" + data1[26:28], 0)
tempDecimal = int("0x" + data1[28:30], 0)
tempDecimal = tempDecimal / 100
# t is temperature of chip to two decimal points precision
metric.fields["t"] = tempWhole + tempDecimal
# b is battery level in mV
metric.fields["b"] = int("0x" + data1[30:34], 0)
return metric
'''
Context: Running F# in a containerized environment
$ dotnet --version 2.2.203
$ uname -a
Linux SAFE 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 GNU/Linux
on Ubuntu 18.04 desktop machine.
This simple code ignores the [<BsonIgnore>] attribute. The value of Ignore is stored in LiteDB. Am I doing something wrong?
I've checked it by looking with the console command $ dotnet LiteDB.Shell.dll micompany.db:
...
> open micompany.db
> db.computers.find
[1]: {"_id":11,"Ignore":"ignore","Manufacturer":"Computers Inc.","Disks":[{"SizeGb":100},{"SizeGb":250},{"SizeGb":500}]}
This is the code:
open System
open LiteDB
open LiteDB.FSharp
[<StructuredFormatDisplay("{SizeGb}GB")>]
[<CLIMutable>]
type Disk =
{ SizeGb : int }
[<StructuredFormatDisplay("Computer #{Id}: {Manufacturer}/{Disks}")>]
[<CLIMutable>]
type Computer =
{ Id: int
[<BsonIgnore>] Ignore : string
Manufacturer: string
Disks: Disk list }
[<EntryPoint>]
let main argv =
let myPc =
{ Id = 0
Ignore = "ignore"
Manufacturer = "Computers Inc."
Disks =
[ { SizeGb = 100 }
{ SizeGb = 250 }
{ SizeGb = 500 } ] }
let mapper = FSharpBsonMapper()
use db = new LiteDatabase("micompany.db", mapper)
let computers = db.GetCollection<Computer>("computers")
// Insert & Print
computers.Insert(myPc) |> ignore
printfn "%A" myPc
0 // return an integer exit code
On the other hand, the [<StructuredFormatDisplay>] attribute of the Disk record is not correctly written (only a few dots appear in the console), when the Computer record is printed with printfn "%A" myPc. The output is:
Computer #12: Computers Inc./[...GB; ...GB; ...GB]
Is there anything else I need to say?
I have tried using a Yaml collection of maps in my config file :
Companies:
- code: 11
name: A
country: FR
functionalCurrency: EUR
- code: 12
name: B
country: GB
functionalCurrency: GBP
However, when trying to read it with the type provider, it only finds the first result of the list.
With :
open FSharp.Configuration
type CompaniesConfig = YamlConfig<"Config.yaml">
let config = CompaniesConfig()
the output is :
val config : CompaniesConfig =
Companies:
- code: 11
name: A
country: FR
functionalCurrency: EUR
Trying to parse the code online worked, hence I wonder if that is a library limitation or... ?
Thanks for your help
You need to actually load the file, not only get the schema if you want to work with it directly: config.Load(yamlFile). This should probably more explicit in the documentation. I used the sample file in the link.
#if INTERACTIVE
#r #"..\packages\FSharp.Configuration.0.6.1\lib\net40\FSharp.Configuration.dll"
#endif
open FSharp.Configuration
open System.IO
/// https://github.com/fsprojects/FSharp.Configuration/blob/master/tests/FSharp.Configuration.Tests/Lists.yaml
[<Literal>]
let yamlFile = __SOURCE_DIRECTORY__ + "..\Lists.yaml"
File.Exists yamlFile
type TestConfig = YamlConfig<yamlFile>
let config = TestConfig()
config.Load(yamlFile)
config.items.Count
config.items
And I get both items:
>
val it : int = 2
>
val it : System.Collections.Generic.IList<TestConfig.items_Item_Type> =
seq
[FSharp.Configuration.TestConfig+items_Item_Type
{descrip = "Water Bucket (Filled)";
part_no = "A4786";
price = 147;
quantity = 4;};
FSharp.Configuration.TestConfig+items_Item_Type
{descrip = "High Heeled "Ruby" Slippers";
part_no = "E1628";
price = 10027;
quantity = 1;}]
>
I'm running a fresh installation of Oracle 12c on Solaris 10 and I can connect to the CDB using toad just fine, please tell me how can I now connect to the PDB database named PDBORCL as mentioned in the guide: https://oracle-base.com/articles/12c/multitenant-connecting-to-cdb-and-pdb-12cr1
Following are the contents of my tnsnames.ora file:
# tnsnames.ora Network Configuration File: /bkofa/oracle/app/oracle
/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL12 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl12)
)
)
pdbORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdborcl)
)
)
Here are the contents of my listener.ora file:
# listener.ora Network Configuration File: /bkofa/oracle/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = afxortsts)(PORT = 1523))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl12)
(SID_NAME = orcl12)
)
(SID_DESC =
(GLOBAL_DBNAME = pdborcl)
(SID_NAME = pdborcl)
)
)
These are the containers by the way:
SELECT name, pdb
FROM v$services
ORDER BY name;
NAME PDB
SYS$BACKGROUND CDB$ROOT
SYS$USERS CDB$ROOT
orcl12 CDB$ROOT
orcl12XDB CDB$ROOT
pdborcl PDBORCL
Still when I try to connect to PDB using any combination of commands this is what I get:
bash-3.2$ lsnrctl status
LSNRCTL for Solaris: Version 12.1.0.2.0 - Production on 13-APR-2016 15:42:28
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=afxortsts)(PORT=1523)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Solaris: Version 12.1.0.2.0 - Production
Start Date 12-APR-2016 13:56:56
Uptime 1 days 1 hr. 45 min. 36 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /bkofa/oracle/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /bkofa/oracle/app/oracle/diag/tnslsnr/afxortsts/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=afxortsts)(PORT=1523)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "orcl12" has 1 instance(s).
Instance "orcl12", status UNKNOWN, has 1 handler(s) for this service...
Service "pdborcl" has 1 instance(s).
Instance "pdborcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
bash-3.2$ sqlplus '/ as sysdba'
SQL*Plus: Release 12.1.0.2.0 Production on Wed Apr 13 15:42:44 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> connect sys/oracle123#172.16.1.118:1523/pdborcl as sysdba
ERROR:
ORA-01017: invalid username/password; logon denied
Warning: You are no longer connected to ORACLE.
SQL> connect sys#pdborcl
Enter password:
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SVR4 Error: 2: No such file or directory
Additional information: 2581
Additional information: -2057892281
Process ID: 0
Session ID: 0 Serial number: 0
SQL> connect sys#172.16.1.118:1523/pdborcl as sysdba
ERROR:
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
SQL>
Oh I should make this clear that I'm using port 1523 because there is another instance of older Oracle 10g already running on the system that uses this port so I wanted to avoid any conflict with that.
You should not declare the services in the SID_LIST_LISTENER. Especially the pdborcl which is not an instance but a service within the instance. So remove this part:
(SID_DESC =
(GLOBAL_DBNAME = pdborcl)
(SID_NAME = pdborcl)
)
The instance should register itself to the listener. If not done, you should, when connected to the CDB:
alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=afxortsts)(PORT=1523))) ';
alter system register;
Below my config which works:
listener.ora:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1525))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1525))
)
)
tnsnames.ora:
LISTENER_CATCDB =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1526))
# CDB
CATCDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1526))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = catcdb)
)
)
# PDB
CATDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1526))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = catdb)
)
)
I receive error message 8017:
The UserId, Password or account is invalid while trying to load data
using fast load.
Fast Load Script:
logon 10.61.59.93/796207,Wpwp123;
drop table DATAMDL_SNDBX.QA_FL_PD;
drop table DATAMDL_SNDBX.ERROR_TABLE_ucv;
drop table DATAMDL_SNDBX.ERROR_TABLE_TV;
CREATE SET TABLE DATAMDL_SNDBX.QA_FL_PD ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
NAME VARCHAR(10) CHARACTER SET LATIN NOT CASESPECIFIC,
INITIAL VARCHAR(10) CHARACTER SET LATIN NOT CASESPECIFIC)
PRIMARY INDEX CRO_FLIGHT_LEG_DEP_NUPI ( NAME );
SET RECORD VARTEXT'~';
DEFINE
NAME (VARCHAR(10)),
INITIAL (VARCHAR(10))
FILE = C:\Users\Scarlet\Desktop\FL_Data.TXT;
BEGIN LOADING DATAMDL_SNDBX.QA_FL_PD ERRORFILES teradata fastload.ERROR_TABLE_UCV, teradata fastload.ERROR_TABLE_TV;
INSERT INTO DATAMDL_SNDBX.QA_FL_PD
VALUES (:NAME,
:INITIAL);
END LOADING;
LOGOFF;
File containing data (with only 1 record):
NAME~INITIAL
PRASHANT~PD
Error Message:
C:\Windows\system32>cd\
C:\>fastload<C:\Users\Scarlet\Desktop\FL_Script.TXT
===================================================================
= =
= FASTLOAD UTILITY VERSION 14.10.00.03 =
= PLATFORM WIN32 =
= =
===================================================================
===================================================================
= =
= Copyright 1984-2013, Teradata Corporation. =
= ALL RIGHTS RESERVED. =
= =
===================================================================
**** 14:08:03 Processing starting at: Thu Mar 10 14:08:02 2016
===================================================================
= =
= Logon/Connection =
= =
===================================================================
0001 logon 10.61.59.93/796207,
**** 14:08:03 RDBMS error 8017: The UserId, Password or Account is
invalid.
**** 14:08:03 Unable to log on Main SQL Session
**** 14:08:03 FastLoad cannot continue. Exiting.
===================================================================
= =
= Exiting =
= =
===================================================================
**** 14:08:03 Total processor time used = '0.124801 Seconds'
. Start : Thu Mar 10 14:08:02 2016
. End : Thu Mar 10 14:08:03 2016
. Highest return code encountered = '12'.
**** 14:08:03 FDL4818 FastLoad Terminated
The problem was, I should have mentioned what mechanism I should be using to connect.
Adding below line at the top solved my problem
logmech LDAP;
Problem solved.. :)
I do not know how to close this thread.
Thanks
Prashant