LabTech Vitals Dashboard

Today we release the next round for the Squidworks Labtech Vitals Dashboard.

The Labtech Vitals Dashboard is a set of web pages that query the local Labtech MySql database and provides visual widgets of important data on the main display of the Labtech Support Console. We currently have 17 different widgets with 10 of them having detail views.

To install the Dashboard you will need to download and install PHP 5 for windows at PHP.net on your Labtech server. Afterwards download the SWVDB zip package and unzip to c:\inetpub\wwwroot\SWVDB. Go into this directory and find the header.php file and open it with notepad. You will need to edit the LT server address, Username and password for the LT database access to work.

Once completed you should be able to browse http://your.labtech.server/SWVDB/ and get the dashboard. Now to have the dashboard auto load in the console for everyone who uses support console go to your LT config dashboard -> Config -> Control Center and set the Initial URL Value to your tested URL from above.

Get the dashboard ->  Download SWVDB here

 

Should look like this:

SWVDB-setup

Widgets:

Systems Missing AntiVirus application

SWVDB-missingAV

 

 

 

Agents missing patches

SWVDB-missingpatch

 

 

 

 

Agents Online

SWVDB-oflinesystems

 

 

 

Offline Servers Alarms

SWVDB-offlineservers

 

 

 

 

 

 

Dell Appassure 5 Backup Core Monitor

SWVDB-appassurebackups

 

 

 

ESX Hardware Health Monitor

SWVDB-ESXHardwareHealth

 

 

 

Hitman Pro Monitor

SWVDB-hitmanpro

 

 

 

Agent Monitors

SWVDBnopatch

 

 

 

 

 

ESX Monitor Details Page (Failed/Missing/All)

SWVDB-esx details

 

 

 

 

 

 

 

 

 

 

Dell Appassure Monitor Details (Completed and Failed)

SWVDB-appassure-details

 

 

 

 

 

 

Some widgets may not function correctly if you are not using the source data tables and extra monitor scripting I’ve made available like the Squidworks ESXi Health Monitor for Labtech located at ESX Health Monitor, The Dell Appassure Backups/Failures also requires my Appassure Backup Scripting to populate the database with data. You must edit the index.php page in notepad and uncomment the 5 function calls noted in index.php for ESX and Appassure counters to function. They have been commented out so that you do not get errors if tables are missing. Install both ESX and Appassure packages before uncommenting code block.

 

 

Enjoy

Cubert  😎

How-to: Setup Ubuntu and PHP to use MSSQL Microsoft SQL Server

It is easier to get PHP on Ubuntu to connect to MSSQL than it is to get PHP on Windows.

 

I would not normally believe such a thing until I tried to setup a pre-existing install of PHP on Windows missing any MSSQL extensions. Looking through Google to find information was less than quick and I found myself wanting to go back to my old faithful Ubuntu server, but how?

Here are my 10 quick steps to get PHP seeing MSSQL:

There are some basic software we will need to grab using apt-get, then we will install them and modify the php.ini file to update the new extension. I will go over the process below on how to install and in what order but before we do that I will give you a brief description of what we are doing.

We will need to get the source for PHP, we will also need the PHP Development packages. We will be installing FreeTDS and then editing our php.ini file. Lastly restarting Apache to complete the process.

For the rest of this we will assume you have ( sudo su -) so you do not need to sudo each cmd, but if not then add sudo where it applies. We are also assuming you already have a working php system and only need to add MSSQL functionality.

  1. apt-get source php5 – This will install the PHP source in the the current directory that you are in.
  2. cd php5-5.3.2/ext/mssql – This will place you in the PHP source directory for MSSQL. You may need to edit the directory path as 5.3.2 was the version as of this document and may not be the same version you are installing.
  3. apt-get install freetds-dev – This installs the extra libraries we will need for MSSQL
  4. apt-get install php5-dev – This installs the application (phpize) which we will use next to help build the MSSQL extension.
  5. phpize  – Run this while inside the (/ext/mssql ) directory
  6. ./configure –with-mssql – This creates the MakeFile we will need to build the extension from source.
  7. make – This cmd builds the extension.
  8. cd modules – move in to the module directory.
  9. cp mssql.so /usr/lib/php5/20090626   – Here you will need to pay close attention to the last directory here. This will very based on your version so change the numbers to fit what you have in your (/usr/lib/php5) directory.
  10. vi /etc/php5/apache2/php.ini – We want to go down to where you will find (Dynamic Extensions) and add on a new line the following -> extension = mssql.so then save and close the vi session ( Esc : wq)

You are all done, just restart Apache and test your mssql_connect

Restart Apache:

/etc/init.d/apache2 restart

Enjoy

Cubert

PHP preg_match hostname and domain from FQDN

How to get the hostname and the domain name from FQDN in PHP

This sound easy right? So easy that you would think it would be all over the internet as an example on how to parse host names from domain names. Wrong…. I spent a hour one day looking everywhere and all I found was parsing a URL. Well my needs go deeper I need to do a

How to get the hostname and the domain name from FQDN in PHP

This sound easy right? So easy that you would think it would be all over the internet as an example on how to parse host names from domain names. Wrong…. I spent a hour one day looking everywhere and all I found was parsing a URL. Well my needs go deeper I need to do a quick split of host name from domain name not matter how long or nested the domain names were.

There are a bunch of places that give you the same old PHP preg_match examples as found on www.php.net,   “How to parse the domain name from a URL.”

But lets say I want both the host name and the domain name? If you know anything about FQDN then you know that up to the first “.” is host name and everything else is sub domain, domain and root.

Sometimes your going to have a FQDN that = myname.mysub.mysecondsub.mydomain.root

You want to get “myname” & “mysub.mysecondsub.mydomain .root”

So here is how we do it…


//if host needs to be striped from a URL
preg_match('@^(?:http://)?([^/]+)@i', "http://barfly.beaners.bobbers.mybalistics.net/index.html", $matches);
$host = $matches[1];

//else make $host your FQDN and skip the above segment
preg_match("/^(.*?)\.(.*)/", $host, $rest);
echo "My name is" .$rest[1]. "
";
echo "My domain is" .$rest[2]. "
";

I hope this helps someone out there spending hours looking for the right expression.

PHP Pagination with timestamp / timeline display

Pagination with a timestamp as the center value

We provide a way to scroll page to page of data and show the time stamp of when the data was collected as part of the page navigations.

Here we setup the first query and findout how many pages we have.

$sql = “SELECT COUNT(*) FROM table where name = ‘” . $name . “‘ and type = ‘”

Pagination with a timestamp as the center value

We provide a way to scroll page to page of data and show the time stamp of when the data was collected as part of the page navigations.

Here we setup the first query and findout how many pages we have.


$sql = "SELECT COUNT(*) FROM table where name = '" . $name . "' and type = '" . $type . "'";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];
$rowsperpage = 1;
$totalpages = ceil($numrows / $rowsperpage);
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
$currentpage = (int) $_GET['currentpage'];
} else {
$currentpage = 1;
}
if ($currentpage > $totalpages) {
$currentpage = $totalpages;
}
if ($currentpage < 1) {
$currentpage = 1;
}
$offset = ($currentpage - 1) * $rowsperpage;

Now we need to make the second query for the actual data so we can place our scroll links and then display our data.


$sql = "SELECT * FROM table where name = '" . $name . "' and type = '" . $type . "' ORDER BY data_time DESC LIMIT $offset, $rowsperpage";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
while($row = mysql_fetch_array($result)){
$data = $row['data'];
$data_time = $row['data_time']; // expected in epoch
}
$range = 8;
echo "Reported data";
if ($currentpage > 1) {
echo " << ";
$prevpage = $currentpage - 1;
echo " < ";
}

for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
if (($x > 0) && ($x <= $totalpages)) {
if ($x == $currentpage) {
echo " [";
$rectime = date(DATE_RFC822, $data_time);
echo $rectime;
echo "]
";
} else {
echo " $x ";
}
}
}
if ($currentpage != $totalpages) {
$nextpage = $currentpage + 1;
echo " > ";
echo " >> ";
}

echo "


";
echo $data;
echo "";

 

You should have a database that use epoch time as its time field then set $data_time to that field. You will get a nice output with links to pages forward and previous and the time stamp in local time in the center as the current page you are on. Great for scrolling throught time dlimited data in a time line.

HOW-to: PHP Multiple Select List Box quick and easy..

Sometimes you find that it requires a little looping to get data from a form when using PHP and Multiple select list boxes. Here is a quick and easy way to loop through select data sent from a form in html. We also show you here how to use a Array of data to create the options. This is great if your doing a database query and need to use

Sometimes you find that it requires a little looping to get data from a form when using PHP and Mulitple select list boxes. Here is a quick and easy way to loop through select data sent from a form in html. We also show you here how to use a Array of data to create the options. This is great if your doing a database query and need to use that data in select box.

HTML :

select id="select[]" multiple="multiple" name="select[]" size="10"

option value=" . $listID . ">" .$listItem. ""; } /option /select

input id="button" name="button" type="submit" value="Submit" /

if (isset($_POST['select'])) {
$az = $_POST['select'];
foreach ($az as $a)
{
echo $a;
}
}

 

ELGG Plugin : My Online Friends Messenger

Here is a plugin for ELGG community web framework created to popout from side of browser and show your active friends by name and picture. Each online friend listed is hyperlinked back the the email composer with that friends ID pre posted. The plugin show users as active (5 minutes) and inactive (10 minutes) variations .

myfriends-1.0.tar

Here is a plugin for ELGG community web framework created to popout from side of browser and show your active friends by name and picture. Each online friend listed is hyperlinked back the the email composer with that friends ID pre posted. The plugin show users as active (5 minutes) and inactive (10 minutes) variations .

myfriends-1.0.tar

Howto Install ImageMagick and PHP imagick extension on CentOS 5

