View | Details | Raw Unified | Return to bug 34046
Collapse All | Expand All

(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-maintenance/conffiles/etc/cron.d/univention-mrtg (-3 / +2 lines)
 Lines 4-12   PATH=/usr/sbin:/usr/bin:/sbin:/bin Link Here 
4
4
5
# Create mrtg statistics
5
# Create mrtg statistics
6
@!@
6
@!@
7
if baseConfig.has_key('mrtg/cron') and not baseConfig['mrtg/cron'] == '':
7
if configRegistry.get('mrtg/cron'):
8
        print '@%@mrtg/cron@%@ root /usr/sbin/univention-mrtg'
8
        print configRegistry['mrtg/cron'] root /usr/sbin/univention-mrtg'
9
else:
9
else:
10
        print '#* * * * * root /usr/sbin/univention-mrtg'
10
        print '#* * * * * root /usr/sbin/univention-mrtg'
11
@!@
11
@!@
12
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-maintenance/debian/control (-5 / +2 lines)
 Lines 9-24   Build-Depends: debhelper, Link Here 
9
Package: univention-maintenance
9
Package: univention-maintenance
10
Architecture: all
10
Architecture: all
11
Depends: ${misc:Depends},
11
Depends: ${misc:Depends},
12
 bc,
13
 ldap-utils,
14
 httpd,
12
 httpd,
15
 nmap,
16
 mrtg,
13
 mrtg,
17
 netcat,
18
 mail-transport-agent,
19
 cron,
14
 cron,
20
 univention-config-registry,
15
 univention-config-registry,
21
 python-univention-lib (>= 1.0.25-1)
16
 python-univention-lib (>= 1.0.25-1)
17
Suggests: samba,
18
 lm-sensors,
22
Description: UCS - maintenance tools
19
Description: UCS - maintenance tools
23
 This package monitors the server root's homedir and
20
 This package monitors the server root's homedir and
24
 produces HTML statistics about filesystem usage and
21
 produces HTML statistics about filesystem usage and
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-maintenance/debian/copyright (-2 lines)
 Lines 25-29   You should have received a copy of the GNU Affero General Public Link Here 
25
License with the Debian GNU/Linux or Univention distribution in file
25
License with the Debian GNU/Linux or Univention distribution in file
26
/usr/share/common-licenses/AGPL-3; if not, see
26
/usr/share/common-licenses/AGPL-3; if not, see
27
<http://www.gnu.org/licenses/>.
27
<http://www.gnu.org/licenses/>.
28
29
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-maintenance/debian/dirs (-6 lines)
 Lines 1-6    Link Here 
1
etc/univention
2
usr/sbin
3
var/log/univention
4
var/univention-backup/etc
5
var/www/statistik
6
var/www/mrtg
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-maintenance/debian/docs (-1 lines)
Line 1    Link Here 
1
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-maintenance/debian/postinst (-71 lines)
 Lines 1-71    Link Here 
1
#! /bin/sh
2
#
3
# Univention Maintenance
4
#  postinst script
5
#
6
# Copyright 2004-2013 Univention GmbH
7
#
8
# http://www.univention.de/
9
#
10
# All rights reserved.
11
#
12
# The source code of this program is made available
13
# under the terms of the GNU Affero General Public License version 3
14
# (GNU AGPL V3) as published by the Free Software Foundation.
15
#
16
# Binary versions of this program provided by Univention to you as
17
# well as other copyrighted, protected or trademarked materials like
18
# Logos, graphics, fonts, specific documentations and configurations,
19
# cryptographic keys etc. are subject to a license agreement between
20
# you and Univention and not subject to the GNU AGPL V3.
21
#
22
# In the case you use this program under the terms of the GNU AGPL V3,
23
# the program is provided in the hope that it will be useful,
24
# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
# GNU Affero General Public License for more details.
27
#
28
# You should have received a copy of the GNU Affero General Public
29
# License with the Debian GNU/Linux or Univention distribution in file
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
32
33
34
case "$1" in
35
    configure)
36
		if [ ! -e /var/www/statistik/index.htm ]; then
37
			echo "<HTML>"												>>/var/www/statistik/index.htm
