23
2
Fork 0

Compare commits

..

No commits in common. "d34912a42c4bb8ad318dad1ab8d3a774a95fc837" and "faa314a926566f0f4af7e9f9d63130c18e547676" have entirely different histories.

3 changed files with 1 additions and 85 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
# XMPP tools

View File

@ -1,43 +0,0 @@
#! /bin/bash
main() {
echo "h2. ## Global info"
echo ""
echo "* Total accounts: $(sudo -u ejabberd ejabberdctl registered_users chapril.org | egrep -v -e 'r\.giskard' -e '(lisa|bart)\.simpson' | wc -l)"
echo "* Total messages stored (MAM): $(count_archived_messages) "
# echo "Active users: $(sudo -u ejabberd ejabberdctl connected_users_number)"
echo ""
echo "h2. ## HTTP upload storage:"
echo ""
echo "* User quota: $(get_hard_quota)M"
echo "* Total disk usage: $(du -sh /srv/ejabberd/chapril.org/upload/ | awk '{print $1}')"
per_account_storage_usage
# echo "s2s outgoing connections: $(sudo -u ejabberd ejabberdctl incoming_s2s_number)"
# echo "s2s incoming connections: $(sudo -u ejabberd ejabberdctl outgoing_s2s_number)"
}
get_hard_quota() {
grep hard_quota /etc/ejabberd/ejabberd.yml -A2 | grep all | sed -r 's/^\s*-\s([0-9]+).*/\1/'
}
per_account_storage_usage() {
STORAGE_DIR="/srv/ejabberd/chapril.org/upload/"
# TODO Directories to ignore because they are used for tests accounts (bart and lisa simpsons)
IGNORE_DIRS="35eae3ddc83d72e4d3fad3160a400db688d7d936 9be859c77649f33d207cbe0d74a126b2fd31cb33"
echo "Per user disk usage:"
tmp="$(du -sh ${STORAGE_DIR}* | sort -hr | awk '{print $1}')"
echo "** Max: "$(echo "${tmp}" | head -n 1)
# echo " Min: "$(echo "${tmp}" | tail -n 1)
subfolders_count=$(find ${STORAGE_DIR} -mindepth 1 -maxdepth 1 -type d | wc -l)
total_size=$(du -s ${STORAGE_DIR} | awk '{print $1}')
avg=$(((${total_size} / 1024) / ${subfolders_count}))
echo "** Avg: ${avg}M"
}
count_archived_messages() {
psql -U ejabberd -h localhost ejabberd -c "select count(*) from archive where peer not like 'irc%' and username not in ('r.giskard', 'lisa.simpson', 'bart.simpson')" -t | grep -v '^$' | awk '{print $1}'
}
main

View File

@ -1,42 +0,0 @@
#! /bin/bash
REDMINE_BASE_URL="https://agir.april.org"
API_KEY="4d724eb3e51600b6f9aff26360a5430f76ad4dd9"
TICKET_ID=4047
REPORT_COMMAND="/usr/local/sbin/display_activity_report"
main() {
post_report
}
post_report() {
datafile=$(mktemp /tmp/report_stats_$(date +%Y-%m-%d_%H%M)_XXXX.json)
cat <<EOF > "${datafile}"
{
"issue": {
"notes": "$(${REPORT_COMMAND} | sed -z 's/\n/\\n/g')"
}
}
EOF
curl -s \
-H "Content-Type: application/json" \
-H "X-Redmine-API-Key: ${API_KEY}" \
-X PUT --data-binary "@${datafile}" \
"${REDMINE_BASE_URL}/issues/${TICKET_ID}.json"
rm "${datafile}"
}
# debug function
last_comment_date() {
curl -H "X-Redmine-API-Key: ${API_KEY}" -s "${REDMINE_BASE_URL}/issues/${TICKET_ID}.json?include=journals" \
| jq '.issue.journals | last | .created_on'
}
# debug function
list() {
curl -H "X-Redmine-API-Key: ${API_KEY}" -s "${REDMINE_BASE_URL}/issues/${TICKET_ID}.json?include=journals" \
| jq '.issue.journals[] | [.user.name, .notes]'
}
main