Tuesday, February 15, 2011

Darth Monitor

spacer

Thursday, December 2, 2010

A syslog priority matrix

This table works out the syslog priority (PRI) field for all facilities and severity according to RFC 3164.




Severity









0 1 2 3 4 5 6 7
Facility kernel 0 0 1 2 3 4 5 6 7

user 1 8 9 10 11 12 13 14 15

mail 2 16 17 18 19 20 21 22 23

system 3 24 25 26 27 28 29 30 31

security 4 32 33 34 35 36 37 38 39

syslog 5 40 41 42 43 44 45 46 47

lpd 6 48 49 50 51 52 53 54 55

nntp 7 56 57 58 59 60 61 62 63

uucp 8 64 65 66 67 68 69 70 71

time 9 72 73 74 75 76 77 78 79

security 10 80 81 82 83 84 85 86 87

ftpd 11 88 89 90 91 92 93 94 95

ntpd 12 96 97 98 99 100 101 102 103

logaudit 13 104 105 106 107 108 109 110 111

logalert 14 112 113 114 115 116 117 118 119

clock 15 120 121 122 123 124 125 126 127

local0 16 128 129 130 131 132 133 134 135

local1 17 136 137 138 139 140 141 142 143

local2 18 144 145 146 147 148 149 150 151

local3 19 152 153 154 155 156 157 158 159

local4 20 160 161 162 163 164 165 166 167

local5 21 168 169 170 171 172 173 174 175

local6 22 176 177 178 179 180 181 182 183

local7 23 184 185 186 187 188 189 190 191

spacer
This work is licensed under a Creative Commons Attribution 3.0 Unported License.

Monday, November 8, 2010

Fix or Customize Your WinEdt Toolbar Buttons

Watch the screencast.

Friday, November 5, 2010

Mac OS X Login and Logout Scripts Demystified

spacer

Before You Begin

There are some things one must understand about Mac OS X login scripts before you can begin:
  • Apple refers to them as login- and logout- “hooks”.
  • They run as root so you need to su as the user to take actions as the user.
  • You must activate them with the defaults command or use Workgroup Manager in Open Directory.

Creating a Login Script

You can technically save your scripts anywhere on the filesystem, but /usr/local/bin makes a lot of sense for various reasons.
So, create a file there and mark it executable:
sudo touch /usr/local/bin/login
sudo chmod +x /usr/local/bin/login

Configuring Login Script Actions

Open the login script in your favorite editor:
sudo vi /usr/local/bin/login
Inside the script, you can do things as root or as the user as shown in this sample batch script:
#!/bin/bash

##
# Mac login script
##

# As root, create a directory named "/foo"
mkdir /foo

# As root, set or enforce system settings
defaults write ... 

# As the user, create a directory named "~/foo"
su - $1 -c "/bin/mkdir -p ~/foo"

# As the user, set or enforce user settings
su - $1 -c "/usr/bin/defaults write ..."
The username is passed to the script as the one (and only) argument. In bash, you can use the $1 variable to access the username.

Activating a Login Script

Run this to activate the script:
sudo defaults write com.apple.loginwindow LoginHook /usr/local/bin/login

Logout Scripts

Configure a logout script by following the instructions above then activate it as follows:
sudo defaults write com.apple.loginwindow LogoutHook /usr/local/bin/logout
 
This content is published under the Attribution 3.0 Unported license.

Wednesday, October 27, 2010

Run a WMI VBScript Fast Against All Computers in an OU

This sample WMI VBScript code demonstrates how to use net use instead of pinging to decrease script execution time and increase accuracy when run against multiple computers. This particular script lists the currently logged-on user on each computer in the OU.
On Error Resume Next

Set objOU    = GetObject("LDAP://OU=Accounting,dc=example,dc=com")
objOU.Filter = Array("Computer")

For Each objComputer in objOU
    strComputer = objComputer.CN

    Wscript.StdOut.Write strComputer

    Set objShell = CreateObject("WScript.Shell")
    strCommand   = "net use \\" & strComputer
    Return       = objShell.Run(strCommand,0,True)
    If Return = 0 Then

        ' Insert your code here

        On Error Resume Next

        Const wbemFlagReturnImmediately =  &h10
        Const wbemFlagForwardOnly =  &h20

        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
        Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _
        wbemFlagReturnImmediately + wbemFlagForwardOnly)

        For Each objItem In colItems
            WScript.StdOut.WriteLine vbTab & objItem.UserName
        Next

        ' End

    Else
        Wscript.StdOut.WriteLine vbTab & "NETWORK ERROR"
    End If

Next

This content is published under the Attribution 3.0 Unported license.
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.