Howto install imagemagick and PHP imagick extension on Linux CentOS 5 LAMP server. It is pretty simple really

yum install ImageMagick.i386
yum install ImageMagick-devel.i386
pecl install imagick

After the installation, create an inclusion file in your /etc/php.d directory for imagick.so module and then restart apache daemon:

echo “extension=imagick.so” > /etc/php.d/imagick.ini
/etc/init.d/httpd restart

Test the loading of the module by running:

php -m | grep imagick

Howto install imagemagick and PHP imagick extension on Linux CentOS 5 LAMP server. It is pretty simple really

yum install ImageMagick.i386
yum install ImageMagick-devel.i386
pecl install imagick

After the installation, create an inclusion file in your /etc/php.d directory for imagick.so module and then restart apache daemon:

echo "extension=imagick.so" > /etc/php.d/imagick.ini
/etc/init.d/httpd restart

Test the loading of the module by running:

php -m | grep imagick

Howto: MySQL Full Text Search in PHP

This tutorial is intended for Text Searching using MySQL (http://www.MySQL.com/) and PHP (http://www.php.net) and will focus on the Full-text capabilities presented by MySQL.

Synopsis

We run a website that hosts web blogs, we have a database that contains blog posts. We might create a table in our database using a statement like this:

CREATE TABLE blogs (body TEXT, title VARCHAR(250), id INT NOT NULL auto_increment, PRIMARY KEY(id);
 

This tutorial is intended for Text Searching using MySQL (http://www.MySQL.com/) and PHP (http://www.php.net) and will focus on the Full-text capabilities presented by MySQL.

Synopsis

We run a website that hosts web blogs, we have a database that contains blog posts. We might create a table in our database using a statement like this:

CREATE TABLE blogs (body TEXT, title VARCHAR(250), id INT NOT NULL auto_increment, PRIMARY KEY(id);
 
 
 
 
 

 

How to modify your current database to accommodate Full-text searching.

Now we want to provide a simple search form and the ability to search keywords from the body field in the table “blog” of your database. First you will need to turn on Full Text Search for the table “blog” in your MySql database. Here is how to do that in MySql.

ALTER TABLE blog ADD FULLTEXT(body, title);

How to use a simple Full-text search to quickly gather relevant responses.

Lets create our PHP form and database query to support our search. I normally create a single php file called “search.php” then I “include(“search.php”)” where ever I want my search form and returning search data go but I can see where you may want to split this up and have the form and returning data in different areas so change as you see fit.

search.php
<?php
$keyword = $_POST[‘keyword’];
//we will assume your including this search in your index.php
//if not replace index wiht search.php or any page your going to do the sql query and display
//from.
?>
<h2>Search Our Archives</h2>
<form action=”index.php” enctype=”application/x-www-form-urlencoded” method=”post”>
<input name=”keyword” type=”text” />
<input type=”submit” value=”Search” />
</form>
<br>
<?php
if ($keyword != ”) {

        mysql_connect(“localhost”, “username”, “password”);

        mysql_select_db(“database_name”);

        $sql = ”
            SELECT body,
                MATCH(body) AGAINST(‘$keyword’) AS score
                FROM blog
            WHERE MATCH(body) AGAINST(‘$keyword’)
            ORDER BY score DESC
        “;
        $myresult = mysql_query($sql);
            while($row = mysql_fetch_array($myresult)) {
                echo “<table border=”0″><tbody><tr>”;
                echo “<td>Search – SCORE</td><td>Content</td></tr>”;
                echo “<tr><td><strong>” . $row[‘score’] . “</strong></td>”;
                echo “<td>” . $row[‘body’] . “</td></tr>”;
                echo “</tbody></table>”;
            }
    }
?>

This search.php makes a quick and easy Full Test Search form and display for the data. It checks $keywords to validate data before displaying the data in a table. It includes the MySQL score returned by the Full Text Search. I hope this helps someone out there get a search up and running fast.

Enjoy..

Remove CRLF from windows PHP files.

I have had a few guys ask me, Shannon I have a Windows guy developing web aps in PHP but I run them on a Linux (LAMP) system. Some times the code seems to fail and I find the files populated with Carrage Return Line Feed or better seen while looking at a windows file on a linux system in a text editor ( ^M ). This has been know

I have had a few guys ask me, Shannon I have a Windows guy developing web aps in PHP but I run them on a Linux (LAMP) system. Some times the code seems to fail and I find the files populated with Carrage Return Line Feed or better seen while looking at a windows file on a linux system in a text editor ( ^M ). This has been know to have adverse effects on LAMP systems at times and could cause web errors.

Great we now know the why.. How do we fix it?

Simple, Linux provides the program to review a file and make the mods and we can the loop it through a directory to do all files. Here is the cmd you want to use.
find (path to top level folder) -type f -exec dos2unix {} \;

We use the program “find” to get and pipe our files to the cmd dos2unix which is the program that is actually doing the repairs. We use both programs together to produce the desired effect of removing all CRLF from a directory of windows files like a php website.

Remember always backup your files first, be safe.