* Make a script to monitore the user informations and put it in "update-motd.d".
This commit is contained in:
parent
ebc949870c
commit
0178cae669
|
@ -10,6 +10,7 @@
|
|||
* Create the "update-motd.d" to use the dynamic MOTD generation.
|
||||
* Make a script to monitore the services and put it in "update-motd.d".
|
||||
* Make a script to monitore the system informations and put it in "update-motd.d".
|
||||
* Make a script to monitore the user informations and put it in "update-motd.d".
|
||||
|
||||
---------------------------------------
|
||||
|
||||
|
|
|
@ -19,6 +19,13 @@ class dynmotd::config {
|
|||
mode => 0755,
|
||||
content => template("${dynmotd::system_info_script_content}"),
|
||||
}
|
||||
|
||||
file { "${dynmotd::update_motd_dir_path}/${dynmotd::user_info_script_name}":
|
||||
ensure => present,
|
||||
mode => 0755,
|
||||
content => template("${dynmotd::user_info_script_content}"),
|
||||
}
|
||||
|
||||
file { "${dynmotd::update_motd_dir_path}/${dynmotd::service_info_script_name}":
|
||||
ensure => present,
|
||||
mode => 0755,
|
||||
|
@ -26,6 +33,6 @@ class dynmotd::config {
|
|||
}
|
||||
|
||||
|
||||
File["${dynmotd::update_motd_dir_path}"] -> File["${dynmotd::update_motd_dir_path}/${dynmotd::system_info_script_name}"] -> File["${dynmotd::update_motd_dir_path}/${dynmotd::service_info_script_name}"]
|
||||
File["${dynmotd::update_motd_dir_path}"] -> File["${dynmotd::update_motd_dir_path}/${dynmotd::system_info_script_name}"] -> File["${dynmotd::update_motd_dir_path}/${dynmotd::user_info_script_name}"] -> File["${dynmotd::update_motd_dir_path}/${dynmotd::service_info_script_name}"]
|
||||
|
||||
} # Private class: dynmotd::config
|
||||
|
|
|
@ -39,6 +39,8 @@ class dynmotd (
|
|||
$update_motd_dir_path = $dynmotd::params::update_motd_dir_path,
|
||||
$system_info_script_name = $dynmotd::params::system_info_script_name,
|
||||
$system_info_script_content = $dynmotd::params::system_info_script_content,
|
||||
$user_info_script_name = $dynmotd::params::user_info_script_name,
|
||||
$user_info_script_content = $dynmotd::params::user_info_script_content,
|
||||
$service_info_script_name = $dynmotd::params::service_info_script_name,
|
||||
$service_info_script_content = $dynmotd::params::service_info_script_content,
|
||||
) inherits dynmotd::params {
|
||||
|
|
|
@ -10,6 +10,8 @@ class dynmotd::params {
|
|||
# DynMotd scripts
|
||||
$system_info_script_name = '01system_info'
|
||||
$system_info_script_content = 'dynmotd/motd_system_info.erb'
|
||||
$user_info_script_name = '02user_info'
|
||||
$user_info_script_content = 'dynmotd/motd_user_info.erb'
|
||||
$service_info_script_name = '06service_info'
|
||||
$service_info_script_content = 'dynmotd/motd_service_info.erb'
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#! /usr/bin/env sh
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
#### Colors definition
|
||||
BLACK='\033[30;40m'
|
||||
RED='\033[0;31m'
|
||||
REDB='\033[1;31m'
|
||||
GREEN='\033[1;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[34;40m'
|
||||
MAGENTA='\033[0;35m'
|
||||
CYAN='\033[36;40m'
|
||||
WHITE='\033[0;37m'
|
||||
WHITEB='\033[1;37m'
|
||||
RESET='\033[0m'
|
||||
|
||||
#++++++++++++++++++++: User Data :++++++++++++++++++++++
|
||||
USERNAME=$(whoami)
|
||||
USER_SESSION=$(who | grep $USER | wc -l)
|
||||
PROC_COUNT=$(ps -Afl | wc -l)
|
||||
PROC_COUNT=$(expr $PROC_COUNT - 5)
|
||||
# The "ulimit" from sh don't support the -u option
|
||||
PROC_LIMIT=$(ulimit)
|
||||
|
||||
|
||||
printf '%b' "\n${RESET}${MAGENTA}++++++++++++++++++++: ${WHITE}User Data${MAGENTA} :++++++++++++++++++++++${RESET}
|
||||
${MAGENTA}+ ${WHITE}Username\t${MAGENTA}= ${GREEN}${USERNAME}
|
||||
${MAGENTA}+ ${WHITE}Sessions\t${MAGENTA}= ${GREEN}${USER_SESSION}
|
||||
${MAGENTA}+ ${WHITE}Processes\t${MAGENTA}= ${GREEN}$PROC_COUNT of ${PROC_LIMIT} MAX${RESET}"
|
||||
|
||||
printf '%b' "\n"
|
||||
|
Loading…
Reference in New Issue