[kvmstats] add playbook to deploy kvmstats
continuous-integration/drone/push Build is passing Details

Also add a cron to update the stats.
This commit is contained in:
Alexis Ben Miloud--Josselin 2019-07-31 14:42:50 +02:00
parent e246f02058
commit 15e2165213
3 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,22 @@
###
# ansible-playbook -l $hosts -K --diff --check deploy-kvmstats.yml
---
- hosts: all
become: yes
tasks:
- name: kvmstats is installed
copy:
src: kvmstats
dest: /usr/share/scripts/kvmstats
mode: "0700"
- name: cron for kvmstats is installed
copy:
src: kvmstats.cron
dest: /etc/cron.hourly/kvmstats
mode: "0755"
- name: entry for kvmstats in web page is present
lineinfile:
dest: /var/www/index.html
insertbefore: '</ul>'
line: '<li><a href="/kvmstats.html">kvmstats</a></li>'

View File

@ -85,7 +85,7 @@ done | xargs -n5 | {
column -t
;;
'html')
awk 'BEGIN{print "<html><body><table>"}{printf "<tr>";for(i=1;i<=NF;i++)printf "<td>%s</td>", $i;print "</tr>"}END{print "</table></body></html>"}'
awk 'BEGIN{print "<html><body>\n<table>"}{printf "<tr>";for(i=1;i<=NF;i++)printf "<td>%s</td>", $i;print "</tr>"}END{print "</table>\n</body></html>"}'
;;
'csv')
tr ' ' ','

3
kvmstats/kvmstats.cron Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
/usr/share/scripts/kvmstats -o html > /var/www/kvmstats.html
/bin/chmod go+r /var/www/kvmstats.html