38
			echo "<HEAD>"												>>/var/www/statistik/index.htm
39
			echo "</HEAD>"												>>/var/www/statistik/index.htm
40
			echo "<BODY BGCOLOR=\"#F0F0F0\">"							>>/var/www/statistik/index.htm
41
			echo ""														>>/var/www/statistik/index.htm
42
			echo "No data available. </br> </br>"						>>/var/www/statistik/index.htm
43
			echo ""														>>/var/www/statistik/index.htm
44
			echo "Start \"/usr/sbin/univention-maintenance\" manually"	>>/var/www/statistik/index.htm
45
			echo "</BODY>"												>>/var/www/statistik/index.htm
46
			echo "</HTML>"												>>/var/www/statistik/index.htm
47
		fi
48
49
		if [ -z "$2" ]; then
50
			#run script every 15 minutes
51
			univention-config-registry set mrtg/cron?"*/15 * * * *" \
52
								system/stats?yes \
53
								system/stats/cron?'0,30 * * * * '
54
		fi
55
    ;;
56
57
    abort-upgrade|abort-remove|abort-deconfigure)
58
59
    ;;
60
61
    *)
62
        echo "postinst called with unknown argument \`$1'" >&2
63
        exit 1
64
    ;;
65
esac
66
67
#DEBHELPER#
68
69
exit 0
70
71
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-maintenance/debian/univention-maintenance.dirs (+2 lines)
Line 0    Link Here 
1
var/www/statistik
2
var/www/mrtg
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-maintenance/debian/univention-maintenance.postinst (+67 lines)
Line 0    Link Here 
1
#! /bin/sh
2
#
3
# Univention Maintenance
4
#  postinst script
5
#
6
# Copyright 2004-2013 Univention GmbH
7
#
8
# http://www.univention.de/
9
#
10
# All rights reserved.
11
#
12
# The source code of this program is made available
13
# under the terms of the GNU Affero General Public License version 3
14
# (GNU AGPL V3) as published by the Free Software Foundation.
15
#
16
# Binary versions of this program provided by Univention to you as
17
# well as other copyrighted, protected or trademarked materials like
18
# Logos, graphics, fonts, specific documentations and configurations,
19
# cryptographic keys etc. are subject to a license agreement between
20
# you and Univention and not subject to the GNU AGPL V3.
21
#
22
# In the case you use this program under the terms of the GNU AGPL V3,
23
# the program is provided in the hope that it will be useful,
24
# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
# GNU Affero General Public License for more details.
27
#
28
# You should have received a copy of the GNU Affero General Public
29
# License with the Debian GNU/Linux or Univention distribution in file
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
32
33
34
case "$1" in
35
    configure)
36
		if [ ! -e /var/www/statistik/index.htm ]; then
37
			echo '<html>'
38
			echo '<head>'
39
			echo '</head>'
40
			echo '<body bgcolor="#F0F0F0">'
41
			echo 'No data available.<br/><br/>'
42
			echo 'Start "/usr/sbin/univention-maintenance" manually'
43
			echo '</body>'
44
			echo '</html>'
45
		fi >>/var/www/statistik/index.htm
46
47
		if [ -z "$2" ]; then
48
			#run script every 15 minutes
49
			univention-config-registry set mrtg/cron?"*/15 * * * *" \
50
								system/stats?yes \
51
								system/stats/cron?'0,30 * * * * '
52
		fi
53
    ;;
54
55
    abort-upgrade|abort-remove|abort-deconfigure)
56
57
    ;;
58
59
    *)
60
        echo "postinst called with unknown argument \`$1'" >&2
61
        exit 1
62
    ;;
63
esac
64
65
#DEBHELPER#
66
67
exit 0
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-maintenance/univention-maintenance.conf (-2 lines)
 Lines 1-4    Link Here 
1
2
# Configuration for univention-maintenance
1
# Configuration for univention-maintenance
3
2
4
# tempfile for the mrtg config
3
# tempfile for the mrtg config
 Lines 9-12   wwwdir="/var/www/statistik" Link Here 
9
8
10
# Index file
9
# Index file
11
indexhtm="index.htm"
10
indexhtm="index.htm"
12
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-maintenance/univention-mrtg (-120 / +114 lines)
 Lines 34-191    Link Here 
