I am facing issue while giving command
ip6tables -A DDoS -j DROP
It is resulting in errors like
root#TimeProvider:~# ip6tables -A DDoS -j DROP
ip6tables: Invalid argument.
Run `dmesg' for more information.
root#TimeProvider:~# dmesg|tail -n 20 ip6_tables: limit match: invalid size 40 != 48
ip6_tables: limit match: invalid size 40 != 48
ip6_tables: limit match: invalid size 40 != 48
ip6_tables: limit match: invalid size 40 != 48
ip6_tables: limit match: invalid size 40 != 48
ip6_tables: limit match: invalid size 40 != 48
ip6_tables: limit match: invalid size 40 != 48
ip6_tables: limit match: invalid size 40 != 48
ip6_tables: limit match: invalid size 40 != 48
ADDRCONF(NETDEV_UP):
mgmt0: link is not ready
mgmt0: Link is up - 1000/Full
ADDRCONF(NETDEV_CHANGE):
mgmt0: link becomes ready TMAC switching to SyncE slave mode on PHY 0 TMAC switching to SyncE master mode on PHY 1
mgmt0: no IPv6 routers present TMAC switching to SyncE slave mode on PHY 0 TMAC switching to SyncE master mode on PHY 1
eth0: no IPv6 routers present
eth1: no IPv6 routers present
ip6_tables: limit match: invalid size 40 != 48
Is it a syntax error of the command or is it a system error?
Related
I am trying to replicate sg_inq through sg_raw
This is the command used:
inq_cmd := exec.Command("sg_raw", "-r", "512", "/dev/sg0", "12 00 00 00 60 00")
stdoutStderr, err := read_cmd.CombinedOutput()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", stdoutStderr)
Output after execution is
Inq COMMAND :
exit status 1
Invalid command byte '12 00 00 00 60 00'
Inquire COMMAND :
2020/05/28 19:42:48 exit status 1
exit status 1
Invalid command byte '12 00 00 00 60 00'
Usage: sg_raw [OPTION]* DEVICE CDB0 CDB1 ...
Options:
-b, --binary Dump data in binary form, even when writing to stdout
-h, --help Show this message and exit
-i, --infile=IFILE Read data to send from IFILE (default: stdin)
-k, --skip=LEN Skip the first LEN bytes when reading data to send
-n, --nosense Don't display sense information
-o, --outfile=OFILE Write binary data to OFILE (def: hexdump to stdout)
-r, --request=RLEN Request up to RLEN bytes of data (data-in)
-R, --readonly Open DEVICE read-only (default: read-write)
-s, --send=SLEN Send SLEN bytes of data (data-out)
-t, --timeout=SEC Timeout in seconds (default: 20)
-v, --verbose Increase verbosity
-V, --version Show version information and exit
Between 6 and 256 command bytes (two hex digits each) can be specified
and will be sent to DEVICE. Lengths RLEN and SLEN are decimal by
default. Bidirectional commands accepted.
Simple example: Perform INQUIRY on /dev/sg0:
sg_raw -r 1k /dev/sg0 12 00 00 00 60 00
What's wrong in the command? It would be a great help! Thanks in advance!
I am working with a unix shell script which have an output of script like below code:
EVENT DATE: 2019-05-12
TrapLogId Severity EventTime Model Description
1604 [major] 05:59:50 14 Network Interface Down: service 1-16
1605 [major] 05:59:51 14 Network Interface Down: service 1-15
EVENT DATE: 2019-05-13
TrapLogId Severity EventTime Model Description
1619 [minor] 07:58:50 30 Delayed Subscriber Mapping
1620 [minor] 08:03:49 79 Failed Reload: File syntax
1621 [clear] 08:04:49 79 Failed Reload Cleared: File syntax
1622 [clear] 08:28:50 30 Delayed Subscriber Mapping Cleared
EVENT DATE: 2019-05-15
TrapLogId Severity EventTime Model Description
1627 [minor] 01:43:58 22 Misconfigured Network Awareness: 10.1.17.0/24
1628 [clear] 01:48:58 22 Misconfigured Network Awareness Cleared
Im trying to organize it into table like this format :
EVENT DATE TrapLogId Severity EventTime Model Description
2019-05-12 1604 [major] 05:59:50 14 Network Interface Down: service 1-16
2019-05-12 1605 [major] 05:59:51 14 Network Interface Down: service 1-15
2019-05-13 1619 [minor] 07:58:50 30 Delayed Subscriber Mapping
2019-05-13 1620 [minor] 08:03:49 79 Failed Reload: File syntax
2019-05-13 1621 [clear] 08:04:49 79 Failed Reload Cleared: File syntax
2019-05-13 1622 [clear] 08:28:50 30 Delayed Subscriber Mapping Cleared
2019-05-15 1627 [minor] 01:43:58 22 Misconfigured Network Awareness: 10.1.17.0/24
2019-05-15 1628 [clear] 01:48:58 22 Misconfigured Network Awareness Cleared
how to parse it ? how to export it into table using shell ?
the code i want to organize into table has:
event date 1
header
content 1
event date 2
header
content 2
etc
i want it as
event date (as part of the header) header
content 1
content 2
content 3
You can pipe your script to:
awk 'BEGIN {
print "EVENT DATE TrapLogId Severity EventTime Model Description"
print
}
/EVENT DATE/ {date=$3}
match($3, "[0-9][0-9]:[0-9][0-9]:[0-9][0-9]") {
printf( "%-14s%-14s%-13s%-12s%-3s", date, $1, $2, $3, $4)
for(i=1;i<=4;i++) $i=""
print
}
'
$ cat tst.awk
BEGIN { OFS="\t"; dateTag="EVENT DATE" }
{ gsub(/^[[:space:]]+|[[:space:]]+$/,"") }
/^[^0-9]/ {
if ( $0 ~ dateTag ) {
date = $NF
}
else if ( !doneHdr++ ) {
numCols = NF
gsub(/[[:space:]]+/,OFS)
print dateTag, $0
}
}
/^[0-9]/ {
rest = desc = $0
sub("([[:space:]]+[^[:space:]]+){"(NF-numCols)+1"}$","",rest)
sub("^([^[:space:]]+[[:space:]]+){"numCols-1"}","",desc)
gsub(/[[:space:]]+/,OFS,rest)
print date, rest, desc
}
.
$ awk -f tst.awk file | column -s$'\t' -t
EVENT DATE TrapLogId Severity EventTime Model Description
2019-05-12 1604 [major] 05:59:50 14 Network Interface Down: service 1-16
2019-05-12 1605 [major] 05:59:51 14 Network Interface Down: service 1-15
2019-05-13 1619 [minor] 07:58:50 30 Delayed Subscriber Mapping
2019-05-13 1620 [minor] 08:03:49 79 Failed Reload: File syntax
2019-05-13 1621 [clear] 08:04:49 79 Failed Reload Cleared: File syntax
2019-05-13 1622 [clear] 08:28:50 30 Delayed Subscriber Mapping Cleared
2019-05-15 1627 [minor] 01:43:58 22 Misconfigured Network Awareness: 10.1.17.0/24
2019-05-15 1628 [clear] 01:48:58 22 Misconfigured Network Awareness Cleared
I'm trying to get write size distribution by process. I ran:
sudo dtrace -n 'sysinfo:::writech { #dist[execname] = quantize(arg0); }'
and got the following error:
dtrace: invalid probe specifier sysinfo:::writech...
This is Mac OSX. Please help.
The error message is telling you that Mac OS X doesn't support the sysinfo::: provider. Perhaps you meant to use one of these?
# dtrace -ln sysinfo::writech:
ID PROVIDER MODULE FUNCTION NAME
dtrace: failed to match sysinfo::writech:: No probe matches description
# dtrace -ln sysinfo:::
ID PROVIDER MODULE FUNCTION NAME
dtrace: failed to match sysinfo:::: No probe matches description
# dtrace -ln 'syscall::write*:'
ID PROVIDER MODULE FUNCTION NAME
147 syscall write entry
148 syscall write return
381 syscall writev entry
382 syscall writev return
933 syscall write_nocancel entry
934 syscall write_nocancel return
963 syscall writev_nocancel entry
964 syscall writev_nocancel return
The following script works for me:
# dtrace -n 'syscall::write:entry {#dist[execname] = quantize(arg0)}'
dtrace: description 'syscall::write:entry ' matched 1 probe
^C
activitymonitor
value ------------- Distribution ------------- count
2 | 0
4 |######################################## 4
8 | 0
Activity Monito
value ------------- Distribution ------------- count
2 | 0
4 |######################################## 6
8 | 0
...
I want to monitor a device that doesn´t support SNMP, so I have tried get a counter via an expect script. This script connects to the device using SSH, logs the output on a file and then it parses the output in order to get the desired counter.
When I execute the script from the console I get the following desired output:
root#box:/path# ./GGSN-PDP-Contexts.expect
.1.3.6.1.4.1.6147.2.1
Integer32
310838
However, when I try to get the result using snmpget it doesn´t work!
root#box:/path# snmpget -m TDP-MIB -v 2c -c TM_Com_Pub localhost .1.3.6.1.4.1.6147.2.1
TDP-MIB::PDPContextsNumber = No Such Instance currently exists at this OID
By the way, this is the relevant configuration at snmpd.conf:
pass .1.3.6.1.4.1.6147.2.1 /usr/bin/expect /path/GGSN-PDP-Contexts.expect
And this is the expect script that I'm using:
#!/usr/bin/expect -f
# Constants
set user "user"
set device "10.10.222.176"
set pass "blablabla"
set timeout -1
set prompt "GGSN-LV02#"
set file "./GGSN-PDP-Contexts.log"
# Options
match_max 100000
log_user 0
# Access to device
spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no $user#$device
expect "*?assword:*"
send -- "$pass\r"
# Commands execution
expect -exact "$prompt"
send -- "display pdp-number\r"
log_file -a $file
# Logging
expect -exact "$prompt"
log_file
send -- "quit\r"
# Get the value
set result [exec cat $file | grep "ALL GTP" | cut -d " " -f14]
set value [format %d $result]
# Print the value
puts ".1.3.6.1.4.1.6147.2.1"
puts "Integer32"
puts $value # If I replace the $value with a number, it doesn't work either
# Erase log file
exec rm $file
close
Could you bring me any hint? Thanks in advance!
EDIT:
In addition, these are the last lines of snmpget's debug output:
trace: snmp_comstr_parse(): snmp_auth.c, 135:
dumph_recv: SNMP version
dumpx_recv: 02 01 01
dumpv_recv: Integer: 1 (0x01)
trace: snmp_comstr_parse(): snmp_auth.c, 147:
dumph_recv: community string
dumpx_recv: 04 0A 54 4D 5F 43 6F 6D 5F 50 75 62
dumpv_recv: String: TM_Com_Pub
trace: _snmp_parse(): snmp_api.c, 4149:
dumph_recv: PDU
trace: snmp_pdu_parse(): snmp_api.c, 4255:
dumpv_recv: Command RESPONSE
trace: snmp_pdu_parse(): snmp_api.c, 4336:
dumph_recv: request_id
dumpx_recv: 02 04 3B 9E CF 74
dumpv_recv: Integer: 1000263540 (0x3B9ECF74)
trace: snmp_pdu_parse(): snmp_api.c, 4347:
dumph_recv: error status
dumpx_recv: 02 01 00
dumpv_recv: Integer: 0 (0x00)
trace: snmp_pdu_parse(): snmp_api.c, 4358:
dumph_recv: error index
dumpx_recv: 02 01 00
dumpv_recv: Integer: 0 (0x00)
trace: snmp_pdu_parse(): snmp_api.c, 4376:
dumph_recv: VarBindList
trace: snmp_pdu_parse(): snmp_api.c, 4406:
dumph_recv: VarBind
trace: snmp_parse_var_op(): snmp.c, 166:
dumph_recv: Name
dumpx_recv: 06 09 2B 06 01 04 01 B0 03 02 01
dumpv_recv: ObjID: TDP-MIB::PDPContextsNumber
trace: snmp_pdu_parse(): snmp_api.c, 4415:
dumph_recv: Value
TDP-MIB::PDPContextsNumber = No Such Instance currently exists at this OID
Also, this is my current MIB:
TDP-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, Integer32, enterprises
FROM SNMPv2-SMI
OBJECT-GROUP FROM SNMPv2-CONF;
TDP MODULE-IDENTITY
LAST-UPDATED "201210080000Z" -- 8/oct/2012
ORGANIZATION "TELEFONICA"
CONTACT-INFO "Authors: Hernan Romano / Antonio Ocampo
Email: h.romanoc#pucp.edu.pe / aocampo#pucp.edu.pe"
DESCRIPTION "MIB para gestionar los equipos que carecen de SNMP"
REVISION "201210080000Z" -- 08/oct/2012
DESCRIPTION "Revision 2.1"
::= { enterprises 6147 }
Nokia OBJECT IDENTIFIER ::= { TDP 1 }
Huawei OBJECT IDENTIFIER ::= { TDP 2 }
TDPMIBConformance OBJECT IDENTIFIER ::= { TDP 3 }
ClearCodeGroup1 OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION "Clear Code Group 1"
::= { Nokia 1 }
PDPContextsNumber OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION "PDP Contexts Number"
::= { Huawei 1 }
TDPMIBGroup OBJECT IDENTIFIER
::= { TDPMIBConformance 1 }
--grupoTDP OBJECT-GROUP
-- OBJECTS {
-- ClearCodeGroup1,
-- PDPContextsNumber
-- }
-- STATUS current
-- DESCRIPTION "Objetos para el monitoreo de los equipos que carecen de SNMP"
-- ::= { TDPMIBGroup 1 }
END
Finally solved :) The trouble was the path file.
Instead of relative path:
set file "./GGSN-PDP-Contexts.log"
I put the absolute path:
set file "/FULL_PATH/GGSN-PDP-Contexts.log"
and snmpget works!!
root#box:/path# snmpget -m TDP-MIB -v 2c -c TM_Com_Pub localhost .1.3.6.1.4.1.6147.2.1
TDP-MIB::PDPContextsNumber = INTEGER: 319291
I'm on a Mac. In the terminal, how would you figure out each of the following values?
Word size (64 bit vs. 32 bit)
L1/L2 cache size
Determine how much memory is being used (like df, but for RAM)
Thanks! I know you can find these in Activity Monitor, System Profiler etc. but I am trying to boost my knowledge of the terminal, and UNIX.
System Profiler is a GUI wrapper around /usr/sbin/system_profiler.
mress:10008 Z$ system_profiler -listDataTypes
Available Datatypes:
SPHardwareDataType
SPNetworkDataType
SPSoftwareDataType
SPParallelATADataType
SPAudioDataType
SPBluetoothDataType
SPCardReaderDataType
SPDiagnosticsDataType
SPDiscBurningDataType
SPEthernetDataType
SPFibreChannelDataType
SPFireWireDataType
SPDisplaysDataType
SPHardwareRAIDDataType
SPMemoryDataType
SPPCIDataType
SPParallelSCSIDataType
SPPowerDataType
SPPrintersDataType
SPSASDataType
SPSerialATADataType
SPUSBDataType
SPAirPortDataType
SPFirewallDataType
SPNetworkLocationDataType
SPModemDataType
SPNetworkVolumeDataType
SPWWANDataType
SPApplicationsDataType
SPDeveloperToolsDataType
SPExtensionsDataType
SPFontsDataType
SPFrameworksDataType
SPLogsDataType
SPManagedClientDataType
SPPrefPaneDataType
SPStartupItemDataType
SPSyncServicesDataType
SPUniversalAccessDataType
mress:10009 Z$ system_profiler SPHardwareDataType
Hardware:
Hardware Overview:
Model Name: iMac
Model Identifier: iMac10,1
Processor Name: Intel Core 2 Duo
Processor Speed: 3.33 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache: 6 MB
Memory: 16 GB
Bus Speed: 1.33 GHz
Boot ROM Version: IM101.00CC.B00
SMC Version (system): 1.52f9
Serial Number (system): QP0241DXB9S
Hardware UUID: 01C6B9E9-B0CB-5249-8AC7-069A3E44A188
You can also get some useful information from /usr/sbin/sysctl (try sysctl -a).
mress:10014 Z$ sudo sysctl -a | grep cache
Password:
hw.cachelinesize = 64
hw.l1icachesize = 32768
hw.l1dcachesize = 32768
hw.l2cachesize = 6291456
kern.flush_cache_on_write: 0
vfs.generic.nfs.client.access_cache_timeout: 60
vfs.generic.nfs.server.reqcache_size: 64
net.inet.ip.rtmaxcache: 128
net.inet6.ip6.rtmaxcache: 128
hw.cacheconfig: 2 1 2 0 0 0 0 0 0 0
hw.cachesize: 17179869184 32768 6291456 0 0 0 0 0 0 0
hw.cachelinesize: 64
hw.l1icachesize: 32768
hw.l1dcachesize: 32768
hw.l2cachesize: 6291456
machdep.cpu.cache.linesize: 64
machdep.cpu.cache.L2_associativity: 8
machdep.cpu.cache.size: 6144