Thứ Sáu, 23 tháng 5, 2014

Cannot find registry resource for Application ID

Cannot find registry resource for Application ID

This error is shown when you access an application link in the 'Applications' tab in Parallels Plesk Panel:
Internal error: Can not find registry resource for Application ID fbea5fe0-7e00-42fb-9fa0-e4fd2e664f8b
Can not find registry resource for Application ID fbea5fe0-7e00-42fb-9fa0-e4fd2e664f8b
Resolution

1.Check there is an aps_registry_object record for this application ID:
mysql> select * from aps_registry_object where uid='fbea5fe0-7e00-42fb-9fa0-e4fd2e664f8b';
Empty set (0.00 sec)
2.Check for this application in the PSA database:
mysql> select * from apsContextsApplications where registryApplicationId='fbea5fe0-7e00-42fb-9fa0-e4fd2e664f8b';
+----+--------------+--------------------------------------+
| id | apsContextId | registryApplicationId                |
+----+--------------+--------------------------------------+
| 19 |           17 | fbea5fe0-7e00-42fb-9fa0-e4fd2e664f8b |
+----+--------------+--------------------------------------+

mysql> select * from apsContexts where id=17;
+----+-----------+---------+-------+----------------+
| id | pleskType | pleskId | ssl   | subscriptionId |
+----+-----------+---------+-------+----------------+
| 17 | hosting   |     530 | false |            527 |
+----+-----------+---------+-------+----------------+

mysql> select name from domains where id=530;
+-------------------+
| name              |
+-------------------+
|    domain.tld     |
+-------------------+
In the above example, records show for the broken application and its corresponding domain. 
3. Remove inconsistent records from PSA database:
mysql> delete from apsContexts where id=17;
mysql> delete from apsContextsApplications where apsContextId=17;
Read More

Thứ Hai, 19 tháng 5, 2014

Exim Commands

Exim Commands

Debug a mail delivery:
 /usr/sbin/exim -bt -d email@address.com
Retry message delivery:
 /usr/sbin/exim -M messageID
Force delivery of all message:
 /usr/sbin/exim -qf
Force delivery of all message and delete of frozen ones:
 /usr/sbin/exim -qff
Shows log delivery for a message:
 /usr/sbin/exim -Mvl messageID
Display message body:
 /usr/sbin/exim -Mvb messageID
Display message header:
 /usr/sbin/exim -Mvh messageID
Delete a message without warning:
 /usr/sbin/exim -Mrm messageID
Count messages in queue:
 /usr/sbin/exim -bpr | grep "<" | wc -l or /usr/sbin/exim -bpc
Display all messages from queue:
 /usr/sbin/exim -bp
Count frozen messages:
 /usr/sbin/exim -bpr | grep frozen | wc -l
Delete frozen messages:
 /usr/sbin/exim -bpr | grep frozen | awk '{print $3}' | xargs /usr/sbin/exim -Mrm

Read More

Check how much memory your PHP script is using

Check how much memory your PHP script is using?


The answer is the memory_get_peak_usage() function.

At the end of your PHP script (footer script for a PHP site, you get the idea), put this line:
echo memory_get_peak_usage();
Or you can write the data down in a text file:
file_put_contents('mu.txt', memory_get_peak_usage());
The output is in bytes.More friendly output,Add to the footer of the templates:
<?php
function convert($size) {
   $unit=array('b','kb','mb','gb','tb','pb');
   return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
}
echo convert(memory_get_peak_usage(true));
?>
Read More

How to run a stored procedure in sql server every hour

How to run a stored procedure in sql server every hour

Following step bellow:

In SQL Server Management Studio navigate to SQL Server Agent-->Jobs Right click on the Job Folder and select new job

On the dialog that pops up, give the job a name click on steps, then on new, you will see a dialog like the following, pick correct DB and type your proc name


after that click on schedule, pick new and you will see something like the image below, fill all the stuff you need and click ok, click ok on the job and you should be set



Read More

Chủ Nhật, 18 tháng 5, 2014

Mysql change the default character set and collation of a table

Mysql change the default character set and collation of a table

To change the default character set and collation of a table including those of existing columns (note the convert to clause):
alter table convert to character set utf8 collate utf8_general_ci;

Note: You can't alter multiple tables at once in mysql, just write a query file to alter all tables and execute that file.
Read More

SQL SERVER – Find Row Count in Table – Find Largest Table in Database

SQL SERVER – Find Row Count in Table – Find Largest Table in Database

How many rows are there in any particular table?
This script will gives row number for every table in database.

USE AdventureWorks
GO
SELECT OBJECT_NAME(OBJECT_ID) TableName, st.row_count
FROM sys.dm_db_partition_stats st
WHERE index_id < 2
ORDER BY st.row_count DESC
GO


Read More

Thứ Sáu, 16 tháng 5, 2014

Disable exim email on single cPanel Account

Disable exim email on single cPanel Account 

A week ago one of our clients account been compromised and the attacker used the server to blast emails.
as a system administrator my task was to prevent any outgoing email from the account before I start to investigate the attack and remove any kind of scripts from the hosting account.

Studying cPanel files made me to come around following solution.
To disable email for one account we can change the permission of /etc directory for that particular user, using our root power simply use following commands:
chmod 0 /home/username/etc
chattr +ia /home/username/etc
You need to replace username with your user username. Once this is done the user will not be able to send anymore emails from local server. To undo this you should run the chattr once more:
chattr -ia /home/username/etc
chmod 750 /home/username/etc
Read More