Possible to use snmpget to retrieve one value from table item - snmp

Folks, working on a script to retrieve a specific MIB that is in a table object, e.g.
ltmRouteDomainStatTable OBJECT-TYPE
SYNTAX SEQUENCE OF LtmRouteDomainStatEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"A table containing statistic information of route domains."
LtmRouteDomainStatEntry ::=
SEQUENCE {
ltmRouteDomainStatName LongDisplayString,
ltmRouteDomainStatConnLimit Gauge,
ltmRouteDomainStatConnectionFlowMiss Counter64,
ltmRouteDomainStatClientPktsIn Counter64,
ltmRouteDomainStatClientBytesIn Counter64,
.....
I only want ltmRouteDomainStatClientPktsIn, but it seems the only way to reach it, without using a numeric OID is to get the entire table:
snmptable -v2c -Lo -c xxxx 1.2.3.4 F5-BIGIP-LOCAL-MIB::ltmRouteDomainStatTable
SNMP table: F5-BIGIP-LOCAL-MIB::ltmRouteDomainStatTable
ltmRouteDomainStatName ltmRouteDomainStatConnLimit ltmRouteDomainStatConnectionFlowMiss ltmRouteDomainStatClientPktsIn ltmRouteDomainStatClientBytesIn ltmRouteDomainStatClientPktsOut ltmRouteDomainStatClientBytesOut ltmRouteDomainStatClientMaxConns ltmRouteDomainStatClientTotConns ltmRouteDomainStatClientCurConns ltmRouteDomainStatClientEvictedConns ltmRouteDomainStatClientSlowKilled ltmRouteDomainStatServerPktsIn ltmRouteDomainStatServerBytesIn ltmRouteDomainStatServerPktsOut ltmRouteDomainStatServerBytesOut ltmRouteDomainStatServerMaxConns ltmRouteDomainStatServerTotConns ltmRouteDomainStatServerCurConns ltmRouteDomainStatServerEvictedConns ltmRouteDomainStatServerSlowKilled
/Common/0 0 0 162 12312 0 0 60 60 0 0 0 5135356 570128703 5106503 204356528 60 60 0 0 0
I thought perhaps I might be able to add the index to the snmpget query, but no luck, e.g
snmpget -v2c -Lo -c xxxx 1.2.3.4 F5-BIGIP-LOCAL-MIB::ltmRouteDomainStatClientPktsIn.'/Common/0'
I can parse the snmptable output to get single value I want ... is there an easier way?

Yes, you can do what you want in a couple of ways:
if the table only has one row, do
snmpgetnext .... F5-BIGIP-LOCAL-MIB::ltmRouteDomainStatClientPktsIn
convert the index string of your row to a list of sub IDs, taking into
consideration the variable length octet string encoding. If you walk the
table with snmpwalk you should get the index values in that format. Then use
snmpget ... F5-BIGIP-LOCAL-MIB::ltmRouteDomainStatClientPktsIn.INDICES
where INDICES is the list of sub IDs.

Related

SAS Macros in Datalines

I have a two part question about creating datasets in SAS that calls upon macro variables
Part 1
I'm trying to create a dataset that has one character variable called variable with a length of 100, and 3 observations.
%let first_value=10;
%let second_value=20;
%let third_value=30;
data temp;
infile cards truncover;
input variable $100.;
cards;
First Value: &first_value
Second Value: &second_value
Third Value: &third_value
;
run;
My output dataset doesn't show the macro variables, just the exact text I entered in the datalines. I would love help on syntax of how to concatenate character input with a macro variable. Also I'm curious why sometimes you need a separate length statement for character variables before the input statement when other times you can just specify the length in the input statement like above.
Part 2
Next, I'm trying to create a dataset that has one observation with 4 variables, 3 of which are macro variables.
data temp2;
infile cards dlm=" "
input variable $ first_var second_var third_var
cards;
Observation 1 Filler &first_value &second_value &third_value
;
run;
The 4 spaces in the delimiter statement and between variables in the datalines are actually tabs in my code.
Thanks!
Your examples do not seem to be worth using macro variables.
But if you really need to resolve macro expressions in variable values then use the RESOLVE() function. The RESOLVE() will evaluate all macro code in the text, not just the macro variable references in your example. So any macro function calls and calls to actual macros will be resolved and the generated text returned as the result of the function.
newvar=resolve(oldvar);
So your examples become:
data temp;
infile cards truncover;
input variable $100.;
variable = resolve(variable);
cards;
First Value: &first_value
Second Value: &second_value
Third Value: &third_value
;
data temp2;
infile cards dlm="|" ;
input #;
_infile_=resolve(_infile_);
input variable :$100. first_var second_var third_var ;
cards;
Observation 1 Filler|&first_value|&second_value|&third_value
;
But on the second one be careful as the _INFILE_ variable for CARDS images are fixed multiples of 80 bytes so if the resolved macro expressions make the string longer than the next 80 byte boundary you will lose the extra text.
511 %let xx=%sysfunc(repeat(----+----0,8));
512
513 data test;
514 infile cards truncover;
515 input #;
516 _infile_=resolve(_infile_);
517 input variable $100. ;
518 length=lengthn(variable);
519 put length= variable=;
520 cards;
length=5 variable=short
length=80 variable=long ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+
NOTE: The data set WORK.TEST has 2 observations and 2 variables.
So use input from an actual file instead. That way the limit is instead the 32,767 byte limit for a character variable.
%let xx=%sysfunc(repeat(----+----0,8));
options parmcards=text;
filename text temp;
parmcards;
short
long &xx
;
531
532
533 data test;
534 infile text truncover;
535 input #;
536 _infile_=resolve(_infile_);
537 input variable $100. ;
538 length=lengthn(variable);
539 put length= variable=;
540 run;
NOTE: The infile TEXT is:
Filename=C:\...\#LN00053,
RECFM=V,LRECL=32767,File Size (bytes)=17,
Last Modified=08Jul2022:23:42:10,
Create Time=08Jul2022:23:42:10
length=5 variable=short
length=95 variable=long ----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0----+----0
NOTE: 2 records were read from the infile TEXT.
The minimum record length was 5.
The maximum record length was 8.
NOTE: The data set WORK.TEST has 2 observations and 2 variables.

Change value psql where value between, as string

I have a query that must set a value if the number is between 2 values, but the output is not ok, I think because that column is a string. Any way to do it even it's string?
(In output I have value as , 5 witch is not ok).
All the values that are incorrect are Integer.
SET lkp_age_category_id = 7
WHERE
age BETWEEN '26' and '35.99';
I guess, only working on the SQL side, you could cast the values right into the query, e.g.:
SET lkp_age_category_id = 7
WHERE age BETWEEN '26'::float AND '35.99'::float;
Also check this answer https://stackoverflow.com/a/13809603/917617.

Total size of similar indices

Kibana shows statistics for every index on the monitoring page 1. How can we group indices by type to get their overall size? For example I've got a lot of winlogbeat-6.2.2-YYYY.mm.dd indices and would like to know how much space do all of them consume in total.
thanks!
One way to achieve what you want is to use the Index stats API, and filter out the store.size_in_bytes value, like this:
winlogbeat-6.2.2*/_stats?filter_path=_all.total.store.size_in_bytes
You'll get a response like this:
{
"_all": {
"total": {
"store": {
"size_in_bytes": 922069687976
}
}
}
}
Another way to achieve what you want involves leveraging the Cat APIs, a bit of grep and a tad of awk...
The following shell command will give you the number of bytes consumed by all your winlogbeat-6.2.2 indices:
curl -s localhost:9200/_cat/indices?bytes=b | grep winlogbeat-6.2.2 | awk '{s+=$9} END {print s}'
You'll get a single number, like this: 922069687976
Let me explain:
The first command will retrieve all indices via the _cat/indices API.
curl -s localhost:9200/_cat/indices?bytes=b
The second command keeps only the indices matching winlogbeat-6.2.2
grep winlogbeat-6.2.2
The last command does the magic of summing up all numbers in the 9th column (i.e. store.size)
awk '{s+=$9} END {print s}'
VoilĂ ...
If you collect monitoring stats for your cluster, when you could use Kibana for visualization:
Prerequisites: X-Pack which will be creating .monitoring-* indices.
Create a scripted field for the index pattern .monitoring-es-6-*:
Field name: normalized_index_name (will work for for SOME-INDEX-YYYY.MM.DD pattern only as it removes everything from the index name after the last dash, a scripted field with a regex can be used, but regex fields must be explicitly allowed in the ES config):
def name = doc['index_stats.index'].value;
if (name != null) {
int lastDashIndex = name.lastIndexOf('-');
if (lastDashIndex > 0) {
return name.substring(0,lastDashIndex);
}
}
return name
Create a Line visualization. Note:
time frame should be set to 7 days
start to build the visualization from X-axis, otherwise it may not split series properly (bug?..)!

Data import integer start with zero

I'm using clickhouse for the first time, and when I'm doing import like this:
cat /home/data/_XDR_IMPORT_1001_20001010_000001_.tsv | clickhouse-client --password=123 --query="INSERT INTO ts FORMAT TSV";
It gives me an error:
Column 13, name: dpc, type: Nullable(Int32), parsed text: "0"
ERROR: garbage after Nullable(Int32): "3242"
And this is because I have a column (dpc) in type Int32 and the value of this column is 03242, so it seems the import process takes only 0 and trying to find the tap after it.
Please help anyone?
ok, you can use following command:
sed -E "s/(\t+)0([0-9]+)/\1\2/g" 1.tsv /home/data/_XDR_IMPORT_1001_20001010_000001_.tsv | clickhouse-client --password=123 --query="INSERT INTO ts FORMAT TSV";
and hope first column doesn't contains leading zero ;)
change dpc field to string
and add new column
ALTER TABLE ts
ADD COLUMN dpc_int UInt64 MATERIALIZED toUInt64(dpc);

Reading particular word by its position in vbscript

I have following lines in a file:
Displaying 5 of 17 -- All country members
Displaying 0 of 0 -- All country members
Displaying 15 of 417 -- All country members
Displaying 134 of 4890 -- All country members
In my script condition, i may get any line from the above.
I want to fetch only the bold number.
Is there any way to fetch the 4th word of a line?
You could use Split() to get an array of the " " separated chunks of the line and access the fourth element by accessing it with its (zero-based) index 3.
demo:
>> WScript.Echo Split("Displaying 134 of 4890 -- All country members")(3)
>>
4890
>>

Resources