07-01-2015
Thanks RudiC !
@Yoda & Scrutinizer: I assumed that max NF was unknown.
@senhia83: it works, but RudiC's one is more concise.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Is it possible to find the total number of records processed by awk at begining.
NR gives the value at the end. Is there any variable available to find the value at the begining?
Thanks
----------
Suman (1 Reply)
Discussion started by: suman_jakkula
1 Replies
2. UNIX for Dummies Questions & Answers
Hello all,
Would appreciate if someone can help me out on the following requirement.
INPUT FILE:
--------------------------
TPS REPORT
abc def ghi
jkl mon pqr
stu vrs lll
END OF TPS REPORT
TPS REPORT
field1 field2 field3
field4 field5 field6 (8 Replies)
Discussion started by: hyennah
8 Replies
3. Shell Programming and Scripting
I'm working on formatting some attendance data to meet a vendors requirements to upload to their system. With some help on the forums here, I have the data close. But they've since changed what they want.
The vendor wants me to submit three fields to them. Field 1 is the studentid field,... (4 Replies)
Discussion started by: axo959
4 Replies
4. Shell Programming and Scripting
A file file1.txt exists having records like
The delimiter being "|"
X|_|Y|_|Z|_| (number of fields 7)
A|_|B|_| (number of fields 5)
X|_|Z|_|H|_| (number of fields 7)
A|_|D|_|S|_| (number of... (4 Replies)
Discussion started by: centurion_13
4 Replies
5. Shell Programming and Scripting
Hi,
I have a comma (,) delimited file, in which few fields are enclosed with in double quotes " ". I have to print the records in the file which donot have expected number of field with the line number.
File1
====
name,desgnation,doj,project #header#... (7 Replies)
Discussion started by: machomaddy
7 Replies
6. Shell Programming and Scripting
Hi all,
I have a tab-delimited text file of size 10Mb. I am trying to count the number of lines using,
grep -c . sample.txtor
wc -l < sample.txt or
awk 'END {print NR}' sample.txtAll these commands shows the count as 1, which means they are reading only the first header line of the file.... (3 Replies)
Discussion started by: mehar
3 Replies
7. Shell Programming and Scripting
I would like to print the number of records of 2 files, and divide the two numbers
awk '{print NR}' file1 > output1
awk '{print NR}' file2 > output2
paste output1 output2 > output
awl '{print $1/$2}' output > output_2
is there a faster way? (8 Replies)
Discussion started by: programmerc
8 Replies
8. UNIX for Dummies Questions & Answers
input:
ref.1;rack.1;1 #group1
ref.1;rack.1;2 #group1
ref.1;rack.2;1 #group2
ref.2;rack.3;1 #group3
ref.2;rack.3;2 #group3
ref.2;rack.3;3 #group3
Among records from same group (i.e. with same 1st and 2nd field - separated by ";"), I would need to keep the last record... (5 Replies)
Discussion started by: beca123456
5 Replies
9. UNIX for Beginners Questions & Answers
Hi,
My input looks like that:
A|123|qwer
A|456|tyui
A|456|wsxe
B|789|dfgh
Using awk, I am trying to get:
A|123;456|qwer;tyui;wsxe
B|789|dfgh
For records with same $1, group all the $2 in a field (without replicates), and all the $3 in a field (without replicates).
What I have tried:... (6 Replies)
Discussion started by: beca123456
6 Replies
10. UNIX for Beginners Questions & Answers
Hello all, I am having trouble with what should be an easy task, but seem to be missing something fundamental. I have two files, with File 1 consisting of a single field of many thousands of records. I also have File 2 with two fields and many thousands of records.
My goal is that when $1 of... (2 Replies)
Discussion started by: jvoot
2 Replies
LEARN ABOUT DEBIAN
collectd-nagios
COLLECTD-NAGIOS(1) collectd COLLECTD-NAGIOS(1)
NAME
collectd-nagios - Nagios plugin for querying collectd
SYNOPSIS
collectd-nagios -s socket -n value_spec -H hostname [options]
DESCRIPTION
This small program is the glue between collectd and nagios. collectd collects various performance statistics which it provides via the
"unixsock plugin", see collectd-unixsock(5). This program is called by Nagios, connects to the UNIX socket and reads the values from
collectd. It then returns OKAY, WARNING or CRITICAL depending on the values and the ranges provided by Nagios.
ARGUMENTS AND OPTIONS
The following arguments and options are required and understood by collectd-nagios. The order of the arguments generally doesn't matter, as
long as no argument is passed more than once.
-s socket
Path of the UNIX socket opened by collectd's "unixsock plugin".
-n value_spec
The value to read from collectd. The argument is in the form "plugin[-instance]/type[-instance]".
-H hostname
Hostname to query the values for.
-d data_source
Each value_spec may be made of multiple "data sources". With this option you can select one or more data sources. To select multiple
data sources simply specify this option again. If multiple data sources are examined they are handled according to the consolidation
function given with the -g option.
-g none|average|sum
When multiple data sources are selected from a value spec, they can be handled differently depending on this option. The values of the
following meaning:
none
No consolidation if done and the warning and critical regions are applied to each value independently.
average
The warning and critical ranges are applied to the average of all values.
sum The warning and critical ranges are applied to the sum of all values.
percentage
The warning and critical ranges are applied to the ratio (in percent) of the first value and the sum of all values. A warning is
returned if the first value is not defined or if all values sum up to zero.
-c range
-w range
Set the critical (-c) and warning (-w) ranges. These options mostly follow the normal syntax of Nagios plugins. The general format is
"min:max". If a value is smaller than min or bigger than max, a warning or critical status is returned, otherwise the status is
success.
The tilde sign (~) can be used to explicitly specify infinity. If ~ is used as a min value, negative infinity is used. In case of max,
it is interpreted as positive infinity.
If the first character of the range is the at sign (@), the meaning of the range will be inverted. I. e. all values within the range
will yield a warning or critical status, while all values outside the range will result in a success status.
min (and the colon) may be omitted, min is then assumed to be zero. If max (but not the trailing colon) is omitted, max is assumed to
be positive infinity.
-m If this option is given, "Not a Number" (NaN) is treated as critical. By default, the none consolidation reports NaNs as warning. Other
consolidations simply ignore NaN values.
RETURN VALUE
As usual for Nagios plugins, this program writes a short, one line status message to STDOUT and signals success or failure with it's return
value. It exits with a return value of 0 for success, 1 for warning and 2 for critical. If the values are not available or some other error
occurred, it returns 3 for unknown.
SEE ALSO
collectd(1), collectd.conf(5), collectd-unixsock(5), <http://nagios.org/>
AUTHOR
Florian Forster <octo at verplant.org>
5.1.0 2012-04-02 COLLECTD-NAGIOS(1)