Stéphane Thirion
  • Home
  • Consulting – Raidho
  • homelab
3K
0
0
0
Stéphane Thirion
Stéphane Thirion
  • Home
  • Consulting – Raidho
  • homelab
  • ArchY.net Site
  • Citrix
  • Linux
  • XenServer

WP-XenServerStats – WordPress Plugin for XenServer 2/2

  • February 6, 2011
  • Stephane Thirion
Total
0
Shares
0
0
0
0
0
0
0

WP-XenServerStats – WordPress Plugin for XenServer 1/2
WP-XenServerStats – WordPress Plugin for XenServer 2/2

In the first part of this blog, I made a list about what I wanted to do, how to get the data and how to transport it from my XenServer (home) to my Web Host (Datacenter). Now I’ll explain how I create one WordPress plug-in (my first one) to show everything :

It looks good, and even if it’s really low level on the dev side in PHP and scripting, it works well. In WordPress, there is this sidebar, on the right, if you want to add something you can chose to do it as widget, it’s clean and not hard coded in the main WordPress code, then you can easily keep this plug-in and keep it working without changing anything from a theme to another.

I created a file named : wp-xenserverstats.php in a new directory : wp-xenserverstats/wp-xenserverstats.php this is the main plug-in file and as you can read bellow, this is very very basic.

Source code   
  1. <?php
  2. /*
  3. Plugin Name: WP-XenServerStats
  4. Plugin URI:
  5. Description: Citrix XenServer statistics
  6. Version: 0.2
  7. Author: Stephane Thirion
  8. Author URI:
  9. */
  10.  
  11. function xenserverhostname()
  12. {
  13. $myFile = "/homez.35/archy/www/wp-content/plugins/wp-xenserverstats/hostname.txt";
  14. $fh = fopen($myFile, 'r');
  15. $theData = fread($fh, 12);
  16. fclose($fh);
  17. echo $theData;
  18. }
  19.  
  20. function hostcpu()
  21. {
  22. $myFile = "/homez.35/archy/www/wp-content/plugins/wp-xenserverstats/host_cpus.txt";
  23. $fh = fopen($myFile, 'r');
  24. $theData = fread($fh, 2);
  25. fclose($fh);
  26. echo $theData;
  27. }
  28.  
  29. function hostmem()
  30. {
  31. $myFile = "/homez.35/archy/www/wp-content/plugins/wp-xenserverstats/host_mem.txt";
  32. $fh = fopen($myFile, 'r');
  33. $theData = fread($fh, 10);
  34. fclose($fh);
  35. echo $theData;
  36. }
  37.  
  38. function totalvmscount()
  39. {
  40. $myFile = "/homez.35/archy/www/wp-content/plugins/wp-xenserverstats/vms_total.txt";
  41. $fh = fopen($myFile, 'r');
  42. $theData = fread($fh, 2);
  43. fclose($fh);
  44. echo $theData;
  45. }
  46.  
  47. function totalpoweredvmscount()
  48. {
  49. $myFile = "/homez.35/archy/www/wp-content/plugins/wp-xenserverstats/vms_powered.txt";
  50. $fh = fopen($myFile, 'r');
  51. $theData = fread($fh, 2);
  52. fclose($fh);
  53. echo $theData;
  54. }
  55.  
  56. function totalhaltedvmscount()
  57. {
  58. $myFile = "/homez.35/archy/www/wp-content/plugins/wp-xenserverstats/vms_halted.txt";
  59. $fh = fopen($myFile, 'r');
  60. $theData = fread($fh, 2);
  61. fclose($fh);
  62. echo $theData;
  63. }
  64.  
  65. function totalsuspendedvmscount()
  66. {
  67. $myFile = "/homez.35/archy/www/wp-content/plugins/wp-xenserverstats/vms_suspended.txt";
  68. $fh = fopen($myFile, 'r');
  69. $theData = fread($fh, 2);
  70. fclose($fh);
  71. echo $theData;
  72. }
  73.  
  74. function lastupdate()
  75. {
  76. $myFile = "/homez.35/archy/www/wp-content/plugins/wp-xenserverstats/last_update.txt";
  77. $fh = fopen($myFile, 'r');
  78. $theData = fread($fh, 26);
  79. fclose($fh);
  80. echo $theData;
  81. }
  82.  
  83. function widget_wpxenserver($args)
  84. {
  85. extract($args);
  86. echo $before_widget;
  87. echo $before_title;
  88. echo "XenServer Stats";
  89. echo $after_title;
  90. echo "<div style='text-align: left; padding-left: 10px;'><b><u><img src='".$baseurl."/wp-content/plugins/wp-xenserverstats/images/host.png'> Host : ";
  91. xenserverhostname();
  92.  
  93. echo "</u></b><br>Cpu Nbr : ";
  94. hostcpu();
  95.  
  96. echo "/ Memory : ";
  97. hostmem();
  98.  
  99. echo "Mb<br><br><img src='".$baseurl."/wp-content/plugins/wp-xenserverstats/images/vmstotal.png'> Virtual Machines : ";
  100. totalvmscount();
  101.  
  102. echo "<br><img src='".$baseurl."/wp-content/plugins/wp-xenserverstats/images/powered.png'> Powered On VMs : ";
  103. totalpoweredvmscount();
  104.  
  105. echo "<br><img src='".$baseurl."/wp-content/plugins/wp-xenserverstats/images/halted.png'> Halted VMs : ";
  106. totalhaltedvmscount();
  107.  
  108. echo "<br><img src='".$baseurl."/wp-content/plugins/wp-xenserverstats/images/paused.png'> Suspended VMs : ";
  109. totalsuspendedvmscount();
  110.  
  111. echo "<br><br><i>Last Update : ";
  112. lastupdate();
  113.  
  114. echo "</i></div>";
  115. echo $after_widget;
  116. }
  117.  
  118. function wpxenserver_init()
  119. {
  120. register_sidebar_widget(__('XenServer Widget'), 'widget_wpxenserver');
  121. }
  122. add_action("plugins_loaded", "wpxenserver_init");
  123. ?>

