dnsmasq/hostapd slow to offer DHCP address - dnsmasq

I've got an embedded system running hostapd and dnsmasq acting as a wifi access point. Very repeatably it will take 11s between the time clients (Macbook pros, Dell laptops, iphones, android tablets) associate/authenticate with the AP and the time they get an IP address.
It appears that multipe dhcpdiscover/offers go through at nearly the same time, followed by a dhcprequest and dhcpack:
Apr 5 23:27:01 AP daemon.info hostapd: wlan0-ap: STA b8:e8:56:2d:45:ae IEEE 802.11: authenticated
Apr 5 23:27:01 AP daemon.info hostapd: wlan0-ap: STA b8:e8:56:2d:45:ae IEEE 802.11: associated (aid 2)
Apr 5 23:27:01 AP daemon.info hostapd: wlan0-ap: STA b8:e8:56:2d:45:ae RADIUS: starting accounting session 5521BC1F-00000007
Apr 5 23:27:01 AP daemon.info hostapd: wlan0-ap: STA b8:e8:56:2d:45:ae WPA: pairwise key handshake completed (RSN)
Apr 5 23:27:13 AP daemon.info dnsmasq-dhcp[734]: DHCPDISCOVER(wlan0-ap) b8:e8:56:2d:45:ae
Apr 5 23:27:13 AP daemon.info dnsmasq-dhcp[734]: DHCPOFFER(wlan0-ap) 10.1.1.166 b8:e8:56:2d:45:ae
Apr 5 23:27:13 AP daemon.info dnsmasq-dhcp[734]: DHCPDISCOVER(wlan0-ap) b8:e8:56:2d:45:ae
Apr 5 23:27:13 AP daemon.info dnsmasq-dhcp[734]: DHCPOFFER(wlan0-ap) 10.1.1.166 b8:e8:56:2d:45:ae
Apr 5 23:27:14 AP daemon.info dnsmasq-dhcp[734]: DHCPREQUEST(wlan0-ap) 10.1.1.166 b8:e8:56:2d:45:ae
Apr 5 23:27:14 AP daemon.info dnsmasq-dhcp[734]: DHCPACK(wlan0-ap) 10.1.1.166 b8:e8:56:2d:45:ae Allans-MBP
How can I speed up the time it takes to get an IP address on clients?

Related

Redis HSET keys expire after few minutes

I am trying to connect to a remote redis server and set keys using HSET command like below
hset ABCD:1105 balance 1000
I can able to see the Key using KEYS *
But after approx 1 minute the KEYS * returns empty (empty list or set) . Whereas TTL on the key returns -1.
This is the memory configuration in the redis server
1) "masterauth"
2) ""
3) "maxmemory"
4) "0"
5) "maxmemory-samples"
6) "5"
7) "maxclients"
8) "10000"
9) "min-slaves-to-write"
10) "0"
11) "min-replicas-to-write"
12) "0"
13) "min-slaves-max-lag"
14) "10"
15) "min-replicas-max-lag"
16) "10"
17) "maxmemory-policy"
18) "noeviction"
Here the max memory policy is also noeviction. Then why the Keys are getting expired.
Updating the logs of redis server pod
> 1:C 09 Jan 2021 17:02:04.495 # oO0OoO0OoO0Oo Redis is starting
> oO0OoO0OoO0Oo 1:C 09 Jan 2021 17:02:04.495 # Redis version=5.0.7,
> bits=64, commit=00000000, modified=0, pid=1, just started 1:C 09 Jan
> 2021 17:02:04.495 # Configuration loaded 1:M 09 Jan 2021 17:02:04.496
> * Running mode=standalone, port=6379. 1:M 09 Jan 2021 17:02:04.496 # WARNING: The TCP backlog setting of 511 cannot be enforced because
> /proc/sys/net/core/somaxconn is set to the lower value of 128. 1:M 09
> Jan 2021 17:02:04.496 # Server initialized 1:M 09 Jan 2021
> 17:02:04.496 # WARNING you have Transparent Huge Pages (THP) support
> enabled in your kernel. This will create latency and memory usage
> issues with Redis. To fix this issue run the command 'echo never >
> /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to
> your /etc/rc.local in order to retain the setting after a reboot.
> Redis must be restarted after THP is disabled. 1:M 09 Jan 2021
> 17:02:04.897 * DB loaded from append only file: 0.400 seconds 1:M 09
> Jan 2021 17:02:04.897 * Ready to accept connections
Update2 : Memory Info
used_memory:999576 used_memory_human:976.15K used_memory_rss:5341184
used_memory_rss_human:5.09M used_memory_peak:1679456
used_memory_peak_human:1.60M used_memory_peak_perc:59.52%
used_memory_overhead:958562 used_memory_startup:790256
used_memory_dataset:41014 used_memory_dataset_perc:19.59%
allocator_allocated:1104272 allocator_active:1642496
allocator_resident:5189632 total_system_memory:29508444160
total_system_memory_human:27.48G used_memory_lua:37888
used_memory_lua_human:37.00K used_memory_scripts:0
used_memory_scripts_human:0B number_of_cached_scripts:0 maxmemory:0
maxmemory_human:0B maxmemory_policy:noeviction
allocator_frag_ratio:1.49 allocator_frag_bytes:538224
allocator_rss_ratio:3.16 allocator_rss_bytes:3547136
rss_overhead_ratio:1.03

