Puppet supports regular expressions.
E.g.
Run puppet manifest on all the web servers:
node /^web.*$/ {
class { 'server_web': }
}
Run on a few (db0-9)
node /^db[0-9]\..*$/ {
class { 'server_db': }
}
Thursday, May 29, 2014
Wednesday, May 14, 2014
bash script sum
Bash script exercise.
Add variable to the result of the sum. E.g.
1 1 2 3 5 8 13 21, etc.
#!/bin/bash
x=1
y=1
ans=0
while [ $ans -lt 100 ]
#while true
do
ans=$(( x + y ))
echo $x + $y = $ans
x=$y
y=$ans
done
Add variable to the result of the sum. E.g.
1 1 2 3 5 8 13 21, etc.
#!/bin/bash
x=1
y=1
ans=0
while [ $ans -lt 100 ]
#while true
do
ans=$(( x + y ))
echo $x + $y = $ans
x=$y
y=$ans
done
Monday, May 12, 2014
Friday, May 02, 2014
Number of hits from server in bash
Let's say I have a list of servers and I want to calculate how many hits did I have from "client.com" on April 28, 2014
#!/bin/bash
total=0
for server in $(cat server_list)
do
echo $server
echo "Current count = "$total
servercount=$(ssh $server "zcat /var/log/httpd/access.2014-04-28.log.gz |grep client.com |wc -l")
echo "Server count ="$servercount
total=$(($total + $servercount))
done
echo "Total count = "$total
#!/bin/bash
total=0
for server in $(cat server_list)
do
echo $server
echo "Current count = "$total
servercount=$(ssh $server "zcat /var/log/httpd/access.2014-04-28.log.gz |grep client.com |wc -l")
echo "Server count ="$servercount
total=$(($total + $servercount))
done
echo "Total count = "$total
Subscribe to:
Posts (Atom)