Skip to content

Instantly share code, notes, and snippets.

View discreet's full-sized avatar

Chris Pisano discreet

  • Morning Consult
  • Washington D.C.
View GitHub Profile
@discreet
discreet / SplunkUF_Version
Last active August 29, 2015 14:01
Splunk Universal Forwarder Version
#This fact will pull the Splunk Universal Forwarder version and then normalize it so you can use versioncmp in Puppet to update your Splunk Universal Forwarders.
#Splunk Universal Forwarder Version
Facter.add("SplunkUF_Version") do
confine :osfamily => "RedHat"
setcode do
SplunkUF_Version = Facter::Util::Resolution.exec("/opt/splunkforwarder/bin/splunk --version | awk {'print $4'}")
if SplunkUF_Version.length < 5
@discreet
discreet / Puppet Graphite
Last active August 29, 2015 14:01
Mark Puppet Changes in Graphite
#This will have Puppet send it's changes to Graphite and mark a vertical line on any graph you create to show when the change was made and make it easy to correlate before and after utilization.
require 'puppet'
require 'yaml'
require 'socket'
require 'time'
Puppet::Reports.register_report(:graphite_event) do
configfile = File.join([File.dirname(Puppet.settings[:config]), "graphite_event.yaml"])
@discreet
discreet / Drive Path NRPE
Last active August 29, 2015 14:01
Drive Path for NRPE
#!/bin/bash
#This script pulls the drive path and sets the check command for NRPE. It is outputted to a file that is included int he nrpe.cfg file.
rm -f check_disk.cfg 2> /dev/null;
df -H | grep "/dev" | awk {'print $1'}> out.txt
sed -i "s|tmpfs|/dev/shm|g" out.txt;
no="0"
while read line
do
no=$[$no+1]
@discreet
discreet / Domain_Access
Last active August 29, 2015 14:01
This fact will pull a list of domain users and groups who have access
#This fact will pull securiy groups and users who have access if you are using PBIS.
Facter.add("Domain_Access") do
confine :osfamily => "RedHat"
setcode do
if File.directory? "/opt/likewise"
Domain_Access = `/opt/likewise/bin/lwconfig --detail RequireMembershipOf | grep '"' | sed -e 's/^"//' -e 's/"$//' | awk -F'\\' '{print $3}'`
$Access = split($Domain_Access, ' ')
Domain_Access
end
@discreet
discreet / NRPE_Version
Created May 15, 2014 12:28
This will pull the NRPE version from RHEL/CentOS Servers. You may need to replace "nrpe" with "nagios-nrpe" depending on your install.
#This will pull the package version of the NRPE client
Facter.add("NRPE_Version") do
confine :osfamily => "RedHat"
setcode do
NRPE_Version = `/bin/rpm -q --queryformat "%{VERSION}" nrpe`
NRPE_Version
end
end
@discreet
discreet / NagiosCheck_Disk
Created June 30, 2014 00:02
Puppet Fact for Nagios Check_Disk
#Disks to check for Nagios alerting
Facter.add("Check_Disks") do
confine :osfamily => "RedHat"
setcode do
Check_Disks = Facter::Util::Resolution.exec("cat /etc/nagios/check_disk.cfg | cut -c 9-19")
end
end
@discreet
discreet / NSClient++_Version
Created June 30, 2014 00:03
NSClient++ Version
#NSClient++ Version
Facter.add("NSClient_Version") do
confine :osfamily => "Windows"
setcode do
NSClient_Version = Facter::Util::Resolution.exec("command to pull version")
#only use the below if and while in the case of normalizing version numbers
#the below code is assuming symantec versioning is being used (ex. 3.5.1)
#if NSClient_Version.length < 5
@discreet
discreet / vmware-tools_service
Created July 8, 2014 12:51
vmware-tools as a service centos 6
cp /etc/vmware-tools/services.sh /etc/init.d/vmware-tools
vim /etc/init.d/vmware-tools
Paste the following just below the line ##VMWARE_INIT_INFO## and save:
chkconfig: 235 03 99
chkconfig --add vmware-tools
chkconfig vmware-tools on
@discreet
discreet / remove_udev.sh
Created September 29, 2014 14:32
Remove udev rules
#!bin/bash
#
# chkconfig: 35 20 30
# description: A problem exists when cloining a virtual machine
# that is currently up when using vmware. The problem
# this script solves is to remove the udev rule for
# networking.
# source function library
. /etc/rc.d/init.d/functions
@discreet
discreet / rhelkey.rb
Created September 29, 2014 14:33
Spacewalk Registration Key
# facter rhelkey
#
# This fact will determine which patching group should be applied
# to the server when added to satellite so the need to manually
# add servers to groups will be eliminated.
Facter.add('rhelkey') do
setcode do
myenv = Facter.value('hostname').scan(/(^\D+\d)/).to_s
odd_even = Facter.value('hostname').scan(/^\D+\d\D+(\d+)/).to_s