Feeds:
Posts
Comments

Archive for the ‘DOS’ Category

Searched high and low for a command to get CPU usage on the internet to no avail. From a DOS command prompt (Windows server 2003) CPU usage for all nodes:

WMIC CPU GET LoadPercentage

SNMP was my other alternative, but not all deployments would have this service.

This does not aggregate the values, nor does it easily feed into a batch file. For that I use a FOR loop.

FOR /F "delims= " %%i in ('WMIC CPU GET LoadPercentage') do @echo %%i
Advertisements

Read Full Post »

psql via command line does not have an option for password. To run a scheduled task using psql is pointless without full automation.

Warning postgres recommends against doing this, and instead use a password file.

I use this script to kick off the psql command in python. But you can execute psql straight from the batch file, just check the %ERRORLEVEL% batch variable from the calling method.

@echo off

REM scheduled task point to .bat files
REM besides we need to make sure we have system variables in place

REM export a password for use with the system (no quotes)
SET PGHOST=host
SET PGDATABASE=database
SET PGUSER=user
SET PGPASSWORD=user

REM execute psql by file, even though echo is off, errors will still show
psql -X --variable=ON_ERROR_STOP= -1 -w -f filename.sql

Read Full Post »

%d bloggers like this: