Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import requests
import sys
import json
from datetime import date, timedelta
#Your PagerDuty API key. A read-only key will work for this.
AUTH_TOKEN = 'YOUR_API_KEY'
#The API base url, make sure to include the subdomain
#!/usr/bin/env python
"""
A script to query the Amazon Web Services usage reports programmatically.
Ideally this wouldn't exist, and Amazon would provide an API we can use
instead, but hey - that's life.
Basically takes your AWS account username and password, logs into the
website as you, and grabs the data out. Always gets the 'All Usage Types'
#!/usr/bin/env python
"""
A script to query the Amazon Web Services usage reports programmatically.
Ideally this wouldn't exist, and Amazon would provide an API we can use
instead, but hey - that's life.
Basically takes your AWS account username and password, logs into the
website as you, and grabs the data out. Always gets the 'All Usage Types'
@cjs226span
cjs226span / gist:1387701
Created November 23, 2011 01:52
Problem starting OSSEC agent using Chef ossec cookbook
2011/11/23 01:49:22 ossec-execd: INFO: Started (pid: 21856).
2011/11/23 01:49:22 ossec-agentd(1410): INFO: Reading authentication keys file.
2011/11/23 01:49:22 ossec-agentd(1750): ERROR: No remote connection configured. Exiting.
2011/11/23 01:49:25 ossec-syscheckd(1210): ERROR: Queue '/var/ossec/queue/ossec/queue' not accessible: 'Connection refused'.
2011/11/23 01:49:25 ossec-rootcheck(1210): ERROR: Queue '/var/ossec/queue/ossec/queue' not accessible: 'Connection refused'.
2011/11/23 01:49:31 ossec-logcollector(1210): ERROR: Queue '/var/ossec/queue/ossec/queue' not accessible: 'Connection refused'.
2011/11/23 01:49:31 ossec-logcollector(1211): ERROR: Unable to access queue: '/var/ossec/queue/ossec/queue'. Giving up..
2011/11/23 01:49:33 ossec-syscheckd(1210): ERROR: Queue '/var/ossec/queue/ossec/queue' not accessible: 'Connection refused'.
2011/11/23 01:49:33 ossec-rootcheck(1210): ERROR: Queue '/var/ossec/queue/ossec/queue' not accessible: 'Connection refused'.
2011/11/23 01:49:46 ossec-syscheckd(1210): ER
@cjs226span
cjs226span / d.rsyslog.conf
Created September 20, 2011 18:39
Sample rsyslog config that is incorrectly spewing the same syslog lines repeatedly
$InputFileName /var/log/spanning/mailcli_production_daemon_19.log
$InputFileTag mailcli_production_daemon_19.log
$InputFileStateFile mailcli_production_daemon_19.log
$InputFileSeverity info
$InputFileFacility local7
$InputRunFileMonitor
@cjs226span
cjs226span / gist:1176198
Created August 28, 2011 03:23
knife ec2 server create error: Exception: NoMethodError: undefined method `empty?' for true:TrueClass
/Library/Ruby/Gems/1.8/gems/knife-ec2-0.5.8/lib/chef/knife/ec2_base.rb:74:in `msg_pair': undefined method `empty?' for true:TrueClass (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/knife-ec2-0.5.8/lib/chef/knife/ec2_server_create.rb:233:in `run'
from /Library/Ruby/Gems/1.8/gems/chef-0.10.4/lib/chef/knife.rb:391:in `run_with_pretty_exceptions'
from /Library/Ruby/Gems/1.8/gems/chef-0.10.4/lib/chef/knife.rb:166:in `run'
from /Library/Ruby/Gems/1.8/gems/chef-0.10.4/lib/chef/application/knife.rb:128:in `run'
from /Library/Ruby/Gems/1.8/gems/chef-0.10.4/bin/knife:25
from /usr/bin/knife:19:in `load'
from /usr/bin/knife:19
One the client:
root@ip-10-0-2-186:~# updatedb
root@ip-10-0-2-186:~# locate client.pem
/usr/share/doc/libssl-dev/demos/tunala/A-client.pem.gz
On the server:
[csmith@opschef01 Fri Aug 26 10:00 PM] ~/.chef
$ knife node list
@cjs226span
cjs226span / gist:1174418
Created August 26, 2011 20:54
chef - can't register clients
~# tail /var/log/chef/client.log
[Fri, 26 Aug 2011 20:27:00 +0000] INFO: Forked, in 2335. Priveleges: 0 0
[Fri, 26 Aug 2011 20:27:05 +0000] INFO: *** Chef 0.10.4 ***
[Fri, 26 Aug 2011 20:27:06 +0000] INFO: Client key /etc/chef/client.pem is not present - registering
[Fri, 26 Aug 2011 20:27:09 +0000] INFO: HTTP Request Returned 500 Internal Server Error: Connection refused - connect(2)
[Fri, 26 Aug 2011 20:27:09 +0000] ERROR: Server returned error for http://chef.spanning.co:4000/clients, retrying 1/5 in 4s
[Fri, 26 Aug 2011 20:27:14 +0000] INFO: HTTP Request Returned 409 Conflict: Client already exists
[Fri, 26 Aug 2011 20:27:14 +0000] INFO: HTTP Request Returned 403 Forbidden: You are not allowed to take this action.
[Fri, 26 Aug 2011 20:27:14 +0000] ERROR: Net::HTTPServerException: 403 "Forbidden"
[Fri, 26 Aug 2011 20:27:14 +0000] FATAL: Stacktrace dumped to /var/cache/chef/chef-stacktrace.out
@cjs226span
cjs226span / gist:1174407
Created August 26, 2011 20:50
chef - error deleting clients
[csmith@opschef01 Fri Aug 26 08:48 PM] ~/.chef
$ knife client list
chef-validator
chef-webui
chickenfry
csmith
csmith_opslog02
i-978d81f6
ops-chef-01
root