Recently we were making MIB files for NMS system, while doing so I came across that after deploying the MIBs on Linux machine to query it I need to add 101.1 at the end, where as for standard Linux mibs only .0 needs to be appended. I am not able to understand this that why my value is returned in 101.1 and not .0.
For example when I do this with linux MIBs I get the value
snmpget -v 2c -c public localhost 1.3.6.1.2.1.1.3.0
SNMPv2-MIB::sysUpTime.0 = Timeticks: (105543) 0:17:35.43
But for my mib to work I need to append 101.1
snmpwalk -v 2c localhost -c public .1.3.6.1.4.1.****.1.2.3.101.1
SNMPv2-SMI::enterprises.****.1.2.3.101.1 = STRING: "388 MB"
When I do a walk with my MIB I get the following .
snmpwalk -v 2c localhost -c public .1.3.6.1.4.1.****.1.2.3
SNMPv2-SMI::enterprises.****.1.2.3.1.1 = INTEGER: 1
SNMPv2-SMI::enterprises.****.1.2.3.2.1 = STRING: "getSystemMemoryUsage.sh"
SNMPv2-SMI::enterprises.****.1.2.3.3.1 = STRING:
"/opt/nagios/plugins/fetch_scripts/System/getSystemMemoryUsage.sh"
SNMPv2-SMI::enterprises.****.1.2.3.100.1 = INTEGER: 0
SNMPv2-SMI::enterprises.****.1.2.3.101.1 = STRING: "388 MB"
SNMPv2-SMI::enterprises.****.1.2.3.102.1 = INTEGER: 0
SNMPv2-SMI::enterprises.****.1.2.3.103.1 = ""
Can any one advice why such behavior in our MIB and what needs to be done so that my MIB behave like Linux Mibs where I just add .0 at the end and get the value.
The OBJECT TYPE is scalar for all .
Thanking you all in advance
The MIB nomenclature supports data represented as table's rows and non-tabular scalars. Data which are presented as scalars are accessed by using OID.0 index. The ".0" part indicates access to scalar object - single object instance in the system. The tables contain columns (each column represent some kind of data) and rows (each row represent a table instance - some kind of entity which does support that table).
In your example, you try to access some table in your Enterprise MIB. This table contain an index (there may be single or multiple indexed MIB tables). To determine first available index in that table you can start with snmpgetnext command in following way:
snmpgetnext -v2c -c public localhost .1.3.6.1.4.1.****.1.2.3
or
snmpgetnext -v2c -c public localhost .1.3.6.1.4.1.****.1.2.3.0
or
snmpgetnext -v2c -c public localhost .1.3.6.1.4.1.****.1.2.3.0.0
As you can see all of the above commands give you first existing row instance by updating two last OID parts (.0.0). These two OIDs don't have to be specified explicitly, therefore you may use only one null-index (.0) or even don't have to specify them at all.
To understand how these table's indexes are described you need to refer to your Enterprise MIB - find table described by this OID: .1.3.6.1.4.1.**.1.2.3 and learn about indexing scheme and what does these indexes represent. Well-written MIB should contain this information.
Interpretation may be following:
*.1.1 = 1 - data column with id=1 for entity index 1
*.2.1 = "getSystemMemoryUsage.sh" - data column with id=2 for entity index 1 representing script name (STRING syntax)
*.3.1 = "/opt/nagios/plugins/fetch_scripts/System/getSystemMemoryUsage.sh" - data column with id=3 for entity index 1 representing full script's path (STRING syntax)
*.100.1 = 0 - data column with id=100 for entity index 1 representing some INTEGER value
and so on...
Column indexing (.1, .2, .3, .100, .101 ...) may contain gaps if MIB designers expect to add some columns in future between .3 and .100. or simply entity index 1 does not support these columns (if they are defined in MIB). It is allowed to skip empty columns.
If you would like to read about differences between scalar and columnar objects, please refer to i.e. RFC1212.
Related
I could need some help with a Anylogic Model.
Model (short): Manufacturing scenario with orders move in a individual route. The workplaces (WP) are dynamical created by simulation start. Their names, quantity and other parameters are stored in a database (excel Import). Also the orders are created according to an import. The Agent population "order" has a collection routing which contains the Workplaces it has to stop in the specific order.
Target: I want a moveTo block in main which finds the next destination of the agent order.
Problem and solution paths:
I set the destination Type to agent and in the Agent field I typed a function agent.getDestination(). This function is in order which returns the next entry of the collection WP destinationName = routing.get(i). With this I get a Datatype error (while run not compiling). I quess it's because the database does not save the entrys as WP Type but only String.
Is there a possiblity to create a collection with agents from an Excel?
After this I tried to use the same getDestination as String an so find via findFirst the WP matching the returned name and return it as WP. WP targetWP = findFirst(wps, w->w.name == destinationName);
Of corse wps (the population of Workplaces) couldn't be found.
How can I search the population?
Maybe with an Agentlink?
I think it is not that difficult but can't find an answer or a solution. As you can tell I'm a beginner... Hope the description is good an someone can help me or give me a hint :)
Thanks
Is there a possiblity to create a collection with agents from an Excel?
Not directly using the collection's properties and, as you've seen, you can't have database (DB) column types which are agent types.1
But this is relatively simple to do directly via Java code (and you can use the Insert Database Query wizard to construct the skeleton code for you).
After this I tried to use the same getDestination as String an so find via findFirst the WP matching the returned name and return it as WP
Yes, this is one approach. If your order details are in Excel/the database, they are presumably referring to workplaces via some String ID (which will be a parameter of the workplace agents you've created from a separate Excel worksheet/database table). You need to use the Java equals method to compare strings though, not == (which is for comparing numbers or whether two objects are the same object).
I want a moveTo block in main which finds the next destination of the agent order
So the general overall solution is
Create a population of Workplace agents (let's say called workplaces in Main) from the DB, each with a String parameter id or similar mapped from a DB column.
Create a population of Order agents (let's say called orders in Main) from the DB and then, in their on-startup action, set up their collection of workplace IDs (type ArrayList, element class String; let's say called workplaceIDsList) using data from another DB table.
Order probably also needs a working variable storing the next index in the list that it needs to go to (so let's say an int variable nextWorkplaceIndex which starts at 0).
Write a function in Main called getWorkplaceByID that has a single String argument id and returns a Workplace. This gets the workplace from the population that matches the ID; a one-line way similar to yours is findFirst(workplaces, w -> w.id.equals(id)).
The MoveTo block (which I presume is in Main) needs to move the Order to an agent defined by getWorkplaceByID(agent.workplaceIDsList.get(nextWorkplaceIndex++)). (The ++ bit increments the index after evaluating the expression so it is ready for the next workplace to go to.)
For populating the collection, you'd have two tables, something like the below (assuming using strings as IDs for workplaces and orders):
orders table: columns for parameters of your orders (including some String id column) other than the workplace-list. (Create one Order agent per row.)
order_workplaces table: columns order_id, sequence_num and workplace_id (so with multiple rows specifying the sequence of workplace IDs for an order ID).
In the On startup action of Order, set up the skeleton query code via the Insert Database Query wizard as below (where we want to loop through all rows for this order's ID and do something --- we'll change the skeleton code to add entries to the collection instead of just printing stuff via traceln like the skeleton code does).
Then we edit the skeleton code to look like the below. (Note we add an orderBy clause to the initial query so we ensure we get the rows in ascending sequence number order.)
List<Tuple> rows = selectFrom(order_workplaces)
.where(order_workplaces.order_id.eq(id))
.orderBy(order_workplaces.sequence_num.asc())
.list();
for (Tuple row : rows) {
workplaceIDsList.add(row.get(order_workplaces.workplace_id));
}
1 The AnyLogic database is a normal relational database --- HSQLDB in fact --- and databases only understand their own specific data types like VARCHAR, with AnyLogic and the libraries it uses translating these to Java types like String. In the user interface, AnyLogic makes it look like you set the column types as int, String, etc. but these are really the Java types that the columns' contents will ultimately be translated into.
AnyLogic does support columns which have option list types (and the special Code type column for columns containing executable Java code) but these are special cases using special logic under the covers to translate the column data (which is ultimately still a string of characters) into the appropriate option list instance or (for Code columns) into compiled-on-the-fly-and-then-executed Java).
Welcome to Stack Overflow :) To create a Population via Excel Import you have to create a method and call Code like this. You also need an empty Population.
int n = excelFile.getLastRowNum(YOUR_SHEET_NAME);
for(int i = FIRST_ROW; i <= n; i++){
String name = excelFile.getCellStringValue(YOUR_SHEET_NAME, i, 1);
double SEC_PARAMETER_TO_READ= excelFile.getCellNumericValue(YOUR_SHEET_NAME, i, 2);
WP workplace = add_wps(name, SEC_PARAMETER_TO_READ);
}
Now if you want to get a workplace by name, you have to create a method similar to your try.
Functionbody:
WP workplaceToFind = wps.findFirst(w -> w.name.equals(destinationName));
if(workplaceToFind != null){
//do what ever you want
}
I know you can look at the size of an uncompressed backup, but that's not practical.
Is there a command to find the size of the database while it is online? (In Linux/Unix/windows)
When connected to a database as db2admin (or with similar permissions), use the following command:
call get_dbsize_info(?,?,?,-1);
The first three parameters are output parameters:
Value of output parameters
--------------------------
Parameter Name : SNAPSHOTTIMESTAMP
Parameter Value : 2014-06-17-13.59.55.049000
Parameter Name : DATABASESIZE
Parameter Value : 334801764352
Parameter Name : DATABASECAPACITY
Parameter Value : 1115940028416
Return Status = 0
The size is given in bytes, so divide by 1024^3 to get Gb.
The final parameter is how often the snapshot is refreshed. -1 is to use default settings.
Further reading...
Note: This command does not take into account logs, etc. - so, it may appear much larger on disk.
Use db2top
l(for session)
p(when press small p it will show the total size of db n used size of db)
For specific schema, in KBytes, use:
SELECT sum(TOTAL_P_SIZE) FROM (
SELECT TABNAME, (DATA_OBJECT_P_SIZE + INDEX_OBJECT_P_SIZE + LONG_OBJECT_P_SIZE +
LOB_OBJECT_P_SIZE + XML_OBJECT_P_SIZE) as TOTAL_P_SIZE
FROM SYSIBMADM.ADMINTABINFO
WHERE TABSCHEMA='PUBLIC'
)
Reference: https://www.ibm.com/support/pages/how-do-i-find-out-disk-space-usage-managing-server-octigate-database-tables
Following command will show you memory used by database online :
db2pd -dbptnmem
You can monitor variety of stuff with db2pd command :
https://www.ibm.com/docs/en/db2/11.1?topic=commands-db2pd-monitor-troubleshoot-db2-engine-activities
I've over 5 million key-value pairs stored in REDIS server. Incoming key, which we need to search in REDIS server will be like "key_num_id" format.
Keys and values are stored in the REDIS server like "key_pfx_id" format. All keys will be unique key (No two keys would be same). Below are few examples:
key_1234_11
key_123_12
key_123_11
key_12_11
..
..
where 1234, 123, 12 are the prefix of num in incoming key key_num_id.
Now, for example if we get key_1234567890_11 as the incoming key then REDIS should give value corresponding to "key_1234_11" which is the best match for the "num" we got in incoming key "1234567890" in our example.
One way is to do this is query the REDIS server multiple times till we got the value; e.g.
GET key_1234567890_11
GET key_123456789_11
GET key_12345678_11
GET key_1234567_11
.
.
But I think this is the costly solution as I'm getting around 2000 incoming keys in a second. So want to have optimized solution. Can anyone help in this as I'm newbie in REDIS
NOTE: I'm doing all above in C code
One way you could do this in a single call to Redis is put the iteration logic in a Lua script.
local input = KEYS[1]
local key, output
while string.len(input) > 1 do
key = "test_" .. input .. "_11"
output = redis.call("GET", key)
if output then return output end
input = string.sub(input, 1, string.len(input) - 1)
end
return nil
When called (redis.eval(script_body, ["12345678"])) it should correctly return the value of key_1234_11. This is a trivial example, obviously, and will need to be further tailored for your application.
This saves you the overhead of making many calls to redis, but, I guess compared to C then Lua itself might be a bit of an overhead. I can't be certain a Lua script is faster in this scenario, but it may be.
I have a question taken from pg 16 of IBM's Nested Relational Database White Paper, I'm confused why in the below CREATE command they use MV/MS/MS rather than MV/MV/MS, when both ORDER_#, and PART_# are one-to-many relationships.. I don't understand what value, vs sub-value means in non-1nf database design. I'd also like to know to know more about the ASSOC () clause.
Pg 16 of IBM's Nested Relational Database White Paper (slight whitespace modifications)
CREATE TABLE NESTED_TABLE (
CUST# CHAR (9) DISP ("Customer #),
CUST_NAME CHAR (40) DISP ("Customer Name"),
ORDER_# NUMBER (6) DISP ("Order #") SM ("MV") ASSOC ("ORDERS"),
PART_# NUMBER (6) DISP (Part #") SM ("MS") ASSOC ("ORDERS"),
QTY NUMBER (3) DISP ("Qty.") SM ("MS") ASSOC ("ORDERS")
);
The IBM nested relational databases implement nested tables as repeating attributes and
repeating groups of attributes that are associated. The SM clauses specify that the attribute is either repeating (multivalued--"MV") or a repeating group (multi-subvalued--"MS"). The ASSOC clause associates the attributes within a nested table. If desired, the IBM nested relational databases can support several nested tables within a base table. The following standard SQL statement would be required to process the 1NF tables of Figure 5 to produce the report shown in Figure 6:
SELECT CUSTOMER_TABLE.CUST#, CUST_NAME, ORDER_TABLE.ORDER_#, PART_#, QTY
FROM CUSTOMER_TABLE, ORDER_TABLE, ORDER_CUST
WHERE CUSTOMER_TABLE.CUST_# = ORDER_CUST.CUST_# AND ORDER_CUST.ORDER_# =
ORDER _TABLE.ORDER_#;
Nested Table
Customer # Customer Name Order # Part # Qty.
AA2340987 Zedco, Inc. 93-1123 037617 81
053135 36
93-1154 063364 32
087905 39
GV1203948 Alphabravo 93-2321 006776 72
055622 81
067587 29
MT1238979 Trisoar 93-2342 005449 33
036893 52
06525 29
93-4596 090643 33
I'll go ahead and answer my own question, while pursuing IBM's UniVerse SQL Administration for DBAs I came across code for CREATE TABLE on pg 55.
ACT_NO INTEGER FORMAT '5R' PRIMARY KEY
BADGE_NO INTEGER FORMAT '5R' PRIMARY KEY
ANIMAL_ID INTEGER FORMAT '5L' PRIMARY KEY
(see distracting side note below) This amused me at first, but essentially I believe this to be a column directive the same as a table directive like PRIMARY ( ACT_NO, BADGE_NO, ANIMAL_ID )
Later on page 5-19, I saw this
ALTER TABLE LIVESTOCK.T ADD ASSOC VAC_ASSOC (
VAC_TYPE KEY, VAC_DATE, VAC_NEXT, VAC_CERT
);
Which leads me to believe that tacking on ASSOC (VAC_ASSOC) to a column would be the same... like this
CREATE TABLE LIVESTOCK.T (
VAC_TYPE ... ASSOC ("VAC_ASSOC")
VAC_DATE ... ASSOC ("VAC_ASSOC")
VAC_NEXT ... ASSOC ("VAC_ASSOC")
VAC_cERT ... ASSOC ("VAC_ASSOC")
);
Anyway, I'm not 100% sure I'm right, but I'm guessing the order doesn't matter, and that rather than these being an intransitive association they're just a order-insensitive grouping.
Onward! With the second part of the question pertaining to MS and MV, I for the life of me can not figure out where the hell IBM got this syntax from. I believe it to be imaginary. I don't have access to a dev machine I can play on to test this out, but I can't find it (the term MV) in the old 10.1 or the new UniVerse 10.3 SQL Reference
side note for those not used to UniVerse the 5R and 5L mean 5 characters right or left justified. That's right a display feature built into the table meta data... Google for UniVerse FORMAT (or FMT) for more info.
Just so you know, Attribute, Multivalue and Sub-Multivalue comes from the way they structure their data.
Essentially, all data is stored in a tree of sorts.
UniVerse is a Multivalue Database. Generally, it does not work in the say way as Relational DBs of the SQL work function.
Each record can have multiple attributes.
Each attribute can have multiple multivalues.
Each multivalue can have multiple sub-multivalues.
So, if I have a record called FRED
Then, FRED<1,2,3> refers to the 1st attribute, 2 multivalue position and 3 subvalue position.
To read more about it, you need to learn more about how UniVerse works. The SQL section is just a side part of it. I suggest you read the other manuals to understand what you are working with.
EDIT
Essentially, the code above is telling you that:
There may be multiple orders per client. These are stored at an MV level in the 'table'
There may be multiple parts per order. These are stored at the MS level in the 'table'
There may be multiple qtys per order. These are stored at the MS level in the 'table'. since they are at the same level, although they are 1-n for orders, they are 1-1 in regards to parts.
How can you find out what are the long running queries are on Informix database server? I have a query that is using up the CPU and want to find out what the query is.
If the query is currently running watch the onstat -g act -r 1 output and look for items with an rstcb that is not 0
Running threads:
tid tcb rstcb prty status vp-class name
106 c0000000d4860950 0 2 running 107soc soctcppoll
107 c0000000d4881950 0 2 running 108soc soctcppoll
564457 c0000000d7f28250 c0000000d7afcf20 2 running 1cpu CDRD_10
In this example the third row is what is currently running. If you have multiple rows with non-zero rstcb values then watch for a bit looking for the one that is always or almost always there. That is most likely the session that your looking for.
c0000000d7afcf20 is the address that we're interested in for this example.
Use onstat -u | grep c0000000d7afcf20 to find the session
c0000000d7afcf20 Y--P--- 22887 informix - c0000000d5b0abd0 0 5 14060 3811
This gives you the session id which in our example is 22887. Use onstat -g ses 22887
to list info about that session. In my example it's a system session so there's nothing to see in the onstat -g ses output.
That's because the suggested answer is for DB2, not Informix.
The sysmaster database (a virtual relational database of Informix shared memory) will probably contain the information you seek. These pages might help you get started:
http://docs.rinet.ru/InforSmes/ch22/ch22.htm
http://www.informix.com.ua/articles/sysmast/sysmast.htm
Okay it took me a bit to work out how to connect to sysmaster. The JDBC connection string is:
jdbc:informix-sqli://dbserver.local:1526/sysmaster:INFORMIXSERVER=mydatabase
Where the port number is the same as when you are connecting to the actual database. That is if your connection string is:
jdbc:informix-sqli://database:1541/crm:INFORMIXSERVER=crmlive
Then the sysmaster connection string is:
jdbc:informix-sqli://database:1541/sysmaster:INFORMIXSERVER=crmlive
Also found this wiki page that contains a number of SQL queries for operating on the sysmaster tables.
SELECT ELAPSED_TIME_MIN,SUBSTR(AUTHID,1,10) AS AUTH_ID,
AGENT_ID, APPL_STATUS,SUBSTR(STMT_TEXT,1,20) AS SQL_TEXT
FROM SYSIBMADM.LONG_RUNNING_SQL
WHERE ELAPSED_TIME_MIN > 0
ORDER BY ELAPSED_TIME_MIN DESC
Credit: SQL to View Long Running Queries