Skip to content

Instantly share code, notes, and snippets.

View shaneramey's full-sized avatar

Shane Ramey shaneramey

View GitHub Profile

Keybase proof

I hereby claim:

  • I am shaneramey on github.
  • I am shaneramey (https://keybase.io/shaneramey) on keybase.
  • I have a public key ASBWUMm6D4U5Tvrh4Q6HGaKRMDfS8pJwAAoog0yjCueBXwo

To claim this, I am signing this object:

@shaneramey
shaneramey / 0_reuse_code.js
Created February 10, 2017 20:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@shaneramey
shaneramey / gist:090f3a81a28c8892e9de
Created October 16, 2014 07:57
show_temp.pl on Pacer site instead of PDF
A lot of people are not using Adobe-brand PDF software on their Windows computers. Without the proper pre-configuration their software may not open PDFs unless they have a ".pdf" extension. I was using Nuance PDF Converter Professional to access the Pacer court web site and every time I would try to download the file I would have to rename the show_temp.pl file to show_temp.pdf before I could get it to open. I discovered that the Pacer web site using a Perl (.pl) script to serve the file, but the script does not redirect to a new URL with a .pdf extension but rather serves the data up on the fly with the MIME type set to "application/pdf". For some reason the installation of PDF Converter that I was using did not set this MIME type upon installation.
The path in the registry to set the application/pdf MIME type is HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/pdf. I had to create the "application/pdf" subkey, add a string named "Extension" and set its value to ".pdf".
@shaneramey
shaneramey / gist:8a70c3b0c325fe7664d9
Created October 16, 2014 07:55
Configuring Cacti to use Active Directory LDAP
I recently had the opportunity to configure Cacti (0.8.7e) to use LDAP authentication in order to provide network logins for people who might want to view the Cacti graphs. We use this in conjunction with the thold plugin to generate threshold notifications in case disks fill up or other thresholds are met, and email the administrator responsible for managing that machine. These instructions are for Cacti running on a Debian 5.0 box with the PHP LDAP module enabled (by "apt-get install php5-ldap"; other distributions might make you configure an extension=ldap.so .ini file in the /etc/php directory). This queries a Windows Server 2003 Active Directory Domain Controller.
General
Authentication Method: LDAP Authentication
Special Users
Guest User: guest
User Template: guest
LDAP General Settings
@shaneramey
shaneramey / gist:aefe1bb03a13bfff2125
Created October 16, 2014 07:54
Fixing Nagios Error: It appears as though you do not have permission to view information for any of the services you requested
I recently set up a new Nagios installation and was dumbfounded by the following error:
It appears as though you do not have permission to view information for any of the services you requested...
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI
and check the authorization options in your CGI configuration file.
This was happening only occasionally, so I was confused about why this would be...
I was using Debian 5.0.4 ("lenny") with Nagios 3.2.1 and Nagios Plugins version 1.4.14. The installation directory is /usr/local/nagios.
What I found after much troubleshooting is that Nagios was already running after I had set it up as a fresh install. I had upgraded to Nagios 3.2.1 from 3.2.0 and the /etc/init.d/nagios restart command had not been ending the old Nagios process. This meant I ended up with strange entries in my logs like:
@shaneramey
shaneramey / gist:5cde2206f02cb1b6ece8
Created October 16, 2014 07:22
Creating a mac2ip script for arpwatch
For network administrators, being able to trace mac addresses to IP addresses is useful in knowing what's plugged in to your switches. Here's a little script I wrote that takes one argument, the mac-address in hexadecimal format with any number of delimiters, and resolves it to an IP address using an arpwatch database on a Linux machine. It will also resolve the vendor ID using a pre-downloaded database from http://standards.ieee.org/regauth/oui/oui.txt.
Feel free to use it. If you add something, please let me know!
Usage: mac2ip.pl <mac-address>
Example:
jupiter:~# mac2ip.pl 00:16:35:69:88:49
@shaneramey
shaneramey / gist:07370280f189d1df62d2
Created October 7, 2014 18:28
Getting 802.1Q VLANs to work with VMWare
Here’s how to create multiple VLANs on a Linux machine running on a VMWare server. I did this to run arpwatch to monitor IP conflicts on our LAN. Be sure not to send any traffic out these interfaces unless you intend it to broadcast to all attached NICs.
In VMWare:
1) Click on the server root node, and choose the Configuration tab
2) Select the properties for the NIC that you want to use VLAN tagging on
3) Select Edit to enable Promiscuous Mode
Then in Linux:
@shaneramey
shaneramey / gist:a482ba0c4bf830e3546b
Created October 7, 2014 18:28
Computing IP Broadcast Address with VBScript
Here’s a simple script to calculate the broadcast address of a network using its IP address and subnet mask (VBScript)
subnetMaskBytes = Split(“255.255.255.0″, “.”)
ipAddressBytes = Split(“10.1.122.100″, “.”)
broadcastAddress = (ipAddressBytes(0) Or (subnetMaskBytes(0) Xor 255)) & “.” & (ipAddressBytes(1) Or (subnetMaskBytes(1) Xor 255)) & “.” & (ipAddressBytes(2) Or (subnetMaskBytes(2) Xor 255)) & “.” & (ipAddressBytes(3) Or (subnetMaskBytes(3) Xor 255))
@shaneramey
shaneramey / gist:740f47a445d0d5921cf8
Created October 7, 2014 18:27
ntop 4.0.3 noDnsResolution instead of DnsResolutionForAll
After installing ntop 4.0.3 I noticed that I could not get the hostnames to show in the hosts table. This was despite not having specified the -n or the -g flags. After lots of searching, I found that disabling IPv6 would change the run-time configuration to DnsResolution for all. I didn’t see any other articles on the Internet about this so I wrote this to hopefully save you some time.
@shaneramey
shaneramey / gist:13f17acc6f640f1f94df
Created October 7, 2014 18:27
Using Subnet-Directed Broadcasts in SCCM WOL
Here’s a method to add a menu within the SCCM Console and remote-wake (WOL) computers on non-local subnets using subnet-directed broadcasts and mc-wol.exe.
1) Download and install the SCCM Console Extensions (google it; the download link may change with new versions) and mc-wol.exe (http://www.matcode.com/wol.htm). Put mc-wol.exe in C:\Program Files (x86)\SCCMConsoleExtensions\
2) Edit C:\Program Files (x86)\SCCMConsoleExtensions\SCCMAction.vbs, in the Wake On LAN section, to use the mc-wol.exe program you downloaded. This code gets a list of interfaces, and sends a WOL packet to the broadcast address of each interface calculated by its IP address and Netmask.
Be sure to allow subnet-directed broadcasts on your routers. I thank the original author of the console extensions for his/her original code. I added some variables and changed how others are calculated.