The Energy Detective (TED) Data Gathering

Now that I am getting data and graphing it from the Enphase Envoy, I want to get data from my The Energy Detective (TED). I can then graphically view usage and compare it to my solar generation. Here is what I did:

 

I am setting this up on a CentOS 7 VM. I am already running Apache on it, I am not going to go over how to get that going. It is the same VM I used for the Enphase.

 

ted6000 is the name of my TED. You will see it a couple times in the script. Replace it with your URL

 

# If needed Install rrdtool and lynx (you will need the EPEL repos)

 

sudo yum install rrdtool lynx

 

# Then we create the database. I called mine ted.rrd, you can name your what you want. You will just need to note the name in the script below.

 

sudo rrdtool create ted.rrd -s 300 DS:temp:GAUGE:900:-55:125 RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:672 RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460

 

#Now create the web directory.

 

sudo mkdir /var/www/html/ted/

 

#I created the below script in /usr/local/bin/ and made it executable.

 

#!/bin/bash

# get the EPOCH date

 

DATE=$(/bin/date +%s)

#lets get in the right directory

 

cd /etc/ted/watts

#Now we get the data we need and get it into a number

 

RAW=$(lynx -dump http://ted6000/stats.htm | grep '(W)' | sed -r 's/\s+//g'| cut -d":" -f2)

#make it a variable

 

KW=$(/usr/bin/echo "scale=3; $RAW/1000" | bc -l)

#get data into rrd

 

rrdtool update ted_watts.rrd $DATE:$KW

#create daily graph

 

rrdtool graph /var/www/html/ted/ted_watts_day.png -s -1day DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

#create weekly graph

 

rrdtool graph /var/www/html/ted/ted_watts_week.png -s -1week DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

#create monthly graph

 

rrdtool graph /var/www/html/ted/ted_watts_month.png -s -1month DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

#create yearly graph

 

rrdtool graph /var/www/html/ted/ted_watts_year.png -s -1year DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

 

 

##Here is the final Product:

 

Daily

 

ted watts day

 

Weekly:

 

ted watts week

 

Month:

 

ted watts month

##Here it the no mark-up version:

 

#!/bin/bash

# get the EPOCH date
DATE=$(/bin/date +%s)

#lets get in the right directory
cd /etc/ted/watts

#Now we get the data we need and get it into a number
RAW=$(lynx -dump http://ted6000/stats.htm | grep ‘(W)’ | sed -r ‘s/\s+//g’| cut -d”:” -f2)

#make it Kw and put it in a file I can use for other things
#/usr/bin/echo “scale=3; $RAW/1000” | bc -l |sed ‘s/^/, /’ | sed -e “s/^/$(date) /” >> TED_DATA.csv

#make it a variable
KW=$(/usr/bin/echo “scale=3; $RAW/1000” | bc -l)

#get data into rrd
rrdtool update ted_watts.rrd $DATE:$KW

#create daily graph
rrdtool graph /var/www/html/ted/ted_watts_day.png -s -1day DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#create weekly graph
rrdtool graph /var/www/html/ted/ted_watts_week.png -s -1week DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#create monthly graph
rrdtool graph /var/www/html/ted/ted_watts_month.png -s -1month DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#create yearly graph
rrdtool graph /var/www/html/ted/ted_watts_year.png -s -1year DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

Enphase Data Gathering

I wanted to see if I could pull data from my Enphase and stuff it in a graph for my own use. Turns out using the power of open source anything can be done. This is what I did:

I am setting this up on a CentOS 7 VM. I am already running Apache on it, I am not going to go over how to get that going.

Solar is the name of my Enphase Envoy. You will see it a couple times in the script. Replace it with your URL

# Install rrdtool and lynx (you will need the EPEL repos)

sudo yum install rrdtool lynx

 

#Then we create the database. I called mine enphase.rrd, you can name your what you want. You will just need to note the name in the script below.

sudo rrdtool create enphase.rrd -s 300 DS:temp:GAUGE:900:-55:125 RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:672 RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460

 

#Now create the web directory.

sudo mkdir /var/www/html/enphase/

 

#I created the below script in /usr/local/bin/ and made it executable.

#!/bin/bash
# get the EPOCH date

DATE=$(/bin/date +%s)

 

# get to the right directory

cd /etc/enphase

 

# remove old files

rm ENPHASE.csv
rm kw2.txt

 

# Get the data and dump it into a CSV file

lynx -dump http://solar.hohenfels.com/production?locale=en | grep ly > kw.txt

 

# The Enphase Envoy uses Kilowatts (kW) and Watts (W). So a little creativity is required: If I find kW, clean it up, add the date and dump it in the CSV. If I dont find kW then clean it up and put it in a text file called kw2.txt. If it is not kW then it has to be W. when not producing it shows 0W

if grep -q 'kW' "kw.txt"; then
cat kw.txt | sed 's/[A-Za-z%]*//g' | sed -r 's/\s+//g' | sed 's/^/, /' | sed -e "s/^/$(date) /" >> ENPHASE.csv
else
cat kw.txt | sed 's/[A-Za-z%]*//g' | sed -r 's/\s+//g' > kw2.txt
fi

 

# Make the kw2.txt file a variable

 KW2=$(cat kw2.txt)

# Do some math and get our variable into kW and dump it in the CSV.

/usr/bin/echo "scale=3; $KW2/1000" | bc -l |sed 's/^/, /' | sed -e "s/^/$(date) /" >> ENPHASE.csv

 

# Get the data into a variable we can use for RRD

KW=$(cat ENPHASE.csv | sed 's/[A-Za-z ]*//g' | cut -d"," -f2)

# I wanted to make sure things worked up to this point:

echo $KW >> debug.log
echo $DATE >> debug.log

# Finally get data into rrd

rrdtool update enphase.rrd $DATE:$KW

# create daily graph

rrdtool graph /var/www/html/enphase/enphase_day.png -s -1day DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa 

 

# create weekly graph

rrdtool graph /var/www/html/enphase/enphase_week.png -s -1week DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

# create monthly graph

rrdtool graph /var/www/html/enphase/enphase_month.png -s -1month DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

# create yearly graph

rrdtool graph /var/www/html/enphase/enphase_year.png -s -1year DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

 

##Here is the final daily product:

enphase day

##Weekly

 

enphase week

 

#Month

 

enphase month

 

# Here it is with no mark-up:

#!/bin/bash

# get the EPOCH date

DATE=$(/bin/date +%s)

#get to the right directory

cd /etc/enphase

#remove old files

rm ENPHASE.csv
rm kw2.txt

#Get the data ready for a csv for MariaDB

lynx -dump http://solar.hohenfels.com/production?locale=en | grep ly > kw.txt

if grep -q ‘kW’ “kw.txt”; then
cat kw.txt | sed ‘s/[A-Za-z%]*//g’ | sed -r ‘s/\s+//g’ | sed ‘s/^/, /’ | sed -e “s/^/$(date) /” >> ENPHASE.csv
else
cat kw.txt | sed ‘s/[A-Za-z%]*//g’ | sed -r ‘s/\s+//g’ > kw2.txt
fi

KW2=$(cat kw2.txt)

/usr/bin/echo “scale=3; $KW2/1000” | bc -l |sed ‘s/^/, /’ | sed -e “s/^/$(date) /” >> ENPHASE.csv

#Get the data into a variable

KW=$(cat ENPHASE.csv | sed ‘s/[A-Za-z ]*//g’ | cut -d”,” -f2)

##DEBUG

echo $KW >> debug.log
echo $DATE >> debug.log

#get data into rrd

rrdtool update enphase.rrd $DATE:$KW

#create daily graph

rrdtool graph /var/www/html/enphase/enphase_day.png -s -1day DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#create weekly graph

rrdtool graph /var/www/html/enphase/enphase_week.png -s -1week DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#create monthly graph

rrdtool graph /var/www/html/enphase/enphase_month.png -s -1month DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#create yearly graph

rrdtool graph /var/www/html/enphase/enphase_year.png -s -1year DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

RRD Setup Example 1

Here is what I did to get the web control units to report back to RRDTool

First create the database:

 

# rrdtool create office_temp.rrd -s 300 DS:temp:GAUGE:900:-55:125 RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:672 RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460

 

Then the script to pull the data:

 

#!/bin/bash

# get the EPOCH date

 

DATE=$(/bin/date +%s)

 

# get temp. Change this to correct location probably /etc/temperatures/

 

TEMP=$(/bin/cat /etc/temperature/buildings/office/office_temp.txt)

 

# get to the right directory this is most likely the directory above

 

cd /etc/temperature/buildings/office/

 

# get the date from the web control unit for sensor 1.

 

wget http://192.168.1.16/gett1.cgi --http-user=office --http-password=1qazxsw2

 

# cat it to a file

 

cat gett1.cgi > office_temp

 

# get rid of everything but the numbers

 

cat office_temp | sed 's/[A-Za-z%]*//g' > office_temp.txt

 

# remove the original file

 

rm -f gett1.cgi

 

# get it into rrd

 

rrdtool update ../office_temp.rrd $DATE:$TEMP

 

# create Daily graph

 

rrdtool graph /var/www/html/temperatures/buildings/office_temp_day.png -s -1day DEF:shop=../office_temp.rrd:temp:AVERAGE LINE1:shop#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

 

# create Weekly graph

 

rrdtool graph /var/www/html/temperatures/buildings/office_temp_week.png -s -1week DEF:shop=../office_temp.rrd:temp:AVERAGE LINE1:shop#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

 

# create monthly graph

 

rrdtool graph /var/www/html/temperatures/buildings/office_temp_month.png -s -1month DEF:shop=../office_temp.rrd:temp:AVERAGE LINE1:shop#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

 

# create Yearly graph

 

rrdtool graph /var/www/html/temperatures/buildings/office_temp_year.png -s -1year DEF:shop=../office_temp.rrd:temp:AVERAGE LINE1:shop#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

 

Then Create the web page:

 

<!DOCTYPE html>

<html>

<body>

<meta http-equiv=”refresh” content=”120″>

<p><b>Office Temperature Daily Graph.</b></p>

<IMG SRC=”buildings/office_temp_day.png” ALT=”Daily Office Humidity Graph” WIDTH=600 HEIGH=400>

</body>

</html>

 

Maintenance Stuff

 

To remove drops or spikes first dump the databae to XML:

 

sudo rrdtool dump shop_temp.rrd shop_temp.xml

 

Then Edit out the bad data:

 

sudo vi shop_temp.xml

 

Save off the original database:

 

sudo mv shop_temp.rrd shop_temp.rrd.evo

 

Last restore the database:

 

sudo rrdtool restore shop_temp.xml shop_temp.rrd

Nagios / NRPE

##Install NRPE and Plugins make sure you have access to EPEL if RHEL/CentOS

sudo yum install nrpe nagios-plugins-all
sudo apt-get install nagios-nrpe-server nagios-plugins

##Then vi /etc/nagios/nrpe.cfg to point to our server:

allowed_hosts=172.16.4.0/24

##I had to comment out the server address

#server_address=127.0.0.1

##Make sure our commands look like this to begin with

command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_root]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/mapper/vg_mul4-lv_root
command[check_boot]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1
command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 220 -c 320
command[check_swap]=/usr/lib64/nagios/plugins/check_swap -w 20 -c 10
command[check_ntp_time]=/usr/lib64/nagios/plugins/check_ntp_time -H 0.centos.pool.ntp.org -w 0.5 -c 1

##Check your config

sudo nagios -v /etc/nagios/nagios.cfg

##Open Firewall

sudo firewall-cmd --zone=public --add-port=5666/tcp --permanent

##Restart Firewall

sudo systemctl restart firewalld.service

## Set SELinux

sudo /sbin/restorecon -v /etc/nagios/nrpe.cfg

##Start the service and enable it

sudo systemctl start nrpe
sudo systemctl enable nrpe

 

## For Custom Command ##

 

##Copy the below to /usr/lib64/nagios/plugins/check_mcafee:

#!/bin/bash
#Get to the right directory
#Set a couple variables
REPO=$(curl -ls http://vscl-repo.aac.va.gov/vscl/ | grep zip | cut -d"-" -f2 | cut -d"." -f1)
SYSTEM=$(/usr/local/bin/uvscan --VERSION | grep Dat | cut -d":" -f2 | cut -d" " -f2)

#Find the difference
MATH=$(($REPO-$SYSTEM))

case $MATH in
[0])
echo "OK - $REPO Mcafee is Current."
exit 0
;;
[1-4])
echo "WARNING - Mcafee is $MATH version behind. Current Installed Version $SYSTEM. $REPO Avaliable"
exit 1
;;
[5-9]|1[0-9])
echo "CRITICAL - Mcafee is $MATH versions behind. Current Installed Version $SYSTEM. $REPO Avaliable"
exit 2
;;
*)
echo "UNKNOWN - Mcafee is $MATH versions behind. Current Installed Version $SYSTEM."
exit 3
;;
esac

