Skip to content

Commit 50b7015

Browse files
author
Josiah Ritchie
committed
Updating with some new scripts and changes to previous ones
1 parent a796cb0 commit 50b7015

File tree

5 files changed

+135
-3
lines changed

5 files changed

+135
-3
lines changed

PRTG-Sensors/linux-distro.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
# Set distro to...
1010
if which lsb_release > /dev/null; then
1111
# the LSB description field, removing surrounding quotes if they exist
12-
distro=`lsb_release -ds | sed -e 's/^\"//' -e 's/\"$//'`
12+
distro=`lsb_release -s | sed -e 's/^\"//' -e 's/\"$//'`
13+
version=`lsb_releas -r`
1314
elif [ -a /etc/debian_version ]; then
1415
distro="Debian"
1516
version=`cat /etc/debian_version`
16-
distro="$distro $version"
1717
elif [ -a /etc/centos-release ]; then
1818
distro=`cat /etc/centos-release`
1919
elif [ -a /etc/redhat-release ]; then
@@ -26,6 +26,29 @@ elif [ -a /proc/version ]; then
2626
fi
2727

2828
# Report the findings to PRTG (as output of script)
29+
30+
# Advanced PRTG type sensor output (XML)
31+
# Needs more work before it can be usedi
32+
#if [ -n "no error" ]; then
33+
#<prtg>
34+
# <result>
35+
# <channel>Distribution</channel>
36+
# <value>$distro</value>
37+
# </result>
38+
# <result>
39+
# <channel>Version</channel>
40+
# <value>$version</value>
41+
# </result>
42+
#</prtg>
43+
#else
44+
#<prtg>
45+
# <error>1</error>
46+
# <text>Couldn't retrieve info</text>
47+
#</prtg>
48+
#fi
49+
50+
51+
# Standard PRTG type sensor output
2952
if [ -n "$distro" ]; then
3053
echo "0:0:$distro"
3154
else

install-hhvm-ubuntu.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
# by Josiah Ritchie <jritchie@crosslinkgroup.com>
3+
# script assumes Ubuntu 14.04
4+
5+
# Must be run with root permissions
6+
# sudo will be sufficient
7+
8+
if [ "$(id -u)" != "0" ]; then
9+
echo "This script must be run as root" 1>&2
10+
exit 1
11+
fi
12+
13+
apt-get install libmemcached-dev nginx
14+
15+
curl http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add -
16+
add-apt-repository 'http://dl.hhvm.com/ubuntu'
17+
18+
apt-get update && apt-get install hhvm
19+
20+
update-rc.d hhvm defaults
21+
22+
/usr/share/hhvm/install_fastcgi.sh
23+
/etc/init.d/hhvm restart
24+
/etc/init.d/nginx restart

list-all-cron-jobs.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
3+
# Found script on http://stackoverflow.com/a/137173/264881 by yukondude
4+
5+
# System-wide crontab file and cron job directory. Change these for your system.
6+
CRONTAB='/etc/crontab'
7+
CRONDIR='/etc/cron.d'
8+
9+
# Single tab character. Annoyingly necessary.
10+
tab=$(echo -en "\t")
11+
12+
# Given a stream of crontab lines, exclude non-cron job lines, replace
13+
# whitespace characters with a single space, and remove any spaces from the
14+
# beginning of each line.
15+
function clean_cron_lines() {
16+
while read line ; do
17+
echo "${line}" |
18+
egrep --invert-match '^($|\s*#|\s*[[:alnum:]_]+=)' |
19+
sed --regexp-extended "s/\s+/ /g" |
20+
sed --regexp-extended "s/^ //"
21+
done;
22+
}
23+
24+
# Given a stream of cleaned crontab lines, echo any that don't include the
25+
# run-parts command, and for those that do, show each job file in the run-parts
26+
# directory as if it were scheduled explicitly.
27+
function lookup_run_parts() {
28+
while read line ; do
29+
match=$(echo "${line}" | egrep -o 'run-parts (-{1,2}\S+ )*\S+')
30+
31+
if [[ -z "${match}" ]] ; then
32+
echo "${line}"
33+
else
34+
cron_fields=$(echo "${line}" | cut -f1-6 -d' ')
35+
cron_job_dir=$(echo "${match}" | awk '{print $NF}')
36+
37+
if [[ -d "${cron_job_dir}" ]] ; then
38+
for cron_job_file in "${cron_job_dir}"/* ; do # */ <not a comment>
39+
[[ -f "${cron_job_file}" ]] && echo "${cron_fields} ${cron_job_file}"
40+
done
41+
fi
42+
fi
43+
done;
44+
}
45+
46+
# Temporary file for crontab lines.
47+
temp=$(mktemp) || exit 1
48+
49+
# Add all of the jobs from the system-wide crontab file.
50+
cat "${CRONTAB}" | clean_cron_lines | lookup_run_parts >"${temp}"
51+
52+
# Add all of the jobs from the system-wide cron directory.
53+
cat "${CRONDIR}"/* | clean_cron_lines >>"${temp}" # */ <not a comment>
54+
55+
# Add each user's crontab (if it exists). Insert the user's name between the
56+
# five time fields and the command.
57+
while read user ; do
58+
crontab -l -u "${user}" 2>/dev/null |
59+
clean_cron_lines |
60+
sed --regexp-extended "s/^((\S+ +){5})(.+)$/\1${user} \3/" >>"${temp}"
61+
done < <(cut --fields=1 --delimiter=: /etc/passwd)
62+
63+
# Output the collected crontab lines. Replace the single spaces between the
64+
# fields with tab characters, sort the lines by hour and minute, insert the
65+
# header line, and format the results as a table.
66+
cat "${temp}" |
67+
sed --regexp-extended "s/^(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(.*)$/\1\t\2\t\3\t\4\t\5\t\6\t\7/" |
68+
sort --numeric-sort --field-separator="${tab}" --key=2,1 |
69+
sed "1i\mi\th\td\tm\tw\tuser\tcommand" |
70+
column -s"${tab}" -t
71+
72+
rm --force "${temp}"

rcl.service

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=Retrospect backup client
3+
After=network.target local-fs.target system.slice systemd-journald-dev-log.socket basic.target sysinit.target systemd-journald.socket
4+
Before=shutdown.target graphical.target multi-user.target
5+
6+
[Service]
7+
ExecStart=/usr/local/retrospect/client/retroclient
8+
ExecStop=/usr/local/retrospect/client/retrocpl -stop
9+
Restart=on-failure
10+
RestartSec=60s
11+
12+
[Install]
13+
WantedBy=multi-user.target

testConnectionLimit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ip=$1
55
port=$2
66

7-
for i in {1..100}
7+
for ((i=1; i<=100; i++))
88
do
99
# do nothing just connect and exit
1010
echo "exit" | nc ${ip} ${port};

0 commit comments

Comments
 (0)