34
# LANG is set to UTF-8.
34
# LANG is set to UTF-8.
35
export LANG=C
35
export LANG=C
36
36
37
38
die () { echo "$*" >&2 ; exit 2 ; }
37
# Name of config file
39
# Name of config file
38
configfile="/etc/univention/univention-maintenance.conf"
40
configfile="/etc/univention/univention-maintenance.conf"
39
41
40
# Search config file and check values
42
# Search config file and check values
41
test -e $configfile || {
43
test -e "$configfile" ||
42
    echo
44
	die "ERROR: Config file \"$configfile\" was not found!"
43
    echo "ERROR: Config file \"$configfile\" was not found!"
44
    echo
45
    exit 2;
46
}
47
45
48
. $configfile
46
. "$configfile"
49
47
50
test -z "$mrtg_config" && touch "$mrtg_config" 2>/dev/null && {
48
test -n "$mrtg_config" &&
51
    echo
49
	touch "$mrtg_config" 2>/dev/null ||
52
    echo "ERROR: \"\$mrtg_config\" is not valid."
50
	die "ERROR: \"\$mrtg_config\" is not valid."
53
    echo
51
test -n "$wwwdir" &&
54
    exit 2;
52
	mkdir -p "$wwwdir" 2>/dev/null ||
55
}
53
	die "ERROR: Missing \"\$wwwdir\" in $configfile"
56
test -z "$wwwdir" && mkdir -p "$wwwdir" 2>/dev/null && {
54
test -n $indexhtm ||
57
    echo
55
	die "ERROR: Missing \"\$indexhtm\" in $configfile"
58
    echo "ERROR: Missing \"\$wwwdir\" in $configfile"
59
    echo
60
    exit 2;
61
}
62
test -z $indexhtm && {
63
    echo
64
    echo "ERROR: Missing \"\$indexhtm\" in $configfile"
65
    echo
66
    exit 2;
67
}
68
56
69
# Delete old mrtg files
57
# Delete old mrtg files
70
rm -f $wwwdir/ucs_*.png $wwwdir/ucs_*.txt
58
rm -f "$wwwdir"/ucs_*.png "$wwwdir"/ucs_*.txt
71
rm -f $wwwdir/uds_*.png $wwwdir/uds_*.txt
59
rm -f "$wwwdir"/uds_*.png "$wwwdir"/uds_*.txt
72
for i in $(ls $wwwdir/uds_*.log 2>/dev/null); do
60
for uds in "$wwwdir"/uds_*.log
73
	new=$(echo $i | sed 's/\/uds/\/ucs/')
61
do
74
	mv $i $new
62
	mv "$uds" "$wwwdir/ucs_${uds#$wwwdir/uds_}"
