In some times you want to receive notifications from grafana only in working hours. You may configure quiet hours, but in this case grafana show status as unhealthy, just not notifying you.

It’s possible to set hours, when alerts actually present and should be sent.

Just add new prometheus condition with code (time in UTC):

((hour() >= 9) * (hour() <= 18)) OR on() vector(0)

This expression returns 81 at 9:00-9:59, 100 at 10:00-10:59 etc between 9:00 and 18:00 (6 p.m.).

And add condition for this expression >0

First condition – original value expression, second – time interval.

 1,562 total views

How to downgrade MS SQL database we can find from web-search. Its discribe simple method – use “Tasks – Generate Scripts…” with data and Win!

standard downgrade method

But! If you have huge database’s size, you cannot use that method. For example: My 10 Gb database, have exported size – 50 Gb. No one text editor can handle this size of plane text file, including command-line import (because its import data from text file line by line and some data cannot be inserted in buffer).

Here is article to help you downgrade huge database in “simple” way.

Continue reading

 390 total views

To change Remote Desktop certificate in Windows Server 2012R2 you need to do two steps:

Step 1. Get thumbprint of certificate (the name of certificate must be equal of server connection name). It possible from mmc.exe console (add certificates snap-in from computer account and view certificate in personal folder). Copy thumbprint without spaces and special symbol in start of line.

Step 2. Assign certificate from powershell:

$path = (Get-WmiObject -class “Win32_TSGeneralSetting” -Namespace rootcimv2terminalservices -Filter “TerminalName=’RDP-tcp'”).__path
Set-WmiInstance -Path $path -argument @{SSLCertificateSHA1Hash=”THUMBPRINT”} ## in THUMBPRINT pole add value from step 1.


 440 total views

You can compress files and folders from PowerShell without installing third-party application (required .NET Framework 4.5):

[System.IO.Compression.ZipFile]::CreateFromDirectory(“$Source”, “$Archive”)

Here the function listing to use compression easy:

function Add-Zip ($Source, $Archive){
Compression function

Native compression with latest .NET 4.5 framework

Source file or directory for compression

Archive file name [with path]

————————– EXAMPLE  —————————
Add-Zip -Source C:Temp -Archive

Compress C:temp folder to archive

If (-Not $Source -or -Not $Archive) {
Write-Host ‘One parameter is missing’
} else {
Add-Type -Assembly “System.IO.Compression.FileSystem” ;
[System.IO.Compression.ZipFile]::CreateFromDirectory(“$Source”, “$Archive”) ;

 391 total views

You can generate ssh private and public keys to use in ssh connection with puttygen (can be downloaded from link).

Step 1. Open puttygen, choose ‘ssh-2 rsa’ or ‘ssh2 dsa’ and push ‘Generete’ button (move mouse in ‘key’ area).

Step 2. Push ‘save private key’ to save keyfile (you can set password to protect private key).

Step 3. Save text from ‘public key for pasting into OpenSSH authorized_keys file’:

Step 4. Login to remote Linux server (presumably OpenSSH server already installed). Note: lately with this username you should connect with SSH.

Step 5. Create .ssh folder (mkdir ~/.ssh) and change permissions (chmod 700 ~/.ssh).

Step 6. Create file authorized_keys2 in .ssh folder and paste information from ‘Step 3’ into it (your_favorite_editor ~/.ssh/authorized_keys2).

Step 7. Configuring PuTTY:

  • Enter hosthame of remote server in ‘Session’ category.
  • In ‘Data – Connection – Auto-login username’ enter username that used in Sstep 4’.
  • In ‘Connection – SSH – Auth – Private key file for authentication’ put fullpath to file saved in ‘Step 2’.
  • You can save this settings in ‘Session’ category and push ‘Open’ (Note: if you set private key password at this time you should enter it, else putty connect to remote server with private/public key pairs).

Author: Andrey Makovetsky

 399 total views

Some times RRAS can`t route traffic from VPN clients to internal network after server restart. You can create startup script to re-apply RRAS config at startup to restore correct functionality of RRAS server.

You need previously export “clean” RRAS config (when RRAS not configured) by running “netsh dump” at command promt and save this listing to file (for example C:rras_clean_config.txt). Then configure RRAS as need and export config again (for example to C:rras_work_config.txt).

At last create command file (for exampe C:rras_reset_config.cmd) with next commands and configure start this script at server startup with admin rights:

:: Disable RRAS settings
netsh exec rras_clean_config.txt
:: Set RRAS auto startup type
sc config RemoteAccess start= auto
:: Stop RRAS (if started)
net stop RemoteAccess
:: Apply RRAS work settings
netsh exec rras_work_config.txt
:: Set RRAS auto startup type
sc config RemoteAccess start= auto
:: Start RRAS
net start RemoteAccess

Note: You should put thees three files to one folder.

 509 total views