##Make root the owner

chown root.root /usr/lib64/nagios/plugins/check_mcafee

##Make it executable

chmod 755 /usr/lib64/nagios/plugins/check_mcafee

##in host /etc/nagios/nrpe.cfg add to the command section:

command[check_mcafee]=/usr/lib64/nagios/plugins/check_mcafee

##test by running

/usr/lib64/nagios/plugins/check_mcafee
OK - 7730 Mcafee is Current.

##set up nagios to receive

##Define new command in /etc/nagios/objects/commands.cfg

define command{
        command_name    check_mcafee
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_mcafee
        }

##To change an individual service check interval add the ‘normal_check_interval’ and ‘notification_interval’ to the service.cfg file. The interval is in minutes, in the below example it is 720 which is 12 hours.

##In the service.cfg file:

#check McAfee##

define service {
        use                         generic-service
        host_name                   vaauslbe126
        service_description         Check McAfee Anti Virus
        check_command               check_nrpe!check_mcafee
        normal_check_interval       720
        notification_interval       720
        }

#

Katello

##What I had to do to get it installed:

##Make Sure the /etc/hosts is right

127.0.0.1          mul72.hohenfels.com mul72 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1                mul72.hohenfels.com mul72 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.19       mul72.hohenfels.com mul72

##Made Sure everything was updated

