MSSQL Table Reindex
Use this single line command to re-index every table in a Microsoft SQL Server database:
EXEC sp_msForEachTable
@COMMAND1 = 'DBCC DBREINDEX ("?")'
Use this single line command to re-index every table in a Microsoft SQL Server database:
EXEC sp_msForEachTable
@COMMAND1 = 'DBCC DBREINDEX ("?")'
We use an open source software package called GLPI to track our equipment and the trouble tickets associated with them. A while back I had built a ASP.net front end for our end users to enter their own trouble tickets. Since the database is populated with every computer, printer and phone in the company there was a simple little interface that allowed them to select a radio button for say printer and then a drop down box would appear with all the printers in the company with the printer’s location for them to select the printer that is having the issue.
The problem came into the fact that I thought people would be conscientious enough to actually select the device that was actually having the problem. This was not the case. Instead all the trouble tickets were being generated for the first piece of equipment in the corresponding list. A bit frustrating as we would then have to drop into the database and change the association between the ticket to the correct equipment.
This needed to stop so here is how I did it.
First off I changed the SQL query to add one more select option to the top of the list of options they could choose from. For the printers the query now looked like this for the printers:
SELECT * FROM
(SELECT id,
CONCAT(name,' { ',comments,' } ') AS name
FROM glpi_printers
WHERE deleted = 0
AND is_template = 0
AND name <> 'shelf'
UNION ALL
SELECT 0,
'--SELECT A PRINTER--'
) as t1
ORDER BY
name;
This now adds the option –SELECT A PRINTER—at the top of the list with an ID value of 0.
Next I add a CompareValidator control to the drop down list that displays the equipment listing.
<asp:CompareValidator ID="cvDevice" runat="server" ControlToValidate="ddlSelectedDevice" ValueToCompare="0" type="Integer" operator="GreaterThan" ErrorMessage="<br /><strong>You must select a valid device for support!</strong>" display="Dynamic" SetFocusOnError="True" />
Now when they create a ticket if they skip over the dropdown list for the equipment, they will get a message telling them to select a valid device. While this does not guarantee that they will actually choose the equipment that is in need of support, I have a better chance at getting the correct equipment selected.
Working on an intranet app and was trying to get a javascript function to run onchange of a drop down box. We use IE7 as our standard web browser so as I was testing it I kept getting this message stating “Object doesn’t support this property or method”. Kept limiting my javascript function to I finally just had an alert(“TEST”) that wouldn’t even work.
I was calling the function medicalPlan and it related to an form with an id=”medicalPlan”. Apparently there is a problem if you call a javascript function with the same name as the form element’s id. As soon as a renamed the function everything worked as you would expect it to.
I have Comcast for my home internet connection and I have the 16Mb pipe. The cable modem and wireless router sit in the basement and we normally work from the main floor. The problem is that I am not seeing any speed at all on my connection. And by no speed I mean 3Mb down and 400k upload.
If I go straight from the cable modem to my laptop I get over 20Mb down and 1.5Mb up. Crap that kind of points to the router as my problem. It is a Linksys router running the OpenWRT. The reason I am using this firmware instead of the stock is that I wanted to get rid of my internal servers to save power and the last service I needed to provide was internal DNS. OpenWRT gives me that ability. Since I have no other routers anymore to try out, I can either downgrade the firmware to the stock release from Linksys or buy a new router and see what kind of speed I get there.
Arrrrgggggghhhhhh!!!!!!!
UPDATE
So running some tests all through the same router with the same OpenWRT software build on the router.
I have two laptops I am testing with and here are the results:
HP Pavilion ZV5000
Wireless speed: 6Mb
Wired speed: 13Mb
MacBook Pro
Wireless speed: 4Mb
Wired speed: 13Mb
The uploads were all around the 400K speed.
Looks like I need to find a way to tweak the wireless speeds and the upload speeds.
UPDATE #2
On the router I disable the G-Mode Protection settings.
HP Pavilion ZV5000 now at 7Mb
MacBook Pro now at 10Mb
UPDATE #3
Now on the router I have set it to only G mode and got rid B settings.
HP Pavilion ZV5000 no at 9Mb
MacBook Pro now at 11Mb
Don’t think I have any more B mode devices anymore, but that could be an issue if I come across a long forgotten device.
UPDATE #4
Got my uploads figured out now. No longer capped at 400k I am now getting 1.5Mb uploads.
Apparently even though the QoS Service is disabled, there is a setting called QoS Overhead Calculation which by default is on. Once this setting is also disabled, everything uploads quickly.
After all this I kind of feel bad for gripping at the Comcast people on the phone when it was not them that hosed the connection. {blushes} I hate being that jerk.
One of the cool features of FireFox for the linguistics challenged like me is that it will spell check items in a textarea of a web page. If you misspell it, there is little red line that shows under the word and you can right mouse click on it and select the correct spelling of that word. The problems for me is that I get a little too quick on my clicking and from time to time, select the Add To Dictionary option which is directly under the list of other options for the word you misspelled.
To clear the word from the custom dictionary you need to find the persdict.dat and open it in a text editor and removed the wrong entry. On Windows XP you will find it in C:\Documents and Settings\username\Application Data\Mozilla\Firefox\Profiles\unique.default And on Mac OS X it is located at /Library/Application Support/Firefox/Profiles/unique.default
MySQL has a cool command called
SHOW TABLES;
which will list out all the tables in the current database.
I wanted the same ability in Microsoft SQL Server. To get the same info you would issue
SELECT NAME
FROM {databasename}..sysobjects
WHERE xtype = 'U'
Replace {databasename} with your database.
There has been a link at the top of the admin page of this site for a little while. I run it on WordPress and it is telling me there is an upgrade available. Usually this means I pull down the tar ball, unpack it and usually overwrite some file I really wanted to keep. By the time I get to the last site that I manage it usually goes much smoother but about an hour of my life is gone. So tonight I see that it had a button that said upgrade automatically. After doing a quick upgrade, I clicked the button. Moments later, it says it is completed and check the site and everything is cool.
This is nice!
UPDATE
Apparently this is the only site that will upgrade automatically. It failed on all the others. {sigh}
I have never really done much with PHP. I do very little coding and when I do it has always been a Microsoft centric language. For whatever reason, it can’t be boredom I have too much to be doing, this weekend I started fiddling around with PHP. I am actually working through a PHP tutorial so I actually learn the correct ways to use the language instead of just mashing things together like I have done in the past.
Not sure if it is the procedure or the documentation that I am using but it seems to be a very easy language with incredible power available to use. At this point I have only worked through operators, arrays and loops but I have been impressed with the little bit that I have done with it. I am curious once I get to the point of pulling data from a MySQL database and that should be fun.
I have no idea what I am going to do with this knowledge, we use ASP and ASP.net at work.
Ok so about a year ago I was fretting over the idea that MySQL was now owned buy Sun and I actually said, “…Worse of all is if Oracle had purchased them, we would never see another MySQL product again same with IBM.” Uhm yeah, well the news comes out today that Oracle is buying Sun and there by owns MySQL now too.
Interesting.
These instruction are for setting up rsyslog and phpLogCon on CentOS 5.3. It is assumed you have a working Apache and MySQL setup. Configuration of these two packages are outside the realm of this document.
On the Linux server I wanted to host the rsyslog database I ran yum install -y rsyslog-mysql on my CentOS 5.3 machine. Once installed went to the path of cd /usr/share/doc/rsyslog-mysql-2.0.6/. In this location you will see a file called createDB.sql which is the scheme needed to make using phpLogCon easy to use. To create this database type mysql -u MySQLusername -p < createDB.sql You will be prompted for a password for the account you entered and then the database will be created.
Edit the /etc/rsyslog.conf file to add in the mysql connection information at the top of the config file. I am using FROMHOST instead of HOSTNAME as I wasn't getting any hostnames with the former.
$ModLoad ommysql.so
$template dbFormat,”insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values (‘%msg%’, %syslogfacility%, ‘%FROMHOST%’, %syslogpriority%, ‘%timereported:::date-mysql%’, ‘%timegenerated:::date-mysql%’, %iut%, ‘%syslogtag%’)”,sql
*.* : ommysql:192.168.1.100,Syslog,MySQLusername,MySQLpassword;dbFormat
Stop the normal syslog daemon
service syslog stop
And set it to never come on
chkconfig syslog off
Set rsyslog to start at boot
chkconfig rsyslog on
And then start the service
service rsyslog start
You should now have messages showing in your MySQL database. If you do not check the /var/log/messages to see if there is an error in your rsyslog.conf file.
Once you are sure you are getting messages in your database you can use the phpLogCon application to have a nice web interface over the top of the database. Download from http://www.phplogcon.org/, I am using version 2.6.2 for this tutorial. Once downloaded unpack it and move the src directory to the web server path mv src /var/www/html/phplogcon Out of the contrib directory copy both the configure.sh and secure.sh to /var/www/html/phplogcon. Change to the web directory cd /var/www/html/phplogcon and then run the configure script by typing ./configure.sh Open a web browser and enter the path to this site http://servername/phplogcon to start the configuration of the site. Click NEXT until you get to Step 7 and make sure the source type is MySQL, the Database Name is Syslog and the table name is SystemEvents and then enter your MySQL username and password. You now have a function phpLogCon page.
On the Linux clients make sure you install the rsyslog-mysql module the same way you did on the server by typing yum install -y rsyslog-mysql
Edit the /etc/rsyslog.conf file to add in the mysql connection information at the top of the config file.
$ModLoad ommysql.so
$template dbFormat,"insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values ('%msg%', %syslogfacility%, '%FROMHOST%', %syslogpriority%, '%timereported:::date-mysql%', '%timegenerated:::date-mysql%', %iut%, '%syslogtag%')",sql
*.* : ommysql:192.168.1.100,Syslog,MySQLusername,MySQLpassword;dbFormat
Stop the normal syslog daemon
service syslog stop
And set it to never come on
chkconfig syslog off
Set rsyslog to start at boot
chkconfig rsyslog on
And then start the service
service rsyslog start
Refresh your phpLogCon web page and you will now see two entries from the Linux client, one is a kernel message the other is a syslog message.
Anything that has a syslog capability can now point to the rsyslog server, such as HP JetDirect cards and Cisco network gear. All the messages are available in one location and you can filter and search for issues on your network.