Ping Results with CSV

This is a project that came out of a wish list from a coworker to monitor,  at a glance, if something is up or down as well as have a bit of a history to analyze for any slow or dropped pings, hence the graph.  The first phase (script) ping.ps1 for performing the ping tests is from an external source that my coworker found and then modified by the two of us to get what we want, the second phase of the process is GeneratePingCharts.ps1 written by me to generate the graphs from the output of the first script using RGraph which is an HTML 5 charts library.

GeneratePingCharts.ps1 output sampleping.ps1 output sample
Ping Results GraphsPing Results HTM


I am writing about this one first since I wrote it from scratch. The script calculates the ping response time averages for month, week, & day utilizing the data collected and saved in a CSV file and outputs the graphs and averages to an HTML file. For flexibility I allow the folder containing the CSV files, where the HTML should be outputted, and the location of the RGraph library files to be passed as parameters to the script.

The script starts by outputting the CSS utilized and then gathers the list of files containing the CSV extension from the folder path passed in.  For each file found a new job is started, with a maximum of 10 jobs running at a time, to process the CSV file.  The script waits for all 10 jobs to finish  and then removes the jobs prior to starting 10 more jobs.  This process continues until all files have been handled.

The line which starts the job by running the script block and passing the parameters is:

Start-Job $ProcessCSVScriptBlock -ArgumentList $file.FullName,$outputPath,$rGraphJS

The script block then initiates the processing of the CSV file by calling the Process-CSV function.  The CSV file is imported into a variable using the Import-CSV PowerShell cmdlet followed by each row being processed.  The sum of all the response times and number of response times collected is tracked to calculate the averages.  The response times are stored in a string with the format [a,b,c,….,z] where a-z is the response time value and will contain as many as there are stored in the CSV for the given time frame.  The only exception to this is month, which stores the average response time over $mInc points; otherwise, the graph would not draw do to the large quantity of points.  All this data is then stored into a custom object which is passed to the Generate-Chart function.

The Generate-Chart function stores the HTML for the graph page in a variable inserting the appropriate information stored in the $chartOut parameter in with the HTML string so that the:

  • Machine name and run time are displayed at the top
  • Averages are displayed in a table
  • Day, week, and month graphs contain the appropriate data points.

Worth mentioning is that the Get-My-Date function is used to convert the date stored in an unsupported format (MM_DD_YYYY) to a supported format (YYYY-MM-DD) so that within the Process-CSV function the date can be compared against today’s date allowing the script to know which graphs the ping result belong too.

Continue reading

Portfolio & My Story

I have made some major overhauls to my website over the past month to a point where I can deem things acceptable.  The latest updates include finding a portfolio implementation I like and getting an initial start on my story, where I have a start on the academics section but am still trying to figure out what to write and how to word parts of it.  I have a solid section for my athletics to give a comprehensive overview.  I’m not really sure if I need to give any more details like injuries, additional mini-stories, etc.

The plugin I came across which give me the best look and feel for what I am going for is the Aeolus Portfolio WP Plugin.  This wasn’t as simple as install and configure.  The latest version, as of this writing, is 1.8 which once installed and activated did not work properly with my theme.  The issue I was having is that all the content would become ‘minified’ and illegible due to the plugin altering the display of the theme.  My best guess is that this is due to the Bootstrap update for the plugin.

In order to get around this I removed the plugin I installed through the WordPress Add Plugin feature and grabbed version 1.7 of the Aeolus Creative Portfolio plugin, unzipped the file and uploaded the folder to my WordPress installation plugins directory.  I was then able to go to the Plugins section on the dashboard within WordPress and activate version 1.7 of the plugin.  This did not cause any negative effects with my theme so I continued on and configured my Portfolio page to display all portfolio items with pagination similar to a parallax effect since it gives the short description for items.  I’m not sure at the moment how well this is going to work long term as it doesn’t appear to show categories; however, you can filter by category so I may be able to do one of the following once there are a lot of items:

  • Add multiple portfolio short codes to one page filtered by category and then add a top navigation manually  with anchor tags / headings to the various sections
  • Add individual pages for each portfolio category as subpages of Portfolio and the root page would be either like the first bullet point or links with explanations to the sub pages

Now I just have to build up my portfolio.  This all started with a portfolio being a requirement for a job interview I had while finishing up my Masters.  This is why the only portfolio items so far are for my academic projects.  Presently I have no work projects I am allowed to divulge (or for that matter have access to anymore) from past or present positions.

In the case of personal projects the portfolio items will appear upon completion of the first major version (1.0) and will be updated with any major features that get added as well as link to the corresponding category containing all posts pertaining to the project.