sudo yum update

##Ran the Installer: Made sure under capsule (4) that TFTP was set to TRUE and that the DNS settings are correct.

sudo katello-installer -i
Welcome to the Kafo installer!
------------------------------

This wizard will gather all required information. You can change any parameter
to your needs.


Ready to start? (y/n)
y

Main Config Menu
1. [?] Configure certs
2. [?] Configure katello
3. [?] Configure foreman
4. [?] Configure capsule
5. [?] Configure foreman_plugin_bootdisk
6. [?] Configure foreman_plugin_discovery
7. [?] Configure foreman_plugin_hooks
8. [?] Configure foreman_plugin_tasks
9. [?] Configure foreman_plugin_chef
10. [?] Configure foreman_plugin_default_hostgroup
11. [?] Configure foreman_plugin_puppetdb
12. [?] Configure foreman_plugin_setup
13. [?] Configure foreman_plugin_templates
14. Display current config
15. Save and run
16. Cancel run without Saving

Chance all to a check and change 1

15 to go

##To get LibVirt/KVM going as a Compute Resource:

To provision systems on KVM using Red Hat Satellite 6 follow the below steps
  • Create a .ssh directory under /usr/share/foreman and assign permissions as below.
[user@satellite ~]# sudo mkdir /usr/share/foreman/.ssh
[user@satellite ~]# sudo chmod 700 /usr/share/foreman/.ssh
[user@satellite ~]# sudo chown foreman:foreman /usr/share/foreman/.ssh
  • Create ssh keys for foreman user to login to the KVM host.
