Browse Source

add file to gather further system information the gnuish way...for now get the number of cpus

master
Georg Hopp 12 years ago
parent
commit
afaba61205
  1. 64
      cf-engine-classes.txt
  2. 22
      classes.sh
  3. 16
      gnu_information.sh
  4. 8
      run.sh
  5. 5
      system_information.sh
  6. 3
      test.sh
  7. 18
      utils.sh

64
cf-engine-classes.txt

@ -0,0 +1,64 @@
127_0_0_1
192_168_120_40
2001_4ba0_ffff_138_1__400
64_bit
8_cpus
?Day15
?Evening
?GMT_Hr17
?Hr18
?Hr18_Q2
?Lcycle_1
?March
?Min15_20
?Min17
PK_MD5_1cc0a2b13599f57ebb17df5abdc45ae1
?Q2
?Saturday
?Yr2014
agent
any
cfengine
cfengine_3
cfengine_3_5
cfengine_3_5_3
community_edition
compiled_on_linux_gnu
cpu0_high
cpu1_high
cpu2_high
cpu3_high
cpu_high
diskfree_high_normal
entropy_misc_in_low
entropy_misc_out_low
entropy_postgresql_in_low
entropy_postgresql_out_low
fe80__14d8_4dff_fed7_9c59
gentoo
inform_mode
ipv4_127
ipv4_127_0
ipv4_127_0_0
ipv4_127_0_0_1
ipv4_192
ipv4_192_168
ipv4_192_168_120
ipv4_192_168_120_40
ldap_out_high
linux
linux_3_12_8_hardened_r1
linux_x86_64
linux_x86_64_3_12_8_hardened_r1
linux_x86_64_3_12_8_hardened_r1__4_SMP_Tue_Mar_4_17_38_20_CET_2014
loadavg_low
localhost
mac_16_d8_4d_d7_9c_59
net_iface_eth0
net_iface_lo
rootprocs_high
ssh_in_high
test
users_high
verbose_mode
x86_64

22
classes.sh

@ -0,0 +1,22 @@
#!/bin/dash
##
# This creates function that will gather some system informations
# and propagate them as environment variables.
#
. ./utils.sh
include_once system_information.sh
include_once interface_information.sh
has_class() {
if [ 1 -ne $# ]
then
logger -p syslog.err 'has_class: no class given'
exit 1
fi
test "${CLASSES}" != "${CLASSES%${1}*}"
}
# vim: set ts=4 sw=4:

16
gnu_information.sh

@ -0,0 +1,16 @@
#!/bin/dash
##
# This creates function that will gather some system informations
# and propagate them as environment variables.
#
. ./utils.sh
include_once system_information.sh
echo "foo ${NPROC}"
CPUS=$(${NPROC})
export CLASSES="${CLASSES}${CPUS}cpus "
# vim: set ts=4 sw=4:

8
run.sh

@ -10,9 +10,9 @@
#
. ./utils.sh
include_once ./system_information.sh
include_once ../sysman/interface_information.sh
include_once /home/ghopp/sysman/network_tools.sh
include_once system_information.sh
include_once interface_information.sh
include_once network_tools.sh
##
# report everysthing
@ -24,6 +24,7 @@ ${PRINTF} "%15s : %s\n" "VERSION" "${VERSION}"
${PRINTF} "%15s : %s\n" "PLATFORM" "${PLATFORM}"
${PRINTF} "%15s : %s\n" "DIST" "${DIST}"
${PRINTF} "%15s : %s\n" "HOSTNAME" "${HOSTNAME}"
${PRINTF} "%15s : %s\n" "CPUS" "${CPUS}"
${PRINTF} "%15s : %s\n" "# INTERFACES" "${NINTERFACES}"
NO=1
@ -44,3 +45,4 @@ echo $(mask2cidr 255.255.128.0)
echo $(cidr2mask 17)
eval echo \$\(cidr2mask $(mask2cidr 255.255.128.0)\)
# vim: set ts=4 sw=4:

5
system_information.sh

@ -125,4 +125,9 @@ get_dist_info() {
[ -z "${DIST}" ] && get_dist_info
case "${OS}" in
GNU/*)
include_once gnu_information.sh;;
esac
# vim: set ts=4 sw=4:

3
test.sh

@ -0,0 +1,3 @@
#!/bin/sh
logger -i -p syslog.err $0: blubber

18
utils.sh

@ -12,7 +12,7 @@ then
if [ 1 -ne $# ]
then
logger -p syslog.err 'filename2sybol: missing filename'
${LOGGER} -p syslog.err 'filename2sybol: missing filename'
exit 1
fi
@ -29,11 +29,16 @@ then
echo "${SYM}"
}
canonify_name() {
##
# create an absolute filename from a given relative one.
# This deals only with leading ./ and ../ it does not
# handle then when they are in the middle of the name.
#
abs_filename() {
local FILE="${1}"
local DIR="${PWD}"
# if FILE starts with a / its already canonified
# if FILE starts with a / its already absolute
if [ "${FILE}" != ${FILE#/} ]
then
echo "${FILE}"
@ -56,19 +61,19 @@ then
}
include_once() {
local FILE="$(canonify_name "${1}")"
local FILE="$(abs_filename "${1}")"
local SYM="$(filename2symbol "${FILE}")"
if [ 1 -ne $# ]
then
logger -p syslog.err 'include_once: missing filename'
${LOGGER} -p syslog.err 'include_once: missing filename'
exit 1
fi
if eval [ -z \"\${SOURCED_${SYM}}\" ]
then
. ${FILE}
eval export SOURCED_${SYM}=\"\${FILE}\"
. ${FILE}
fi
}
@ -88,6 +93,7 @@ then
[ -z "${TR}" ] && TR="$(${WHICH} tr)"
[ -z "${PRINTF}" ] && PRINTF="$(${WHICH} printf)"
[ -z "${LOGGER}" ] && LOGGER="$(${WHICH} logger)"
[ -z "${NPROC}" ] && NPROC="$(${WHICH} nproc)"
[ -z "${IP}" ] && IP="$(${WHICH} ip)"
[ -z "${IFCONFIG}" ] && IFCONFIG="$(${WHICH} ifconfig)"

Loading…
Cancel
Save