Используйте Nagios для контроля уровней тонера локальных принтеров USB

Fortinet является просто сервером VPN IPSEC - Вам конкретно не нужен их клиент для соединения с нею. ПРАКТИЧЕСКОЕ РУКОВОДСТВО IPSEC подробно излагает список различных вариантов, которые Вы имеете для установки клиента VPN Linux. Существуют также некоторые коммерческий Linux клиенты IPSec, такие как Shrewsoft.

2
задан 29 February 2012 в 01:53
1 ответ

A PowerShell script like this should do the trick. This can be called via Nagios and will return an exit code of 0 and "OK: All printers are normal" or an exit code of 2 and information about the printer(s) that have a problem.

#Initialize variables
$nagiosStatus = "0"
$nagiosDescription = ""
$detectedErrorStateDescriptions = New-Object string[] 12

#Assign error state descriptions - see http://msdn.microsoft.com/en-us/library/windows/desktop/aa394363(v=vs.85).aspx
$detectedErrorStateDescriptions[0] = "Unknown"
$detectedErrorStateDescriptions[1] = "Other"
$detectedErrorStateDescriptions[2] = "No Error"
$detectedErrorStateDescriptions[3] = "Low Paper"
$detectedErrorStateDescriptions[4] = "No Paper"
$detectedErrorStateDescriptions[5] = "Low Toner"
$detectedErrorStateDescriptions[6] = "No Toner"
$detectedErrorStateDescriptions[7] = "Door Open"
$detectedErrorStateDescriptions[8] = "Jammed"
$detectedErrorStateDescriptions[9] = "Offline"
$detectedErrorStateDescriptions[10] = "Service Requested"
$detectedErrorStateDescriptions[11] = "Output Bin Full"

#Check the status of each printer on the system
ForEach ( $printer in ( Get-WmiObject win32_printer ) ) {
    If ( ( $printer.DetectedErrorState -ne "0" ) -and ( $printer.DetectedErrorState -ne "2" ) ) {
        $nagiosStatus = "2"
        If ($nagiosDescription -ne "") {
            $nagiosDescription = $nagiosDescription + ", "
        }
        $nagiosDescription = $nagiosDescription + $printer.Name + ":" + $detectedErrorStateDescriptions[$printer.DetectedErrorState]
    }
}

#Output the status
If ( $nagiosStatus -eq "2" ) {
    Write-Host "CRITICAL: " $nagiosDescription
}
Else {
    Write-Host "OK: All printers are normal"
}

exit $nagiosStatus

I do not have a Nagios installation available to me for testing at the moment, but this is modified from another PowerShell script that I used to use with Nagios.

See http://msdn.microsoft.com/en-us/library/windows/desktop/aa394363(v=vs.85).aspx for further information about possible information you can get from the win32_printer WMI object.

9
ответ дан 3 December 2019 в 08:47

Теги

Похожие вопросы