[user@satellite ~]# sudo su - foreman -s /bin/bash

bash-4.1$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/usr/share/foreman/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /usr/share/foreman/.ssh/id_rsa.
Your public key has been saved in /usr/share/foreman/.ssh/id_rsa.pub.
The key fingerprint is:
48:d2:f5:5b:2a:63:7e:ae:a3:c6:31:54:d2:33:21:25 foreman@satellite.example.com
The key's randomart image is:
+--[ RSA 2048]----+
|      Eo+.       |
|     ..+=.       |
|    . oo o. .    |
|     o..   +     |
|     .. S o      |
|      oo o       |
|     . o. .      |
|      o .o       |
|     ....o.      |
+-----------------+

bash-4.1$ ssh-copy-id root@kvm.example.com
The authenticity of host 'kvm.example.com (192.168.1.2)' can't be established.
RSA key fingerprint is b8:4c:bf:8a:df:70:e1:2b:71:a1:6f:0a:d2:f9:2f:2a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'kvm.example.com' (RSA) to the list of known hosts.
root@kvm.example.com's password: 
Now try logging into the machine, with "ssh 'root@kvm.example.com'", and check in:

.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

bash-4.1$ ssh root@kvm.example.com
Last login: Fri Dec  5 23:34:35 2014 from host.example.com