Facebook Analytics - how group events based on time (breakdown to 24 segments)

I want to know at WHAT TIME mostly my events happens during a period of time, so for example:
Event : Initiate Checkout
time 00:00 ~ 01:00 = 80 events
time 01:00 ~ 02:00 = 145 events
time 02:00 ~ 03:00 = 300 events
...
time 23:00 ~ 24:00 = 20 events
between date range: 1 nov ~ 30 nov 2018
Note : the results shouldn't be 720 (30*24) time fragments, but 24 time fragments.
How to do that using facebook analytics ?
You can go to "Events" section, choose "Initiate Checkout", on the charts choose "Time Interval" as "Hourly". For date range, you can choose 1 nov ~ 30 nov on the top left corner.

How do I create a cron expression running in Kibana on weekday?

I would like my watcher to run from Monday to Friday only. So I'm trying to use this schedule:
"trigger": {
"schedule" : { "cron" : "0 0 0/4 * * MON-FRI" }
},
"input": {
...
However, I'm getting
Error
Watcher: [parse_exception] could not parse [cron] schedule
when I'm trying to save the watcher. Removing MON-FRI does helps but I need it.
This expression works:
0 0 0/4 ? * MON-FRI
But I'm not sure I understand why ? is required for either the day_of_week or day_of_month
Thank you!
I believe this is what you are looking for:
"0 0 0/4 ? * MON-FRI"
You can use croneval to check your cron expressions 1:
$ /usr/share/elasticsearch/bin/x-pack/croneval "0 0 0/4 ? * MON-FRI"
Valid!
Now is [Mon, 20 Aug 2018 13:32:26]
Here are the next 10 times this cron expression will trigger:
1. Mon, 20 Aug 2018 09:00:00
2. Mon, 20 Aug 2018 13:00:00
3. Mon, 20 Aug 2018 17:00:00
4. Mon, 20 Aug 2018 21:00:00
5. Tue, 21 Aug 2018 01:00:00
6. Tue, 21 Aug 2018 05:00:00
7. Tue, 21 Aug 2018 09:00:00
8. Tue, 21 Aug 2018 13:00:00
9. Tue, 21 Aug 2018 17:00:00
10. Tue, 21 Aug 2018 21:00:00
For the first expression you'll get following java exception:
java.lang.IllegalArgumentException: support for specifying both a day-of-week AND a day-of-month parameter is not implemented.
You can also use Crontab guru to get human readable descriptions like:
At every minute past every 4th hour from 0 through 23 on every day-of-week from Monday through Friday.
The question mark means 'No Specific value'. From the documentation on Quartz's website:
? (“no specific value”) - useful when you need to specify something in one of the two fields in which the character is allowed, but not the other. For example, if I want my trigger to fire on a particular day of the month (say, the 10th), but don’t care what day of the week that happens to be, I would put “10” in the day-of-month field, and “?” in the day-of-week field. See the examples below for clarification.
http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html
I suppose since you want your schedule to run every 4 hours, mon-fri, the actual day of the month is irrelevant, so the ? specifies that. * on teh other hand would be 'all values' which would not make sense since you are specifying only mon-fri for day of the week.
Hope that helps!

Suggestions on what patterns/analysis to derive from Airlines Big Data

I recently started learning Hadoop,
I found this data set http://stat-computing.org/dataexpo/2009/the-data.html - (2009 data),
I want some suggestions as what type of patterns or analysis can I do in Hadoop MapReduce, i just need something to get started with, If anyone has a better data set link which I can use for learning, help me here.
The attributes are as:
1 Year 1987-2008
2 Month 1-12
3 DayofMonth 1-31
4 DayOfWeek 1 (Monday) - 7 (Sunday)
5 DepTime actual departure time (local, hhmm)
6 CRSDepTime scheduled departure time (local, hhmm)
7 ArrTime actual arrival time (local, hhmm)
8 CRSArrTime scheduled arrival time (local, hhmm)
9 UniqueCarrier unique carrier code
10 FlightNum flight number
11 TailNum plane tail number
12 ActualElapsedTime in minutes
13 CRSElapsedTime in minutes
14 AirTime in minutes
15 ArrDelay arrival delay, in minutes
16 DepDelay departure delay, in minutes
17 Origin origin IATA airport code
18 Dest destination IATA airport code
19 Distance in miles
20 TaxiIn taxi in time, in minutes
21 TaxiOut taxi out time in minutes
22 Cancelled was the flight cancelled?
23 CancellationCode reason for cancellation (A = carrier, B = weather, C = NAS, D = security)
24 Diverted 1 = yes, 0 = no
25 CarrierDelay in minutes
26 WeatherDelay in minutes
27 NASDelay in minutes
28 SecurityDelay in minutes
29 LateAircraftDelay in minutes
Thanks

Remove "invalid byte sequence in UTF-8" after an apparently succesfull encoding

I have an IMAP mail with a message string that looks like this:
message = #<Mail::Message:70152447148720, Multipart: false, Headers: <Return-Path: <apache#mail.gameseek.co.uk>>, <Received: by 10.86.68.12 with SMTP id q12cs352558fga; Mon, 9 Mar 2009 04:23:05 -0700 (PDT)>, <Received: by 10.210.137.14 with SMTP id k14mr2429643ebd.46.1236597783700; Mon, 09 Mar 2009 04:23:03 -0700 (PDT)>, <Received: from exproxy-2.exserver.dk (exproxy-2.exserver.dk [195.69.129.163]) by mx.google.com with ESMTP id 27si3500694ewy.75.2009.03.09.04.23.03; Mon, 09 Mar 2009 04:23:03 -0700 (PDT)>, <Received: by exproxy-2.exserver.dk (Postfix, from userid 65534) id DF2F6106EF3; Mon, 9 Mar 2009 12:13:26 +0100 (CET)>, <Received: from exsmtp01.exserver.dk (exsmtp01.exserver.dk [195.69.129.177]) by exproxy-2.exserver.dk (Postfix) with ESMTP id C2CEE106ED0 for <support_email.com#exfwd01.scannet.dk>; Mon, 9 Mar 2009 12:13:26 +0100 (CET)>, <Received: from exsmtp02.exserver.dk ([10.10.10.32]) by exsmtp01.exserver.dk with Microsoft SMTPSVC(6.0.3790.1830); Mon, 9 Mar 2009 12:22:19 +0100>, <Received: from front08.exserver.dk ([195.69.129.93]) by exsmtp02.exserver.dk with Microsoft SMTPSVC(6.0.3790.1830); Mon, 9 Mar 2009 12:22:19 +0100>, <Received: from localhost (front08.exserver.dk [127.0.0.1]) by front08.exserver.dk (Postfix) with ESMTP id F1B2BC4028 for <support#email.com>; Mon, 9 Mar 2009 12:46:22 +0100 (CET)>, <Received: from front08.exserver.dk ([127.0.0.1]) by localhost (front08.exserver.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mrYGo4G2pt13 for <support#email.com>; Mon, 9 Mar 2009 12:46:16 +0100 (CET)>, <Received: from mail.gameseek.co.uk (78.109.164.42.srvlist.ukfast.net [78.109.164.42]) by front08.exserver.dk (Postfix) with ESMTP id 99022C4021 for <support#email.com>; Mon, 9 Mar 2009 12:46:16 +0100 (CET)>, <Received: by mail.gameseek.co.uk (Postfix, from userid 48) id D321218DD2D; Mon, 9 Mar 2009 11:22:55 +0000 (GMT)>, <Date: Mon, 09 Mar 2009 11:22:55 +0000>, <From: myorder#gameseek.co.uk>, <Reply-To: myorder#gameseek.co.uk>, <To: support#email.com>, <Message-ID: <20090309112255.D321218DD2D#mail.gameseek.co.uk>>, <Subject: Gameseek Order Refunded: Gh68y1235386413>, <Delivered-To: my#email.com>, <Received-SPF: neutral (google.com: 195.69.129.163 is neither permitted nor denied by best guess record for domain of apache#mail.gameseek.co.uk) client-ip=195.69.129.163;>, <Authentication-Results: mx.google.com; spf=neutral (google.com: 195.69.129.163 is neither permitted nor denied by best guess record for domain of apache#mail.gameseek.co.uk) smtp.mail=apache#mail.gameseek.co.uk>, <X-Exserver-To: support_email.com#exfwd01.scannet.dk>, <X-Virus-Scanned: amavisd-new at exserver.dk>, <X-OriginalArrivalTime: 09 Mar 2009 11:22:19.0838 (UTC) FILETIME=[4F6005E0:01C9A0A9]>, <X-ScanNet-Forward: TTL=5>>
I now wish to give it a proper encoding:
unless message.multipart?
charset = message.charset # => "UTF-8"
if charset != nil
body = message.body.decoded.force_encoding(charset).encode("UTF-8") # => "\n\nHello you,\n\nYour order or part of it has been refunded by Gameseek. The refund will be present on the same payment method you used when purchasing. If no other items are due to be posted to you the postage charge will also be refunded.\n\nPlease allow upto four working days for this refund to process.\n\nIf you have not contacted us about this order then it is most likely you are being refunded for an item we cannot currently get hold of.\n\nWe do apologise if this is the case, we would rather refund customers rather than having them wait weeks and weeks for an item.\n\nIf you have contacted us about this order then you will know why you are being refunded.\nMay we apologise if we have not met your requirements on this occassion.\n\nYour Order: Product | Category | Quantity | Cost\n---------------------------------------------------\nDragon Ball Z - Supersonic Warriors 2 | NintendoDS | 1 | \xA326.97\n\n\nFor all order enquires please contact myorder#gameseek.co.uk\n\nThank you for using Gameseek.\n"
end
end
body = body.split(/Sent from my iPhone/)[0]
The last line raises the following error:
invalid byte sequence in UTF-8
Any idea how to fix this?
The text contains the invalid sequence \xA3. This represents a pound sign in Latin-1 (ISO-8859-1).
"\xA3".force_encoding('ISO-8859-1').encode('UTF-8')
#=> "£"
The quick fix is to replace invalid byte sequences in body with String#scrub, but that will remove them:
"\xA326.97".scrub('')
#=> "26.97"
However, to solve the "real" problem you should look earlier in the pipeline. The supplied charset seems to be wrong. Apparently the message is encoded in Latin-1, although the charset suggests something different. Maybe the problem is on the side of the sender.

Resources