Answer the question
In order to leave comments, you need to log in
What's wrong with the Ubnutu system information gathering script?
There is a script for collecting information about the system taken from the network.
#!/bin/bash
telescripts_path=/root/
info_web="Web-servers
-------------
$(service apache2 status)
$(service nginx status)
"
info_mysql="MySQL
-------------
$(mysqladmin ping)
$(mysqladmin status)
"
info_cpu="CPU
-------------
top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1" of 100 percents"}'
"
info_ram="RAM
-------------
free: $(free -m | grep Mem | awk '{print $4}') MB of $(free -m | grep Mem | awk '{print $2}') MB total
"
info_space="HDD
-------------
$(df -h --output=source,size,used,avail | head -n2)
"
text=$(printf "$info_web$info_mysql$info_cpu$info_ram$info_space")
printf '%s\n' "$text" > ${telescripts_path}/status.txt
line 21: syntax error near unexpected token `('
MySQL
-------------
RAM
-------------
free: MB of MB total
Answer the question
In order to leave comments, you need to log in
$( top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1" of 100 percents"}' )
if hash mysql 2>/dev/null; then
echo mysql exists
fi
cat << EOF > /path/to/file
$info_web
$info_mysql
$info_cpu
$info_ram
$info_space
EOF
but on startup, an error occurs in the processor data collection line:
[[email protected] ~]$ s="abc"def(g)"hij"
bash: syntax error near unexpected token `('
[[email protected] ~]$
[[email protected] ~]$ s="abc'def(g)'hij"
[[email protected] ~]$
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question