75
done
63
done
76
64
77
# memory
65
# memory
78
freemem=$(more /proc/meminfo | grep ^MemFree: | awk {'print $2'})
66
freemem=$(awk '/^MemFree:/{print $2}' </proc/meminfo)
79
buffers=$(more /proc/meminfo | grep ^Buffers: | awk {'print $2'})
67
buffers=$(awk '/^Buffers:/{print $2}' </proc/meminfo)
80
cached=$(more /proc/meminfo | grep ^Cached: | awk {'print $2'})
68
cached=$(awk '/^Cached:/{print $2}' </proc/meminfo)
81
memtotal=$(more /proc/meminfo | grep ^MemTotal: | awk {'print $2'})
69
memtotal=$(awk '/^MemTotal:/{print $2}' </proc/meminfo)
82
free=$(($buffers + $cached + $freemem))
70
free=$(($buffers + $cached + $freemem))
83
memused=$(($memtotal - $free))
71
memused=$(($memtotal - $free))
84
prctmem=$((100 * $memused / $memtotal))
72
prctmem=$((100 * $memused / $memtotal))
85
mrtgname="ucs_2mem"
73
mrtgname="ucs_2mem"
86
echo "WorkDir: $wwwdir" > $mrtg_config
74
(
87
echo "Language: german" >> $mrtg_config
75
	echo "WorkDir: $wwwdir"
88
echo "Interval: 15" >> $mrtg_config
76
	echo "Language: german"
89
echo "Target[$mrtgname]: \`echo -e \"$prctmem\n0\nunused\nunused\"\`" >> $mrtg_config
77
	echo "Interval: 15"
90
echo "Options[$mrtgname]: growright,noo,gauge,nobanner,noborder,nolegend,noinfo" >> $mrtg_config
78
	echo "Target[$mrtgname]: \`echo -e \"$prctmem\n0\nunused\nunused\"\`"
91
echo "Unscaled[$mrtgname]: dwmy" >> $mrtg_config
79
	echo "Options[$mrtgname]: growright,noo,gauge,nobanner,noborder,nolegend,noinfo"
92
echo "MaxBytes[$mrtgname]: 100" >> $mrtg_config
80
	echo "Unscaled[$mrtgname]: dwmy"
93
echo "AbsMax[$mrtgname]: 99999" >> $mrtg_config
81
	echo "MaxBytes[$mrtgname]: 100"
94
echo "Title[$mrtgname]: " >> $mrtg_config
82
	echo "AbsMax[$mrtgname]: 99999"
95
echo "Ylegend[$mrtgname]: % " >> $mrtg_config
83
	echo "Title[$mrtgname]: "
96
echo "Colours[$mrtgname]: blau#6666ff,unused#000000,unused#000000,unused#000000" >> $mrtg_config
84
	echo "Ylegend[$mrtgname]: %"
97
echo "Background[$mrtgname]: #ffffff" >> $mrtg_config
85
	echo "Colours[$mrtgname]: blau#6666ff,unused#000000,unused#000000,unused#000000"
98
echo "PageTop[$mrtgname]: <H1>Speicherauslastung</H1>" >> $mrtg_config
86
	echo "Background[$mrtgname]: #ffffff"
87
	echo "PageTop[$mrtgname]: <H1>Speicherauslastung</H1>"
88
) >"$mrtg_config"
99
mrtg "$mrtg_config" 2>/dev/null
89
mrtg "$mrtg_config" 2>/dev/null
100
rm -f $mrtg_config $wwwdir/ucs_*.htm*
90
rm -f "$mrtg_config" "$wwwdir"/ucs_*.htm*
101
echo "Auslastung des Hauptspeichers: $prctmem%" >$wwwdir/$mrtgname.txt
91
echo "Auslastung des Hauptspeichers: $prctmem%" >"$wwwdir/$mrtgname.txt"
102
92
103
# swap
93
# swap
104
swaptotal=$(more /proc/meminfo | grep ^SwapTotal: | awk {'print $2'})
94
swaptotal=$(awk '/^SwapTotal:/{print $2}' </proc/meminfo)
105
swapfree=$(more /proc/meminfo | grep ^SwapFree: | awk {'print $2'})
95
swapfree=$(awk '/^SwapFree:/{print $2}' </proc/meminfo)
106
swapused=$(($swaptotal - $swapfree))
96
swapused=$(($swaptotal - $swapfree))
107
if [ "$swaptotal" = "0" ]; then
97
if [ "$swaptotal" = "0" ]; then
108
	prctswap=0
98
	prctswap=0
109
else
99
else
110
	prctswap=$((100 * $swapused / $swaptotal)) 
100
	prctswap=$((100 * $swapused / $swaptotal))
