Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
JR Dalrymple
/
check_citrix_user
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ed9a88ec
authored
Oct 28, 2015
by
JR Dalrymple
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This kind of works
parent
b98184a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
6 deletions
+39
-6
check_citrix_user.ps1
+39
-6
No files found.
check_citrix_user.ps1
View file @
ed9a88ec
...
...
@@ -11,19 +11,52 @@
#
#################################################################################
if
(
(
Get-PSSnapin
-Name Citrix.XenApp.Commands -ErrorAction SilentlyContinue
)
-eq
$null
)
{
Add-PSSnapin
Citrix.XenApp.Commands
$nscpBinary
=
"c:\program files\NSClient++\nscp.exe"
$returnCode
=
"3"
#Unknown by default
$nagiosHost
=
"mn-lx9.gsellc.local"
# this is the host running the NSCA daemon
$encryption
=
"3des"
# set this to match nsca.cfg on the Nagios host
$payloadLength
=
"4096"
# set this to match your nsca daemon, the default is 512
$nscaPassword
=
"somepassword"
# set this to match nsca.cfg on the Nagios host
$sourceHost
=
"CitrixFarm"
# This needs to match the host you have configured in Nagios for these passive checks
$userStringArray
=
@
()
function
nagiosExit
(
$returnCode
,
$statusOutput
)
{
Write-Host
$statusOutput
Exit
$returnCode
}
function
sendNscaExit
(
$returnCode
,
$statusoutput
)
{
}
if
(
(
Get-PSSnapin
-Name Citrix.XenApp.Commands -ErrorAction SilentlyContinue
)
-eq
$null
)
{
Add-PSSnapin
-Name Citrix.XenApp.Commands -ErrorAction SilentlyContinue
if
(
(
Get-PSSnapin
-Name Citrix.XenApp.Commands -ErrorAction SilentlyContinue
)
-eq
$null
)
{
nagiosExit
"2"
"Unable to load necessary Citrix PowerShell Snapins"
}
}
$sendNscaBinary
=
$loggedOnUsers
=
$returnCode
=
3
#Unknown by default
$loggedOnUsers
=
Get-XASession -full |
where-object
{
(
$_
.ApplicationState -eq
'Active'
)
}
|
select
AccountName
function
sendNscaExit
(
$returnCode
,
$statusoutput
)
{
}
foreach
(
$user
in
$loggedOnUsers
)
{
$userString
=
$user
.AccountName
$userStringArray
+
=
$userString
-replace
'^.*\\'
,
''
}
$userStringArray
=
$userStringArray
|
Select
-Unique
foreach
(
$user
in
$userStringArray
)
{
$nscpArgs
=
@
(
"nsca"
,
"host=
$nagiosHost
"
,
"command=
$user
"
,
"message=user
$user
is currently online"
,
"result=OK"
,
"encryption=
$encryption
"
,
"payload-length=
$payloadLength
"
,
"password=
$nscaPassword
"
,
"source-host=
$sourceHost
"
)
&
$nscpBinary
$nscpArgs
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment