* Make a script to monitore the user informations and put it in "update-motd.d".

This commit is contained in:
gardouille 2015-02-02 14:17:15 +01:00
parent ebc949870c
commit 0178cae669
5 changed files with 50 additions and 1 deletions

View File

@ -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".
---------------------------------------

View File

@ -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

View File

@ -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 {

View File

@ -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'

37
templates/motd_user_info.erb Executable file
View File

@ -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"