111
fi
101
fi
112
mrtgname="ucs_3swap"
102
mrtgname="ucs_3swap"
113
echo "WorkDir: $wwwdir" > $mrtg_config
103
(
114
echo "Language: german" >> $mrtg_config
104
	echo "WorkDir: $wwwdir"
115
echo "Interval: 15" >> $mrtg_config
105
	echo "Language: german"
116
echo "Target[$mrtgname]: \`echo -e \"$prctswap\n0\nunused\nunused\"\`" >> $mrtg_config
106
	echo "Interval: 15"
117
echo "Options[$mrtgname]: growright,noo,gauge,nobanner,noborder,nolegend,noinfo" >> $mrtg_config
107
	echo "Target[$mrtgname]: \`echo -e \"$prctswap\n0\nunused\nunused\"\`"
118
echo "Unscaled[$mrtgname]: dwmy" >> $mrtg_config
108
	echo "Options[$mrtgname]: growright,noo,gauge,nobanner,noborder,nolegend,noinfo"
119
echo "MaxBytes[$mrtgname]: 100" >> $mrtg_config
109
	echo "Unscaled[$mrtgname]: dwmy"
120
echo "AbsMax[$mrtgname]: 99999" >> $mrtg_config
110
	echo "MaxBytes[$mrtgname]: 100"
121
echo "Title[$mrtgname]: " >> $mrtg_config
111
	echo "AbsMax[$mrtgname]: 99999"
122
echo "Ylegend[$mrtgname]: %" >> $mrtg_config
112
	echo "Title[$mrtgname]: "
123
echo "Colours[$mrtgname]: blau#6666ff,unused#000000,unused#000000,unused#000000" >> $mrtg_config
113
	echo "Ylegend[$mrtgname]: %"
124
echo "Background[$mrtgname]: #ffffff" >> $mrtg_config
114
	echo "Colours[$mrtgname]: blau#6666ff,unused#000000,unused#000000,unused#000000"
125
echo "PageTop[$mrtgname]: <H1>Swapauslastung</H1>" >> $mrtg_config
115
	echo "Background[$mrtgname]: #ffffff"
116
	echo "PageTop[$mrtgname]: <H1>Swapauslastung</H1>"
117
) >"$mrtg_config"
126
mrtg "$mrtg_config" 2>/dev/null
118
mrtg "$mrtg_config" 2>/dev/null
127
rm -f $mrtg_config $wwwdir/ucs_*.htm*
119
rm -f "$mrtg_config" "$wwwdir"/ucs_*.htm*
128
echo "Auslastung des Auslagerungsspeicher: $prctswap%" >$wwwdir/$mrtgname.txt
120
echo "Auslastung des Auslagerungsspeicher: $prctswap%" >"$wwwdir/$mrtgname.txt"
129
121
130
# CPU usage of last 15 minutes
122
# CPU usage of last 15 minutes
131
loadavg="`echo \`cat /proc/loadavg |awk '{print $3}'\`*100 | bc | cut -f1 -d"."`"
123
loadavg=$(awk '{print int($3*100)}' </proc/loadavg)
132
mrtgname="ucs_0load"
124
mrtgname="ucs_0load"
133
echo "WorkDir: $wwwdir" > $mrtg_config
125
(
134
echo "Language: german" >> $mrtg_config
126
	echo "WorkDir: $wwwdir"
135
echo "Interval: 15" >> $mrtg_config
127
	echo "Language: german"
136
echo "Target[$mrtgname]: \`echo -e \"$loadavg\n0\nunused\nunused\"\`" >> $mrtg_config
128
	echo "Interval: 15"
137
echo "Options[$mrtgname]: growright,noo,gauge,nobanner,noborder,nolegend,noinfo" >> $mrtg_config
129
	echo "Target[$mrtgname]: \`echo -e \"$loadavg\n0\nunused\nunused\"\`"
138
echo "Unscaled[$mrtgname]: dwmy" >> $mrtg_config
130
	echo "Options[$mrtgname]: growright,noo,gauge,nobanner,noborder,nolegend,noinfo"
139
echo "MaxBytes[$mrtgname]: 100" >> $mrtg_config
131
	echo "Unscaled[$mrtgname]: dwmy"
140
echo "AbsMax[$mrtgname]: 99999" >> $mrtg_config
132
	echo "MaxBytes[$mrtgname]: 100"
141
echo "Title[$mrtgname]: " >> $mrtg_config
133
	echo "AbsMax[$mrtgname]: 99999"
142
echo "Ylegend[$mrtgname]: %" >> $mrtg_config
134
	echo "Title[$mrtgname]: "
143
echo "Colours[$mrtgname]: blau#6666ff,unused#000000,unused#000000,unused#000000" >> $mrtg_config
135
	echo "Ylegend[$mrtgname]: %"
144
echo "Background[$mrtgname]: #ffffff" >> $mrtg_config
136
	echo "Colours[$mrtgname]: blau#6666ff,unused#000000,unused#000000,unused#000000"
145
echo "PageTop[$mrtgname]: <H1>Systemlast</H1>" >> $mrtg_config
137
	echo "Background[$mrtgname]: #ffffff"
138
	echo "PageTop[$mrtgname]: <H1>Systemlast</H1>"
139
) >"$mrtg_config"
146
mrtg "$mrtg_config" 2>/dev/null
140
mrtg "$mrtg_config" 2>/dev/null
147
rm -f $mrtg_config $wwwdir/ucs_*.htm*
141
rm -f "$mrtg_config" "$wwwdir"/ucs_*.htm*
148
echo "Systemlast: $loadavg%" >$wwwdir/$mrtgname.txt
142
echo "Systemlast: $loadavg%" >"$wwwdir/$mrtgname.txt"
149
143
150
# Session count
144
# Session count
151
nrsessions="`ps -C univention-sess | grep -ic univention-sess`"
145
nrsessions=$(pgrep -c univention-sess)
152
mrtgname="ucs_1sessions"
146
mrtgname="ucs_1sessions"
153
echo "WorkDir: $wwwdir" > $mrtg_config
147
(
154
echo "Language: german" >> $mrtg_config
148
	echo "WorkDir: $wwwdir"
155
echo "Interval: 15" >> $mrtg_config
149
	echo "Language: german"
156
echo "Target[$mrtgname]: \`echo -e \"$nrsessions\n0\nunused\nunused\"\`" >> $mrtg_config
150
	echo "Interval: 15"
157
echo "Options[$mrtgname]: growright,noo,gauge,nobanner,noborder,nolegend,noinfo" >> $mrtg_config
151
	echo "Target[$mrtgname]: \`echo -e \"$nrsessions\n0\nunused\nunused\"\`"
158
echo "Unscaled[$mrtgname]: dwmy" >> $mrtg_config
152
	echo "Options[$mrtgname]: growright,noo,gauge,nobanner,noborder,nolegend,noinfo"
159
echo "MaxBytes[$mrtgname]: 10" >> $mrtg_config
153
	echo "Unscaled[$mrtgname]: dwmy"
160
echo "AbsMax[$mrtgname]: 99999" >> $mrtg_config
154
	echo "MaxBytes[$mrtgname]: 10"
161
echo "Title[$mrtgname]: " >> $mrtg_config
155
	echo "AbsMax[$mrtgname]: 99999"
162
echo "Ylegend[$mrtgname]: Total" >> $mrtg_config
156
	echo "Title[$mrtgname]: "
163
echo "Colours[$mrtgname]: blau#6666ff,unused#000000,unused#000000,unused#000000" >> $mrtg_config
157
	echo "Ylegend[$mrtgname]: Total"
164
echo "Background[$mrtgname]: #ffffff" >> $mrtg_config
158
	echo "Colours[$mrtgname]: blau#6666ff,unused#000000,unused#000000,unused#000000"
165
echo "PageTop[$mrtgname]: <H1>Sessions</H1>" >> $mrtg_config
159
	echo "Background[$mrtgname]: #ffffff"
160
	echo "PageTop[$mrtgname]: <H1>Sessions</H1>"
161
) >"$mrtg_config"
166
mrtg "$mrtg_config" 2>/dev/null
162
mrtg "$mrtg_config" 2>/dev/null
167
rm -f $mrtg_config $wwwdir/ucs_*.htm*
163
rm -f "$mrtg_config" "$wwwdir"/ucs_*.htm*
168
echo "Session(s): $nrsessions" >$wwwdir/$mrtgname.txt
164
echo "Session(s): $nrsessions" >"$wwwdir/$mrtgname.txt"
169
165
170
# Write HTML file
166
# Write HTML file
171
cat <<__EOT__ >$wwwdir/$indexhtm
167
(
172
<HTML>
168
	echo '<html>'
173
<HEAD>
169
	echo '<head>'
174
</HEAD>
170
	echo '</head>'
175
<BODY BGCOLOR="#F0F0F0">
171
	echo '<body bgcolor="#f0f0f0">'
176
__EOT__
172
	for file in "$wwwdir"/*-day.png
177
for file in $wwwdir/*-day.png; do
173
	do
178
    echo "<P ALIGN=\"center\"><FONT FACE=\"ARIAL\">" >>$wwwdir/$indexhtm
174
		echo '<p align="center"><font face="arial">'
179
    cat "`echo \"$file\" | sed \"s/-day.png/.txt/\"`" >>$wwwdir/$indexhtm
175
		cat "${file%-day.png}.txt"
180
    echo "<BR>" >>$wwwdir/$indexhtm
176
		echo '<br/>'
181
    echo "<IMG SRC=\"`basename $file`\"><BR>" >>$wwwdir/$indexhtm
177
		echo "<img src=\"$(basename "$file")\"/><br/>"
182
    echo "<IMG SRC=\"`basename $file -day.png`-week.png\"><BR>" >>$wwwdir/$indexhtm
178
		echo "<img src=\"$(basename "$file" -day.png)-week.png\"/><br/>"
183
    echo "<IMG SRC=\"`basename $file -day.png`-month.png\"><BR>" >>$wwwdir/$indexhtm
179
		echo "<img src=\"$(basename "$file" -day.png)-month.png\"/><br/>"
184
    echo "<IMG SRC=\"`basename $file -day.png`-year.png\"><BR>" >>$wwwdir/$indexhtm
180
		echo "<img src=\"$(basename "$file" -day.png)-year.png\"/><br/>"
185
    echo "</FONT></P>" >>$wwwdir/$indexhtm
181
		echo '</font></p>'
186
done
182
	done
187
cat <<__EOT__ >>$wwwdir/$indexhtm
183
	echo '</body>'
188
</BODY>
184
	echo '</html>'
189
</HTML>
185
) >"$wwwdir/$indexhtm"
190
__EOT__
191
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-maintenance/univention-system-stats (-21 / +23 lines)
 Lines 32-48    Link Here 
32
date=$(date)
32
date=$(date)
33
log="/var/log/univention/system-stats.log"
33
log="/var/log/univention/system-stats.log"
34
34
35
cmds[0]="$(which df) -lhT"
35
cmds=(
36
cmds[1]="$(which ps) auxf"
36
	"df -lhT"
37
cmds[2]="$(which top) -b -n2"
37
	"ps auxf"
38
cmds[3]="$(which free)"
38
	"top -b -n2"
39
cmds[4]="$(which uptime)"
39
	"free"
40
cmds[5]="$(which sensors)"
40
	"uptime"
41
cmds[6]="$(which smbstatus)"
41
	"sensors"
42
	"smbstatus"
43
)
42
44
43
# print usage
45
# print usage
44
function usage () {
46
usage () {
45
	echo usage: $(basename $0) [-h]
47
	echo usage: $(basename "$0") [-h]
46
	echo "This script logs some systems stats (df, free, ...) in \"$log\"."
48
	echo "This script logs some systems stats (df, free, ...) in \"$log\"."
47
49
48
	exit 0
50
	exit 0
 Lines 59-81   done Link Here 
59
if [ ! -e "$log" ]; then
61
if [ ! -e "$log" ]; then
60
	: > "$log"
62
	: > "$log"
61
fi
63
fi
62
chmod 640 $log
64
chmod 640 "$log"
63
chgrp adm $log
65
chgrp adm "$log"
64
66
65
# redirect output
67
# redirect output
66
exec 1>>"$log"
68
exec >>"$log" 2>/dev/null
67
exec 2>/dev/null
68
69
69
echo "--- system stats for $date"
70
echo "--- system stats for $date"
70
echo 
71
echo
71
72
72
for cmd in "${cmds[@]}"; do
73
for cmd in "${cmds[@]}"
73
	tool=${cmd/ */}
74
do
74
	if [ -x "$tool" ]; then
75
	set -- $cmd  # IFS
75
		echo "-> $cmd"
76
	tool=$(which "$1") || continue
76
		$cmd 
77
	[ -x "$tool" ] || continue
77
		echo 
78
	echo "-> $cmd"
78
	fi
79
	$cmd  # IFS
80
	echo
79
done
81
done
80
82
81
echo "--- end system stats for $date"
83
echo "--- end system stats for $date"

Return to bug 34046