Saburo
November 7th, 2003, 08:15 PM
Hi guys,
Lemme start by saying I really love this project so far, so I've decided to put forth some input, and hopefully give some people some ideas on how to use this wonderful software.
Anyway, I did a quick search, and found that there doesn't seem to be anyone doing this yet, so I thought I'd let you know what I did for my personal CCF. The ccf is still in the works, so I won't be posting that (yet)
anyway, I needed a way to view my htpc's disc usage, mem usage, and other vital stats. I accomplished this using these things:
CoolMon (System Monitor)
Girder (w/ MBM and TimeServer Plugin)
and thats it :)
First, I'll assume you have feedback with girder working and all of that. Go download CoolMon (found here (http://coolmon.arsware.org/)) and install it. When that finishes make sure its running (right click icon in systray) and select display items. From here you can choose any of the items you want to monitor. the only necessary part is you remove all the useless information (like "FREE MEM:" stuff) this is what mine looks like:
<NAME=IPAddr>
<NAME=Uptime FORMAT="*d* Days, *h* Hrs, *M* Mins" SIZE=20>
<NAME=RAMFree>
<NAME=RAMTotal>
<NAME=ProcUsage LEADZERO DECIMAL SIZE=5 FORMAT="ALL">
<NAME=DriveSpace SIZE=5 FORMAT="C FREE">
<NAME=DriveSpace Size=5 FORMAT="C TOTAL">
<NAME=DriveSpace SIZE=5 FORMAT="D FREE">
<NAME=DriveSpace SIZE=5 FORMAT="D TOTAL">
<NAME=DriveSpace SIZE=5 FORMAT="E FREE">
<NAME=DriveSpace SIZE=5 FORMAT="E TOTAL">
when you apply those settings, the program output should just be the values of the items to monitor. remember the order they are in.
CoolMon has the ability to output what its recording to XML in a given inteval. You can accomplish this by right clicking the icon, and going under config. select "AutoSave XML" and you'll get a file prompt. after saving it you'll get the update interval dialog option. If you are monitoring things like CPU Usage, I'd suggest a lower interval. if its just HDD space, go for long intervals (won't change often).
After thats done, this is where the scripting comes in. After searching through the coolmon forums, I found this thead (http://coolmon.arsware.org/forum/viewtopic.php?t=572) where A1ehouse was kind enough to a lot of the work for me ;) anyway, Here is the code (in case that link is down):
'XML to Raw Text script for CoolMon users
'Removes ALL Coolmon tags (colour/file/links/pixelstart)
'Aswell as dodgy chracters "%3C" etc!
'written by A1ehouse
'for CoolMon <<www.arsware.org/coolmon/>>
'You DON'T need a webserver for this, just your XML autosave
'Right click the coolmon icon>Config>AutoSave XML>Choose Dir>Choose Interval Time!
On Error Resume Next
Const XML = "c:\Program Files\CoolMon\coolmon.xml" 'Change this to where you have Autosaved your XML
Const Path = "c:\Program Files\CoolMon\XMLtoText.txt" 'Change this to where you want to save your Text Output
Set doc = CreateObject("MSXML.DOMDocument")
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile(Path, True)
doc.async = false
doc.load(XML)
Dim i
For i = 0 To 10 'Change 60 to the number of Formatted Items you have or leave as is
Item_x = doc.selectSingleNode("//Item_" & i).xml
'Manipulate the string to change the spurious characters
Item_x = replace(Item_x,"%3C","<")
Item_x = replace(Item_x,"%3E",">")
Item_x = replace(Item_x,"%A0","")
Item_x = replace(Item_x,"%25","%")
Item_x = Replace(Item_x,"%BA","º")
'Remove the tags, including all the colour/bold/underline/shadow/links/pixelstarts
'This loops 10 times, but could be more or less, depending on the max no. of formatting for any one line
'e.g. One line may have:
'<Item_6><u><c red>C: </u></c><PIXELSTART=25>1,453<PIXELSTART=75>4,001 MB<LINK="file:///C:\"></Item_6>
'Which has 10 different tags to remove!!!
Dim j
For j = 1 To 10 'If one of your lines had more than 10 change this
Item_x = Replace(Item_x,Mid(Item_x,InStr(Item_x,"<"),InStr(InStr(Item_x,"<"),Item_x,">")-InStr(Item_x,"<")+1),"")
Next
outFile.WriteLine Item_x
Next
outFile.Close
Just edit the necessary lines and paste that into notepad and save it as "XMLtoText.vbs"
Now comes girder's magic.
What I did is set up a multigroup that would be triggered on an interval using the TimeServer Plugin (make the interval a little longer than coolmon's interval). Under the multigroup just add an event that will execute the vbs script from above. (OS->Execute, File = "X:\Path\To\File\XMLtoText.vbs"). Then create a LUA script event. All it needs to do is read in the txt file created by the vbs script (output file is specified inside the script) and read line by line all the data. This is where you need to remember what order all the stats are displayed. For this its really upto you, since its not hard, but here's what mine looks like:
--First Open the File
local stats_file = openfile("C:\\Program Files\\CoolMon\\XMLtoText.txt", "r");
--Read the IP from the file
Sys_IP = read(stats_file, "*l");
--Read the Uptime from the file
Sys_Uptime = read(stats_file, "*l");
--Read the Free Ram from the file
Sys_FreeRAM = read(stats_file, "*l");
--Read the Total Ram from the file
Sys_TotalRAM = read(stats_file, "*l");
--Read the CPU Usage from the file
Sys_CPUusg = read(stats_file, "*l");
--Read the C Drive Free MB's
Sys_CFree = read(stats_file, "*l");
--Read the C Drive Total MB's
Sys_CTotal = read(stats_file, "*l");
--Read the D Drive Free MB's
Sys_DFree = read(stats_file, "*l");
--Read the D Drive Total MB's
Sys_DTotal = read(stats_file, "*l");
--Read the E Drive Free MB's
Sys_EFree = read(stats_file, "*l");
--Read the E Drive Total MB's
Sys_ETotal = read(stats_file, "*l");
After that I just have another LUA script that will output all the variables to NetRemote using the NetRemote.SendLabel functionality Naturally you could do this all in the same LUA script, but this made more sense to me. I'll leave that to you.
Hopefully I wrote this out in a manner thats understandable. If you need clarification on anything, just lemme know, and I'll be more than happy to clear things up. Also, if you do find this usefull/cool/stupid, I'd love to hear it ;)
and finally, a screenshot of it all together in my ccf:
SCREENSHOT (http://warrior-network.org/Misc/SystemStats.jpg)
Enjoy :)
Lemme start by saying I really love this project so far, so I've decided to put forth some input, and hopefully give some people some ideas on how to use this wonderful software.
Anyway, I did a quick search, and found that there doesn't seem to be anyone doing this yet, so I thought I'd let you know what I did for my personal CCF. The ccf is still in the works, so I won't be posting that (yet)
anyway, I needed a way to view my htpc's disc usage, mem usage, and other vital stats. I accomplished this using these things:
CoolMon (System Monitor)
Girder (w/ MBM and TimeServer Plugin)
and thats it :)
First, I'll assume you have feedback with girder working and all of that. Go download CoolMon (found here (http://coolmon.arsware.org/)) and install it. When that finishes make sure its running (right click icon in systray) and select display items. From here you can choose any of the items you want to monitor. the only necessary part is you remove all the useless information (like "FREE MEM:" stuff) this is what mine looks like:
<NAME=IPAddr>
<NAME=Uptime FORMAT="*d* Days, *h* Hrs, *M* Mins" SIZE=20>
<NAME=RAMFree>
<NAME=RAMTotal>
<NAME=ProcUsage LEADZERO DECIMAL SIZE=5 FORMAT="ALL">
<NAME=DriveSpace SIZE=5 FORMAT="C FREE">
<NAME=DriveSpace Size=5 FORMAT="C TOTAL">
<NAME=DriveSpace SIZE=5 FORMAT="D FREE">
<NAME=DriveSpace SIZE=5 FORMAT="D TOTAL">
<NAME=DriveSpace SIZE=5 FORMAT="E FREE">
<NAME=DriveSpace SIZE=5 FORMAT="E TOTAL">
when you apply those settings, the program output should just be the values of the items to monitor. remember the order they are in.
CoolMon has the ability to output what its recording to XML in a given inteval. You can accomplish this by right clicking the icon, and going under config. select "AutoSave XML" and you'll get a file prompt. after saving it you'll get the update interval dialog option. If you are monitoring things like CPU Usage, I'd suggest a lower interval. if its just HDD space, go for long intervals (won't change often).
After thats done, this is where the scripting comes in. After searching through the coolmon forums, I found this thead (http://coolmon.arsware.org/forum/viewtopic.php?t=572) where A1ehouse was kind enough to a lot of the work for me ;) anyway, Here is the code (in case that link is down):
'XML to Raw Text script for CoolMon users
'Removes ALL Coolmon tags (colour/file/links/pixelstart)
'Aswell as dodgy chracters "%3C" etc!
'written by A1ehouse
'for CoolMon <<www.arsware.org/coolmon/>>
'You DON'T need a webserver for this, just your XML autosave
'Right click the coolmon icon>Config>AutoSave XML>Choose Dir>Choose Interval Time!
On Error Resume Next
Const XML = "c:\Program Files\CoolMon\coolmon.xml" 'Change this to where you have Autosaved your XML
Const Path = "c:\Program Files\CoolMon\XMLtoText.txt" 'Change this to where you want to save your Text Output
Set doc = CreateObject("MSXML.DOMDocument")
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile(Path, True)
doc.async = false
doc.load(XML)
Dim i
For i = 0 To 10 'Change 60 to the number of Formatted Items you have or leave as is
Item_x = doc.selectSingleNode("//Item_" & i).xml
'Manipulate the string to change the spurious characters
Item_x = replace(Item_x,"%3C","<")
Item_x = replace(Item_x,"%3E",">")
Item_x = replace(Item_x,"%A0","")
Item_x = replace(Item_x,"%25","%")
Item_x = Replace(Item_x,"%BA","º")
'Remove the tags, including all the colour/bold/underline/shadow/links/pixelstarts
'This loops 10 times, but could be more or less, depending on the max no. of formatting for any one line
'e.g. One line may have:
'<Item_6><u><c red>C: </u></c><PIXELSTART=25>1,453<PIXELSTART=75>4,001 MB<LINK="file:///C:\"></Item_6>
'Which has 10 different tags to remove!!!
Dim j
For j = 1 To 10 'If one of your lines had more than 10 change this
Item_x = Replace(Item_x,Mid(Item_x,InStr(Item_x,"<"),InStr(InStr(Item_x,"<"),Item_x,">")-InStr(Item_x,"<")+1),"")
Next
outFile.WriteLine Item_x
Next
outFile.Close
Just edit the necessary lines and paste that into notepad and save it as "XMLtoText.vbs"
Now comes girder's magic.
What I did is set up a multigroup that would be triggered on an interval using the TimeServer Plugin (make the interval a little longer than coolmon's interval). Under the multigroup just add an event that will execute the vbs script from above. (OS->Execute, File = "X:\Path\To\File\XMLtoText.vbs"). Then create a LUA script event. All it needs to do is read in the txt file created by the vbs script (output file is specified inside the script) and read line by line all the data. This is where you need to remember what order all the stats are displayed. For this its really upto you, since its not hard, but here's what mine looks like:
--First Open the File
local stats_file = openfile("C:\\Program Files\\CoolMon\\XMLtoText.txt", "r");
--Read the IP from the file
Sys_IP = read(stats_file, "*l");
--Read the Uptime from the file
Sys_Uptime = read(stats_file, "*l");
--Read the Free Ram from the file
Sys_FreeRAM = read(stats_file, "*l");
--Read the Total Ram from the file
Sys_TotalRAM = read(stats_file, "*l");
--Read the CPU Usage from the file
Sys_CPUusg = read(stats_file, "*l");
--Read the C Drive Free MB's
Sys_CFree = read(stats_file, "*l");
--Read the C Drive Total MB's
Sys_CTotal = read(stats_file, "*l");
--Read the D Drive Free MB's
Sys_DFree = read(stats_file, "*l");
--Read the D Drive Total MB's
Sys_DTotal = read(stats_file, "*l");
--Read the E Drive Free MB's
Sys_EFree = read(stats_file, "*l");
--Read the E Drive Total MB's
Sys_ETotal = read(stats_file, "*l");
After that I just have another LUA script that will output all the variables to NetRemote using the NetRemote.SendLabel functionality Naturally you could do this all in the same LUA script, but this made more sense to me. I'll leave that to you.
Hopefully I wrote this out in a manner thats understandable. If you need clarification on anything, just lemme know, and I'll be more than happy to clear things up. Also, if you do find this usefull/cool/stupid, I'd love to hear it ;)
and finally, a screenshot of it all together in my ccf:
SCREENSHOT (http://warrior-network.org/Misc/SystemStats.jpg)
Enjoy :)