[root@kvm ~]# exit
  • If SELinux is in enforcing mode, then restore the SELinux context for /usr/share/foreman/.ssh/ folder.
[user@satellite ~]# sudo restorecon -Rv /usr/share/foreman/.ssh/
  • Make sure that KVM packages are installed on the KVM host and libvirtd service is running.
[user@kvm ~]# sudo service libvirtd status   -----> On RHEL 6
[user@kvm ~]# sudo systemctl status libvirtd.service   -----> On RHEL 7

Note: If KVM is not installed, install the packages as below on the KVM host

[user@kvm ~]#sudo yum install qemu-kvm libvirt virt-install bridge-utils virt-manager -y
  • Start the libvirtd service as below
[user@kvm ~]#sudo service libvirtd start   -----> on RHEL 6
[user@kvm ~]#sudo systemctl start libvirtd.service   -----> on RHEL 7
  • Enable the libvirtd service on boot
[user@kvm ~]#sudo chkconfig libvirtd on    ---> on RHEL 6
[user@kvm ~]#sudo systemctl enable libvirtd.service ---> on RHEL 7
  • On satellite 6 webUI —–> Infrastructure —–> Compute resources —> Click on New Compute Resource
    Specify Name —–> My KVM Host
    Select Provider —–> Libvirt
    Specify URL —–> qemu+ssh://root@kvm.example.com/system
    Click Test Connection
  • Finally provision a host using the above created Libvirt compute resource.

https://access.redhat.com/solutions/1288483

##Setting up HammerCLI

##Create the Directories

mkdir ~/.hammer
chmod 700 ~/.hammer

##Create a cli_config.yml file in the new directory

vi ~/.hammer/cli_config.yml
   :foreman:
       :host: 'https://xxx'
       :username: 'admin'
       :password: 'xxx'

##Run it:

hammer shell

##I was getting a pulp-admin ssl error

 pulp-admin -u erik -p password tasks cancel --task-id "7aa48f52-a6be-4c08-9810-16dd3a06d930"
WARNING: The server's SSL certificate is untrusted!

The server's SSL certificate was not signed by a trusted authority. This could
be due to a man-in-the-middle attack, or it could be that the Pulp server needs
to have its certificate signed by a trusted authority. If you are willing to
accept the associated risks, you can set verify_ssl to False in the client
config's [server] section to disable this check.

Here is how I fixed it – Not Secure:

Pulp has a setting called verify_ssl in these files: /etc/pulp/admin/admin.conf, /etc/pulp/consumer/consumer.conf, /etc/pulp/nodes.conf, and /etc/pulp/repo_auth.conf. If you configure these settings to false, the respective Pulp components will no longer validate the Pulp server's certificate signature.

REF: https://github.com/pulp/pulp/blob/master/docs/user-guide/installation.rst

#

Satellite – Spacewalk Info

## To get the boot strap working on a pre-installed server I added the below to the bootstrap file ##

For RHEL/CentOS7:

yum -y install http://10.226.2.78/pub/spacewalk-client-repo-2.2-1.el7.noarch.rpm
yum -y install http://fedora-epel.mirror.lstn.net/7/x86_64/e/epel-release-7-2.noarch.rpm
yum -y install rhn-setup rhn-client-tools

For RHEL/CentOS6:

yum -y install http://10.226.2.78/pub/spacewalk-client-repo-2.2-1.el6.noarch.rpm
yum -y install http://fedora-epel.mirror.lstn.net/6/x86_64/epel-release-6-8.noarch.rpm
yum -y install rhn-setup rhn-client-tools

Adding common channels the easy way:

spacewalk-common-channels -v -n -u satadmin -p password -a x86_64 'spacewalk*'

Get a list of common channels available:

spacewalk-common-channels -l

Creating a bootable ISO with Cobbler

##First List Cobbler Profiles##

sudo cobbler list profiles

distros:
   External_-_CentOS_6_x86_64:1:SpacewalkDefaultOrganization
   External_-_CentOS_7_x86_64:1:SpacewalkDefaultOrganization