So as you see, there is still some hard coded path… I try to get rid of that this week, and if someone can give me the tip, it will save me some time… (more…)

Total
0
Shares
Tweet 0
Share 0
Share 0
Share 0
Share 0
Share 0
Share 0
Related Topics
  • Plugin XenServerStats
  • Scripting
  • Wordpress
  • WP-XenServerStats
  • XenServer
Stephane Thirion

Previous Article
  • Citrix
  • Linux
  • XenServer

WP-XenServerStats – WordPress Plugin for XenServer 1/2

  • February 5, 2011
  • Stephane Thirion
View Post
Next Article
  • Citrix
  • Windows 2008 R2

Microsoft RDS – Thoughts and walkthrough 1/3

  • February 14, 2011
  • Stephane Thirion
View Post
You May Also Like
View Post
  • Experience
  • Linux
  • VMware
  • vSphere

multipathd errors in /var/log/syslog

  • Stephane Thirion
  • August 2, 2022
View Post
  • Citrix
  • CTP
  • Uncategorized

This is the end of an era

  • Stephane Thirion
  • February 16, 2022
View Post
  • Docker
  • Experience
  • Kubernetes
  • Linux
  • Raspberry

Kubernetese cluster use with Crypto Currency (Monero)

  • Stephane Thirion
  • January 4, 2022
View Post
  • ADC
  • Experience
  • Linux

Cloud yes but no, thanks (there is some Citrix)

  • Stephane Thirion
  • December 7, 2021
View Post
  • ArchY.net Site
  • Azure
  • Citrix
  • Cloud
  • Experience
  • Microsoft
  • News
  • Office365
  • Raidho
  • VMware

Mettre en place une solution de travail à distance (RemoteOffice / Remoteworking) 2/2

  • Stephane Thirion
  • March 24, 2020
View Post
  • Amazon
  • Citrix
  • Cloud
  • Experience
  • Microsoft
  • News
  • Office365
  • Raidho
  • Security
  • VMware

Mettre en place une solution de travail à distance (RemoteOffice / Remoteworking) 1/2

  • Stephane Thirion
  • March 22, 2020
View Post
  • Citrix
  • Citrix Virtual Apps and Desktops
  • Microsoft
  • PowerShell
  • Scripting
  • Windows 2016
  • Windows 2019
  • XenApp
  • XenDesktop

Enable SSL on Citrix Virtual Apps and Desktops 1912(+) XML Service

  • Stephane Thirion
  • February 13, 2020
View Post
  • Citrix
  • E2E - PubForum
  • Events
  • Microsoft
  • News

E2Evc Lisboa November 2019

  • Stephane Thirion
  • November 13, 2019
vmware
Coinbase – Affiliated link
Blog Stats
  • 1,237,018 hits
Categories
  • Amazon (1)
  • Apple (20)
    • iOS (5)
    • Mac OSx (11)
  • ArchY.net Site (30)
  • Azure (8)
  • Certifications (3)
  • Citrix (207)
    • ADC (1)
    • Citrix Virtual Apps and Desktops (3)
    • NetScaler (12)
    • Password Manager (3)
    • Personal vDisk (5)
    • Power and Capacity Management (3)
    • Provisioning Services (22)
    • Receiver (29)
    • ShareFile (8)
    • Single Sign On (3)
    • SmartAuditor (2)
    • Storefront (12)
    • Synergy (25)
    • User Profile Management (2)
    • VDI (7)
    • WebInterface (21)
    • XenApp (84)
    • XenApp Plugin (3)
    • XenClient (10)
    • XenDesktop (55)
    • XenServer (42)
  • Cloud (12)
  • Crystal Ball (2)
  • CTP (13)
  • Docker (2)
  • Events (35)
    • E2E – PubForum (9)
    • Geek Speak (3)
  • Experience (53)
  • Kubernetes (2)
  • Licensing (3)
  • Linux (12)
  • Microsoft (145)
    • Azure (8)
    • Office365 (4)
    • PowerShell (18)
    • RDS (5)
    • Windows 10 (6)
    • Windows 2003 (21)
    • Windows 2008 (20)
    • Windows 2008 R2 (54)
    • Windows 2012 (13)
    • Windows 2012R2 (13)
    • Windows 2016 (18)
    • Windows 2019 (4)
    • Windows 2022 (1)
    • Windows 7 (27)
    • Windows 8 (19)
    • Windows Virtual Desktop (1)
    • Windows XP (11)
  • News (5)
  • Raidho (2)
  • Raspberry (3)
  • Scripting (13)
  • Security (4)
  • Slide Deck (1)
  • Thin Clients (3)
  • Twitter (1)
  • Ubiquiti (1)
  • Uncategorized (12)
  • VMware (27)
    • VMWare WorkStation (2)
    • vSphere (15)
Stéphane Thirion
Don't Follow the Trend

Input your search keywords and press Enter.

 

Loading Comments...