- Community Home
- >
- Storage
- >
- HPE SimpliVity
- >
- Automate dsv-balance-show
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 11:30 AM - last edited on 08-16-2022 10:20 AM by support_s
08-11-2022 11:30 AM - last edited on 08-16-2022 10:20 AM by support_s
Automate dsv-balance-show
Hello,
I've scripted the dsv-balance-show command to email me the results. The issue I'm having is that when i use a cronjob to run the script it does not work.
Is there anything about the dsv-balance-show command that wont run in a cronjob?
This is the line that effectively does nothing:
source /var/tmp/build/bin/appsetup;dsv-balance-show >> /data/drivespace.txt
Runs fine if I manually execute the script and the rest of the script executes fine as well in the cronjob.
Thanks,
Ernst.
- Tags:
- SimpliVity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2022 09:59 AM
08-12-2022 09:59 AM
Re: Automate dsv-balance-show
Hi Ernst
Hope you are doing well.!!
Most likely a permissions issue. dsv commands require sudo/root level permissions.
may I request you to try with sudo/root level permissions.
Hope this helps.!!
Regards
Mahesh.
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2022 10:08 AM
08-12-2022 10:08 AM
Re: Automate dsv-balance-show
Hi Mahesh,
I thought as much so I've tried not only in the users cron job but also root's. /etc/crontab
The script runs and creates the output file but does not contain the drive space data.
Thanks,
Ernst.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2022 11:31 AM
08-12-2022 11:31 AM
Re: Automate dsv-balance-show
So not sure if this helps at all...
I added loging and this is what I get:
Error:(47), Caller:48 /etc/drivespace.sh, Command:dsv-balance-show >> /kens/drivespace.txt
Not sure what error 47 means as it looks up as 'Level 3 reset'
Thanks,
Ernst.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 04:55 AM
08-16-2022 04:55 AM
Re: Automate dsv-balance-show
The sequence of commands should be:
sudo su
source /var/tmp/build/bin/appsetup
dsv-balance-show
Is this how you are executing it?
I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 05:31 AM
08-16-2022 05:31 AM
Re: Automate dsv-balance-show
Hi Gustenar,
So I'm running the script as root so the sudo su shouldnt be needed.
The rest is correct.
I have since moved on and completed the task a diferen . I'm now running the automation via powershell instead of from the linux machine.
I now have the output needed.
Thanks,
Ernst.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 10:53 PM
08-24-2022 10:53 PM
Re: Automate dsv-balance-show
Hi Ibehere
Your PowerShell solution sounds interesting, coul;d you share an example of your script please
Paul747
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 05:11 AM
08-25-2022 05:11 AM
Re: Automate dsv-balance-show
Hi Paul,
Of course... so the workflow is 2 parts. A Bash script on the appliance and powershell script on the windows box. The powershell script has 3 requirements.
An installation of Putty, Posh-SSH module installed, and a set of cached creds for use on the appliance. (not best practice)
Appologies as I'm not the best scripter but this works for me.
All thats left is to execute the function on a schedule and email out the pulled data file.
Here's the Bash script:
#!/bin/bash
# Script to create drive space file output
# Source Data
. /var/tmp/build/bin/appsetup
# Clean up old file if needed
rm /data/drivespace.txt
# Define Log file location
LOGPATH="/var/log/"
LOGFILE="drivespace.log"
LOGTAG="Drive Space Script"
function error_trap {
echo "Something went wrong!"
write_log "Error" "Error:$1, Caller:$(caller), Command:${BASH_COMMAND})"
}
function write_log {
if [ ! -d "$LOGPATH" ];
then
mkdir $LOGPATH
fi
d=`date +%m_%d_%Y`
t=`date +%T`
echo [$d] [$t] "$1: " $2 >> $LOGPATH$LOGFILE
}
# Set error trap function
trap 'error_trap $?' ERR
# Set up Logging...
write_log "Info" "------------------------------------------------"
write_log "Info" "Script Invoked as User: $User"
write_log "Info" "Script Tag: $LOGTAG"
# Check for Kens Directory
DIR=/data
if [ ! -d "$DIR" ];
then
mkdir /data
fi
# Write drive space info to file
dsv-balance-show >> /data/drivespace.txt
write_log "Info" "Writting drive space info to file."
Here's the Powershell function:
Function Get-OVCDriveSpace
{
[CmdletBinding()]
param
(
$Hosts,
[string]$Outfile,
[System.Management.Automation.PSCredential]$Creds
)
# Check output folder
if (!(Test-Path -Path 'C:\Temp' -PathType Container))
{
[Void](New-Item -ItemType Directory -Path 'C:\Temp' -Force)
}
Set-Content -Path $Outfile -Value ''
foreach ($HostItem in $Hosts)
{
$SessionID = New-SSHSession -ComputerName $HostItem.IP -Credential $Creds -AcceptKey -ConnectionTimeout 20
Write-Log -LogFolderPath $LogPath -LogFilePrefix $ScriptName -Message "SSH Session created to host: $($Hostitem.IP)."
$null = Invoke-SSHCommand -SessionId $SessionID.SessionId -Command 'sudo /etc/drivespace.sh'
Write-Log -LogFolderPath $LogPath -LogFilePrefix $ScriptName -Message "Remote command executed on host: 'sudo /etc/drivespace.sh'."
$null = pscp.exe -scp -pw $Creds.GetNetworkCredential().Password -l $Creds.UserName "$($HostItem.IP):/data/drivespace.txt" "/Temp/$($HostItem.Name).txt"
Write-Log -LogFolderPath $LogPath -LogFilePrefix $ScriptName -Message "Remove file retrieved from host: 'Drivespace.txt'."
Write-Log -LogFolderPath $LogPath -LogFilePrefix $ScriptName -Message "Local file saved from host: '$($Hostitem.Name).txt'."
$null = Remove-SSHSession -SessionId $SessionID.SessionId
Write-Log -LogFolderPath $LogPath -LogFilePrefix $ScriptName -Message "SSH Session Closed."
$HostItem.Name | Add-Content $Outfile
Get-Content -Path "C:\Temp\$($HostItem.Name).txt" | Add-Content $Outfile
"`r`n" | Add-Content $Outfile
Write-Log -LogFolderPath $LogPath -LogFilePrefix $ScriptName -Message "File content added to '$Outfile'."
}
}
Thanks,