profiles:
   Hohenfels_Basic_7:1:SpacewalkDefaultOrganization
   Hohenfels_Default_6:1:SpacewalkDefaultOrganization
   Hohenfels_Default_7:1:SpacewalkDefaultOrganization

systems:

repos:

images:

##Then build the ISO##

sudo cobbler buildiso --profiles=Hohenfels_Basic_7:1:SpacewalkDefaultOrganization --iso=output_dir_here

##For Multiple Profiles##

sudo cobbler buildiso --profiles="Hohenfels_Basic_7:1:SpacewalkDefaultOrganization, Hohenfels_Default_7:1:SpacewalkDefaultOrganization"

#To Clean Up the DB

sudo spacewalk-data-fsck -r -v

vacuumdb -aef (su - postgres)

##To delete a server from using Spacewalk

##Delete the server from the WebGUI

##On the Client:

sudo vi /etc/yum/pluginconf.d/rhnplugin.conf

##And change:

[main]
enabled = 1

#to

[main]
enabled = 0

##Then

sudo rm -rf /etc/sysconfig/rhn/systemid

##Remove the spacewalk repos if they are there:

sudo rm /etc/yum.repos.d/spacewalk-client*

# How to remove Channels from the Sat

/usr/bin/spacewalk-remove-channel -c channel_name

 

#

Logging

##Setting up Centralized Logging:

http://www.unixmen.com/install-and-configure-rsyslog-in-centos-6-4-rhel-6-4/

##The Only things I changed:

#Did not want to install to many packages

sudo yum install rsyslog-mysql

#URL to the latest:

wget http://download.adiscon.com/loganalyzer/loganalyzer-3.6.6.tar.gz

 #To stop excessive logging

#For snmp I created a file called snmp.conf located in /etc/rsyslog.d/

:msg, contains, "Connection from UDP" stop 
:programname, contains, "snmpd" -/var/log/snmpd.log
& stop

#Dont Log any messages that contain “Connection from UDP”

:msg, contains, "Connection from UDP" stop

#The rest of messages created by the program snmpd put in its own log

:programname, contains, "snmpd" -/var/log/snmpd.log
& stop

On RHEL CentOS 6 put the same info directly in /etc/rsyslog.conf and replace ‘stop’ with ~

:msg, contains, "Connection from UDP" ~ 
:programname, contains, "snmpd" -/var/log/snmpd.log
& ~

##

Could not reliably determine the server’s fully qualified domain name

I had a sever that every I restarted the httpd service I got “Could not reliably determine the server’s fully qualified domain name” To fix it I created a file called fqdn.conf in /etc/httpd/conf.d/

$sudo vi /etc/httpd/conf.d/fqdn.conf

and add:

ServerName mul1.hohenfels.com

Then

$sudo service httpd restart

$sudo systemctl restart httpd

And everything should come back up clean

Setting up https on RHEL and CentOS 6 and 7

Here is how to get HTTPS/SSL working on Red Hat/CentOS 6 and 7

$ sudo yum install mod_ssl openssl

Now let’s generate our own self signed Certificate:

Generate private key

$sudo openssl genrsa -out ca.key 2048 

 

Generate CSR

$sudo openssl req -new -key ca.key -out ca.csr

 

Generate Self Signed Key

 

$sudo openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt

 

Copy the files to the correct locations

$sudo cp ca.crt /etc/pki/tls/certs$sudo cp ca.key /etc/pki/tls/private/ca.key

$sudo cp ca.csr /etc/pki/tls/private/ca.csr

 

Next up, modify the ssl.conf file:

$sudo vi /etc/httpd/conf.d/ssl.conf

Change the paths to match where the Key file is stored. If you’ve used the method above it will be:

 SSLCertificateFile /etc/pki/tls/certs/ca.crt

Then set the correct path for the Certificate Key File a few lines below. If you’ve followed the instructions above it is:

 SSLCertificateKeyFile /etc/pki/tls/private/ca.key

While we are in there let’s take care of the latest Poodle Vulnerability: (if needed)

 SSLProtocol all -SSLv2 -SSLv3

 Restart web service:

$sudo service httpd restart

$sudo systemctl restart httpd

 

Copy Protected by Chetan's WP-Copyprotect.