penfold Posted June 13, 2017 Posted June 13, 2017 One of my daily tasks is to check free disk space on servers (specifically the file server). I've got a number of scripts to do this but in order to monitor it over time I am playing about using a script which outputs the result to a html file and updates the content each time it is run. Now while that is nice, I've thought I'd rather have a graph so I can see visually when space is being used. My thinking was that I can export the result to an excel file and create a graph based on the free space left. I've now got another script which I can pull out the values and export them to excel but it seems to be in the wrong format. The way I was trying to create the graph was to have a structure as follows: Date,Server1,Server2... so effectively when the script runs you get Date,Server1,Server2 01/06/2017, 100,50 02/06/2017, 80, 45 However the script I am using produces this: Date,ServerName,FreeSpace Which results in Date,ServerName,FreeSpace 01/06/2017,Server1,100 01/06/2017,Server2,50 02/06/2017,Server1,80 02/06/2017,Server2,45 Is is possible to change the code so it out puts the free space under the heading of the Server? I am basing the script on the one here but the specific but of code I am using is: $DiskReport | Select-Object @{Label = "Date";Expression = {$logdate}},@{Label = "Server Name";Expression = {$_.SystemName}},@{Label = "Drive Letter";Expression = {$_.DeviceID}},@{Label = "Total Capacity (GB)";Expression = {"{0:N1}" -f( $_.Size / 1gb)}},@{Label = "Free Space (GB)";Expression = {"{0:N1}" -f( $_.Freespace / 1gb ) }},@{Label = 'Free Space (%)'; Expression = {"{0:P0}" -f ($_.freespace/$_.size)}} |Export-Csv -path "D:\DiskReport.csv" -NoTypeInformation -Append Or am I going about this all wrong? I would just like a record of Space used over time and use this to create a chart. I wanted to automate as much as I could so the chart would auto update as entries are added to the spreadsheet.
dapaulio Posted June 13, 2017 Posted June 13, 2017 There are plenty of network monitoring systems free and paid that report exactly what you are trying to achieve and more. Scom for instance that i think comes with your licensing agreement. Nagios is another which is free linux based. I run Nagios and the output is basic but is a brilliant traffic light system that gives me the status of many aspects of all my servers on one page. I'm sure I could export historical data to create a graph. 1
penfold Posted June 15, 2017 Author Posted June 15, 2017 I've got this sorted now. I've just updated the script to open an existing file and create a new worksheet. Does pretty much everything I wanted it to do. Only reason I was going with this is because I already have a set of scripts which I run to get specific information as part of my daily checks. Most of which only output to the screen. Just thought it might be worth developing them to be a bit more user friendly.
Knil92 Posted June 15, 2017 Posted June 15, 2017 you know you can use >> filename.txt to output the results to a text file instead of the command prompt window, then you can use a vbs script to send it as an e-mail to yourself. So it stops you having to connect to the server and run the scripts yourself.
penfold Posted June 15, 2017 Author Posted June 15, 2017 @Knil92 - I don't connect to servers to run the scripts, they are run from my machine and run against remote servers. Output is just reported in the powershell window which is fine for me. I was just thinking I could then take this data to form some sort of logging & reporting. As @dapaulio has suggested I can use other tools for this. I was just thinking it would have been pretty straight forward as I had most of the script already. I tend to have a few powershell scripts which I use to do daily checks to save me logging onto to multiple servers in the morning.
fewd01 Posted August 26, 2017 Posted August 26, 2017 This one is amazing with a little tweaking of the scripts... https://community.spiceworks.com/scripts/show/2174-get-report-of-multiple-servers-hdd-space-ram-usage We schedule it to run every Tuesday and email our monitoring inbox. All you need to do is look for the red cells on the resulting table, each row being an individual server HDD. 1
penfold Posted August 29, 2017 Author Posted August 29, 2017 Thanks @fewd01 I actually ended up dropping the use of powershell for this as we had alarms in our monitoring software which I wasn't using.
Sephiroth Posted August 29, 2017 Posted August 29, 2017 you know you can use >> filename.txt to output the results to a text file instead of the command prompt window, then you can use a vbs script to send it as an e-mail to yourself. So it stops you having to connect to the server and run the scripts yourself. Just as an aside, powershell can send email too with Send-MailMessage ... Send-MailMessage [-To] [-Subject] [[-Body] ] [[-SmtpServer] ] [-Attachments ] [-Bcc ] [-BodyAsHtml] [-Cc ] [-Credential ] [-DeliveryNotificationOption ] [-Encoding ] -From [-Port ] [-Priority ] [-UseSsl] [] 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now