- FastAPI
- TaskTiger
- Redis
- PostgreSQL
- peewee
- structlog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RequestHeader unset X-REMOTE_USER | |
RequestHeader set X-REMOTE_USER "%{REMOTE_USER}e" env=REMOTE_USER | |
# see http://httpd.apache.org/docs/current/mod/mod_headers.html#header |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT ips[1] AS left_ip, | |
ports[1] AS left_port, | |
(SELECT array_agg(a) FROM jsonb_array_elements_text(vlans->0) AS a) AS left_vlans, | |
(SELECT array_agg(a) | |
FROM jsonb_array_elements_text(vlans->0) AS a | |
WHERE a NOT IN | |
(SELECT b FROM jsonb_array_elements_text(vlans->1) AS b)) as only_left_vlans, | |
ips[2] AS right_ip, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PUT http://localhost:5000/api/v1/object/device/192.0.2.1/nodes | |
# GET/DELETE methods take query string params to filter: | |
# device, port, action, status, username, userip, backend | |
# list of jobs in the queue | |
# accepts LIMIT option | |
GET http://localhost:5000/api/v1/queue/jobs | |
# submit one or more new jobs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT ip | |
FROM device | |
LEFT OUTER JOIN admin ON (device.ip = admin.device | |
AND admin.status = 'queued' | |
AND admin.action = 'macsuck') | |
FULL OUTER JOIN device_skip ON (device_skip.device = device.ip | |
AND (device_skip.actionset @> string_to_array('macsuck', '') | |
OR (device_skip.deferrals >= '10' | |
AND device_skip.last_defer > (LOCALTIMESTAMP - '7 days' ::interval)))) | |
WHERE admin.device IS NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PUT http://localhost:5000/api/v1/action/macsuck/192.0.2.1?enqueue=true×tamp=now | |
port | |
mac | |
vlan? | |
params - "not part of the resource itself" so OK for query string | |
cannot use macsuck_no because then job refuses to run | |
but will rows be removed by snmp job exec? | |
skip is_macsuckable_now in check phase | |
use early phase to gather data or skip if in `extra` or `port` (mnemonic: path), use store to store. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ignore_deviceports: | |
'group:__ANY__': | |
- 'port:EOBC' | |
- 'port:unrouted VLAN(?: \d+)?' | |
# etc... | |
'vendor:juniper': | |
- '128.0.0.0/2' | |
- 'port:.+\.1638[3456]' | |
- 'port:.+\.3276[789]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
our $home; | |
BEGIN { | |
use FindBin; | |
FindBin::again(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter { | |
# strip the syslog PRI part and create facility and severity fields. | |
# the original syslog message is saved in field %{syslog_raw_message}. | |
# the extracted PRI is available in the %{syslog_pri} field. | |
# | |
# You get %{syslog_facility_code} and %{syslog_severity_code} fields. | |
# You also get %{syslog_facility} and %{syslog_severity} fields if the | |
# use_labels option is set True (the default) on syslog_pri filter. | |
grok { | |
type => "syslog-relay" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# curl -f >> onto authorized_keys | |
# grep a_k for certs | |
# if more than two lines | |
# sed out the first N of them | |
curl -sf https://my-cert.pub >> ~/.ssh/authorized_keys && | |
sed -i '' '1!G;h;$!d' ~/.ssh/authorized_keys && | |
awk '!/^cert-authority / || ++n < 3' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp && | |
sed '1!G;h;$!d' ~/.ssh/authorized_keys.tmp > ~/.ssh/authorized_keys && | |
rm ~/.ssh/authorized_keys.tmp && |
NewerOlder