Compare commits
10 Commits
871289dd04
...
33623eff59
Author | SHA1 | Date | |
---|---|---|---|
|
33623eff59 | ||
9563be75d1 | |||
77e70aaad5 | |||
32809974da | |||
4e69de76eb | |||
b64b741b28 | |||
7ff648da5e | |||
3106172e85 | |||
|
caebe44628 | ||
3b500d7d31 |
@ -108,14 +108,15 @@ SOMME()
|
|||||||
get_random
|
get_random
|
||||||
RAND_INDEX=$(($R % ${#TRANSFORMATIONS[@]}))
|
RAND_INDEX=$(($R % ${#TRANSFORMATIONS[@]}))
|
||||||
|
|
||||||
INSTRUCTIONS=$(echo "$(${TRANSFORMATIONS[$RAND_INDEX]})" | cut -d "|" -f 1)
|
INSTRUCTIONS0=$(echo "$(${TRANSFORMATIONS[$RAND_INDEX]})")
|
||||||
INSTRUCTIONS2=$(echo "$(${TRANSFORMATIONS[$RAND_INDEX]})" | cut -d "|" -f 3)
|
INSTRUCTIONS1=$(echo $INSTRUCTIONS0 | cut -d "|" -f 1)
|
||||||
TEXT=$(echo "$(${TRANSFORMATIONS[$RAND_INDEX]})" | cut -d "|" -f 2)
|
INSTRUCTIONS2=$(echo $INSTRUCTIONS0 | cut -d "|" -f 3)
|
||||||
|
TEXT=$(echo $INSTRUCTIONS0 | cut -d "|" -f 2)
|
||||||
|
|
||||||
convert -size 300x70 xc:none -pointsize 20 \
|
convert -size 300x70 xc:none -pointsize 20 \
|
||||||
\( -clone 0 -fill black \
|
\( -clone 0 -fill black \
|
||||||
-stroke black -strokewidth 1 \
|
-stroke black -strokewidth 1 \
|
||||||
-font Helvetica-Narrow -annotate "0x0+0+0" "\n $INSTRUCTIONS" \
|
-font Helvetica-Narrow -annotate "0x0+0+0" "\n $INSTRUCTIONS1" \
|
||||||
-font Helvetica-Bold -annotate "0x0+0+22" "\n $TEXT" \
|
-font Helvetica-Bold -annotate "0x0+0+22" "\n $TEXT" \
|
||||||
-font Helvetica-Narrow -annotate "0x0+0+44" "\n $INSTRUCTIONS2" \
|
-font Helvetica-Narrow -annotate "0x0+0+44" "\n $INSTRUCTIONS2" \
|
||||||
-roll +$ROLL_X+0 \
|
-roll +$ROLL_X+0 \
|
||||||
@ -126,7 +127,7 @@ convert -size 300x70 xc:none -pointsize 20 \
|
|||||||
convert -size 300x70 xc:none -pointsize 20 \
|
convert -size 300x70 xc:none -pointsize 20 \
|
||||||
\( -clone 0 -fill black \
|
\( -clone 0 -fill black \
|
||||||
-stroke black -strokewidth 1 \
|
-stroke black -strokewidth 1 \
|
||||||
-font Helvetica-Narrow -annotate "0x0+0+0" "\n $INSTRUCTIONS" \
|
-font Helvetica-Narrow -annotate "0x0+0+0" "\n $INSTRUCTIONS1" \
|
||||||
-font Helvetica-Bold -annotate "0x0+0+22" "\n $TEXT" \
|
-font Helvetica-Bold -annotate "0x0+0+22" "\n $TEXT" \
|
||||||
-font Helvetica-Narrow -annotate "0x0+0+44" "\n $INSTRUCTIONS2" \
|
-font Helvetica-Narrow -annotate "0x0+0+44" "\n $INSTRUCTIONS2" \
|
||||||
-roll +$ROLL_X+0 \
|
-roll +$ROLL_X+0 \
|
||||||
|
69
metrology/collectd_exec_xmpp.sh
Executable file
69
metrology/collectd_exec_xmpp.sh
Executable file
@ -0,0 +1,69 @@
|
|||||||
|
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}"
|
||||||
|
INTERVAL="${COLLECTD_INTERVAL:-60}"
|
||||||
|
|
||||||
|
# required by some ejabberdctl commands
|
||||||
|
export HOME=/var/lib/ejabberd
|
||||||
|
export HTTP_UPLOAD_DATADIR="/var/www/xmpp.chapril.org/upload/"
|
||||||
|
|
||||||
|
|
||||||
|
main() {
|
||||||
|
# do-while hack found here: https://stackoverflow.com/questions/24420342/is-there-a-do-while-loop-in-bash#24421013
|
||||||
|
while
|
||||||
|
ejabberdctl_stats
|
||||||
|
http_upload_disk_usage
|
||||||
|
captcha_stats
|
||||||
|
#client_stats # XXX pas encore activée
|
||||||
|
sleep "$INTERVAL"
|
||||||
|
do true; done
|
||||||
|
}
|
||||||
|
|
||||||
|
ejabberdctl_stats() {
|
||||||
|
echo "PUTVAL \"${HOSTNAME}/xmpp_registered_users/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl registered_users chapril.org | wc -l)"
|
||||||
|
echo "PUTVAL \"${HOSTNAME}/xmpp_active_users/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl connected_users_number)"
|
||||||
|
echo "PUTVAL \"${HOSTNAME}/xmpp_active_distinct_users/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl connected_users | cut -d@ -f1 | sort -u | wc -l)"
|
||||||
|
echo "PUTVAL \"${HOSTNAME}/xmpp_s2s_in/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl incoming_s2s_number)"
|
||||||
|
echo "PUTVAL \"${HOSTNAME}/xmpp_s2s_out/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl outgoing_s2s_number)"
|
||||||
|
echo "PUTVAL \"${HOSTNAME}/xmpp_muc_total/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl muc_online_rooms muc.chapril.org | wc -l)"
|
||||||
|
|
||||||
|
echo "PUTVAL \"${HOSTNAME}/xmpp_accounts_created_lastday/count\" interval=$INTERVAL $(date +%s):$(count_accounts_created_lastday)"
|
||||||
|
}
|
||||||
|
|
||||||
|
http_upload_disk_usage() {
|
||||||
|
subfolders_count=$(find ${HTTP_UPLOAD_DATADIR} -mindepth 1 -maxdepth 1 -type d | wc -l)
|
||||||
|
total_size=$(du -s ${HTTP_UPLOAD_DATADIR} | awk '{print $1}')
|
||||||
|
avg=$(( ${total_size} / ${subfolders_count} ))
|
||||||
|
echo "PUTVAL \"${HOSTNAME}/xmpp_upload_data_total/count\" interval=$INTERVAL $(date +%s):${total_size}"
|
||||||
|
echo "PUTVAL \"${HOSTNAME}/xmpp_upload_data_avg/count\" interval=$INTERVAL $(date +%s):${avg}"
|
||||||
|
}
|
||||||
|
|
||||||
|
captcha_stats() {
|
||||||
|
echo "PUTVAL \"${HOSTNAME}/xmpp_captcha_lastday/count\" interval=$INTERVAL $(date +%s):$(find /var/lib/ejabberd/chapril_captchas/ -mindepth 1 -maxdepth 1 -type f -mtime -1 | grep -v EXPERIMENTAL | wc -l)"
|
||||||
|
}
|
||||||
|
|
||||||
|
count_accounts_created_lastday() {
|
||||||
|
_sql_ejabberd "
|
||||||
|
select count(*)
|
||||||
|
from users
|
||||||
|
where created_at > current_timestamp - interval '1 day'
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
_sql_ejabberd() {
|
||||||
|
# XXX the psql command can only works if file /var/lib/ejabberd/.pgpass exists
|
||||||
|
psql -U ejabberd -h localhost ejabberd -c "${1}" -t | grep -v '^$' | awk '{print $1}'
|
||||||
|
}
|
||||||
|
|
||||||
|
# XXX la syntaxe de la boucle while ci-dessous fait échouer le démarrage de collectd.
|
||||||
|
# exec plugin: exec_read_one: error = /srv/xmpp.chapril.org/tools/metrology/collectd_exec_xmpp.sh: 44: /srv/xmpp.chapril.org/tools/metrology/collectd_exec_xmpp.sh: Syntax error: redirection unexpected
|
||||||
|
#client_stats(){
|
||||||
|
# return 0
|
||||||
|
# # Fonction pas encore activée car je n'aime pas l'idée de créer dans influxdb autant de noms de métriques que de clients XMPP.
|
||||||
|
# # Il faut encore étudier le format d'envoi de collectd.
|
||||||
|
# while read -r line ; do
|
||||||
|
# clientname=$(echo ${line} | awk '{print $2}')
|
||||||
|
# count=$(echo ${line} | awk '{print $1}')
|
||||||
|
# echo "PUTVAL \"${HOSTNAME}/xmpp_client_${clientname}/count\" interval=$INTERVAL $(date +%s):${count}"
|
||||||
|
# done < <(ejabberdctl connected_users | sed -r 's;^.*@chapril.org/([^. -]+).*;\1;' | sort | uniq -c | sort -n)
|
||||||
|
#}
|
||||||
|
|
||||||
|
main
|
@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
LIST=$(sudo -u ejabberd ejabberdctl connected_users_info | cut -f 1 | cut -d "/" -f 1 | grep $1 | uniq)
|
|
||||||
|
|
||||||
for ADDRESS in $LIST
|
|
||||||
do
|
|
||||||
sudo -u ejabberd ejabberdctl send_message headline chapril.org "$ADDRESS" "Annonce du Serveur" "$2"
|
|
||||||
echo Done with $ADDRESS
|
|
||||||
done
|
|
Loading…
Reference in New Issue
Block a user